Received: by 10.213.65.68 with SMTP id h4csp475761imn; Fri, 16 Mar 2018 08:54:55 -0700 (PDT) X-Google-Smtp-Source: AG47ELtEwe+V1EN2EfUnF2QhnsxKUGEGEsoznZP4r1FuNJbUoyUDh4oX836jGm4MDG9SIf76djVe X-Received: by 10.99.116.85 with SMTP id e21mr1841374pgn.218.1521215695873; Fri, 16 Mar 2018 08:54:55 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1521215695; cv=none; d=google.com; s=arc-20160816; b=VLi4DMdi/34d30ob2GPlxH+3tKJQ99vfUcqiehrGDEv/V8zktee2+yLaqwCiG6Uk+R bvWN9wQxra6y5ViS49dz2FTwJSP5XqxBu7DHjez6pieVVUN5D2FOmHl1rwLbYY+XaNoH /jeiQ7lsBM6/IXVSsGSNPW4eKEVUA6A4F+4kSBlcP5tv/Wb8z2X3WrK3mozAK9hq3VoU /UgJDJFGN6sjWZndRC4qLkZhIdsc5T18cN09kG68ZAawxAYyoC/2YdXvHdSCbs3MzDzi 7/5X7tutmRP40DBX5bt3xWQm1YCfnZhRhJSTVOEsDFspl+6xnFzGh4+ZiMKCMbIIukrL dMJw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:mime-version:user-agent:references :in-reply-to:message-id:date:subject:cc:to:from :arc-authentication-results; bh=ydPwZC476Y9xlbVr5OAQTH5qdy5nf2lwnBCpydZWm10=; b=bwYxrQoVhe8FoaI59d2rzWxVAeFDO2Aegvvs1AQZPDoAPcSXhP79LlgHvaqa6FuFMk 3xv7ponYTDdt64rfLXXZwlH3UcfueV9Wy7CvYLrMS4hlYprBCUjuJXvurkgsqWLG/onD wUUSQxyCfQ1WX6unYFyQwqu6zcAo/XVWe+BI/A3L1tdb+tC2IcFsmLjdIYACB7vRt3AD parUZzHOFTjLLSpzjzftVHwJeoZTSVM7IQH9o0AUMGT+/VEZlAdtl888mhWLhrYcgh2k CNN9qWPyJzy2+b3yE2ar+r5i+WtABvphevKOSuQKwkYDoly9+W1Nk1RsEXAZ/Ie0DhB4 lfWQ== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id t14si700510pgr.277.2018.03.16.08.54.41; Fri, 16 Mar 2018 08:54:55 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S965375AbeCPPoL (ORCPT + 99 others); Fri, 16 Mar 2018 11:44:11 -0400 Received: from mail.linuxfoundation.org ([140.211.169.12]:45852 "EHLO mail.linuxfoundation.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S965364AbeCPPoI (ORCPT ); Fri, 16 Mar 2018 11:44:08 -0400 Received: from localhost (LFbn-1-12247-202.w90-92.abo.wanadoo.fr [90.92.61.202]) by mail.linuxfoundation.org (Postfix) with ESMTPSA id 47026DD9; Fri, 16 Mar 2018 15:44:08 +0000 (UTC) From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Toshiaki Makita , "Michael S. Tsirkin" , Jason Wang , "David S. Miller" , Sasha Levin Subject: [PATCH 4.15 108/128] virtio_net: Disable interrupts if napi_complete_done rescheduled napi Date: Fri, 16 Mar 2018 16:24:09 +0100 Message-Id: <20180316152341.923418133@linuxfoundation.org> X-Mailer: git-send-email 2.16.2 In-Reply-To: <20180316152336.199007505@linuxfoundation.org> References: <20180316152336.199007505@linuxfoundation.org> User-Agent: quilt/0.65 X-stable: review MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 4.15-stable review patch. If anyone has any objections, please let me know. ------------------ From: Toshiaki Makita [ Upstream commit fdaa767aefc1685f9a41e91f447c9aea94103df6 ] Since commit 39e6c8208d7b ("net: solve a NAPI race") napi has been able to be rescheduled within napi_complete_done() even in non-busypoll case, but virtnet_poll() always enabled interrupts before complete, and when napi was rescheduled within napi_complete_done() it did not disable interrupts. This caused more interrupts when event idx is disabled. According to commit cbdadbbf0c79 ("virtio_net: fix race in RX VQ processing") we cannot place virtqueue_enable_cb_prepare() after NAPI_STATE_SCHED is cleared, so disable interrupts again if napi_complete_done() returned false. Tested with vhost-user of OVS 2.7 on host, which does not have the event idx feature. * Before patch: $ netperf -t UDP_STREAM -H 192.168.150.253 -l 60 -- -m 1472 MIGRATED UDP STREAM TEST from 0.0.0.0 (0.0.0.0) port 0 AF_INET to 192.168.150.253 () port 0 AF_INET Socket Message Elapsed Messages Size Size Time Okay Errors Throughput bytes bytes secs # # 10^6bits/sec 212992 1472 60.00 32763206 0 6430.32 212992 60.00 23384299 4589.56 Interrupts on guest: 9872369 Packets/interrupt: 2.37 * After patch $ netperf -t UDP_STREAM -H 192.168.150.253 -l 60 -- -m 1472 MIGRATED UDP STREAM TEST from 0.0.0.0 (0.0.0.0) port 0 AF_INET to 192.168.150.253 () port 0 AF_INET Socket Message Elapsed Messages Size Size Time Okay Errors Throughput bytes bytes secs # # 10^6bits/sec 212992 1472 60.00 32794646 0 6436.49 212992 60.00 32793501 6436.27 Interrupts on guest: 4941299 Packets/interrupt: 6.64 Signed-off-by: Toshiaki Makita Acked-by: Michael S. Tsirkin Acked-by: Jason Wang Signed-off-by: David S. Miller Signed-off-by: Sasha Levin Signed-off-by: Greg Kroah-Hartman --- drivers/net/virtio_net.c | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) --- a/drivers/net/virtio_net.c +++ b/drivers/net/virtio_net.c @@ -261,9 +261,12 @@ static void virtqueue_napi_complete(stru int opaque; opaque = virtqueue_enable_cb_prepare(vq); - if (napi_complete_done(napi, processed) && - unlikely(virtqueue_poll(vq, opaque))) - virtqueue_napi_schedule(napi, vq); + if (napi_complete_done(napi, processed)) { + if (unlikely(virtqueue_poll(vq, opaque))) + virtqueue_napi_schedule(napi, vq); + } else { + virtqueue_disable_cb(vq); + } } static void skb_xmit_done(struct virtqueue *vq)