Received: by 10.213.65.68 with SMTP id h4csp499956imn; Fri, 16 Mar 2018 09:37:21 -0700 (PDT) X-Google-Smtp-Source: AG47ELuo7TBLeg7PQXzt2XAtusdARj/TsGlrd6H9Q4ZlMBo3Fz/trlAw2l/PCtN02IodjYRp6/j9 X-Received: by 10.98.72.205 with SMTP id q74mr1587188pfi.70.1521218241433; Fri, 16 Mar 2018 09:37:21 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1521218241; cv=none; d=google.com; s=arc-20160816; b=cuhIXzVoryWYe1F22ggckGPFGM9ZTz/hT0rkLAjgKDjSYwMNRbaPHVeKEfBKLqpefV jgrae6WtEL9vdkHf9GuXGLVLyuxd0Z2kwdnPaAHJAC7GgYBSfMJKI76MLiHpWm/VKMCn iUMYaKlfHTb7iONzm5cTFGuqkBm+Sd3dwXHFtd1atVu/DhlIJE2oKLTW0J3xndpuzQsR 1xfNHarEInd+DdwvSM7o3NPfpSnPeKOUtgFX1CfOyhTBVehwSYoNh/w7fsRaI4RAbQ54 3f7nIQIYecloMK18BtitqhKyx2qwFiu+eBKzn/BiCwCy0FY+LjvR3NjBy2M4Imxe0Z8f gD/w== 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=rcRpeHKEY3TYIyHCnPiYWjA7eg1lySW6ttXBREUAlbA=; b=IQhque8+N3ORW72mjbliJJ8h8q+NgX8OfSm47uUheBDddrzi8fyA7OXaSj1GoA8zsA ZyAUCl3biuYpiylH0+WoLgPL/6TVRbpZNlTiCsvp5Bkw3hwM5PelZvnu58MFVIhK1RIG OW721tNZ3L7XoY3Jx/7/BTInz0sO7nxiUOrp17iS3OciXnawGXTeTrxc9pfQZFbPjnRC EysgcaCvT4sUwhiV2WEwjOmOdfEa407vWhcc2Irc6BQMEgXeISFkiTkqqyAtpl7bXLoO nhzQRwWIXmapY4f1owbvyBkAlolFvEvY2WtiMhMuW3rYAykoVZSsFD7ZMV1iITmf7A2V sHZw== 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 c14si5080562pgu.341.2018.03.16.09.37.07; Fri, 16 Mar 2018 09:37:21 -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 S1753053AbeCPQeY (ORCPT + 99 others); Fri, 16 Mar 2018 12:34:24 -0400 Received: from mail.linuxfoundation.org ([140.211.169.12]:42062 "EHLO mail.linuxfoundation.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S934183AbeCPPiD (ORCPT ); Fri, 16 Mar 2018 11:38:03 -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 97B0B1265; Fri, 16 Mar 2018 15:37:54 +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.14 089/109] virtio_net: Disable interrupts if napi_complete_done rescheduled napi Date: Fri, 16 Mar 2018 16:23:58 +0100 Message-Id: <20180316152334.770534110@linuxfoundation.org> X-Mailer: git-send-email 2.16.2 In-Reply-To: <20180316152329.844663293@linuxfoundation.org> References: <20180316152329.844663293@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.14-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 @@ -260,9 +260,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)