Received: by 10.223.185.116 with SMTP id b49csp6320558wrg; Wed, 28 Feb 2018 07:31:40 -0800 (PST) X-Google-Smtp-Source: AH8x227tviqCHwaMKevFdcMNzRmw2AX6/+QsB3/MQWZwjwUK8wNngwh6xjSMGU3OV7n5eKgapbc+ X-Received: by 10.101.72.199 with SMTP id o7mr14513397pgs.303.1519831900576; Wed, 28 Feb 2018 07:31:40 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1519831900; cv=none; d=google.com; s=arc-20160816; b=Ikxzlh4OB8FKUk7FqbH4iFWmT1+cmxZQbBlmKge5VdYnc7VR461kHHQQ3n5IDB1kr3 I5YITLKraYglc3HDQIQgGfcJYhnY/1Sufg06fGlgieYN00VTgLndrMhUC0ifv0OoJRKR R+3aPcrGXTqFvqUS+L5DhLs9ibXcmYQxvtetGcSA8V7VBQ5EfD6wDWg4bciUYjEHSMVt RFJrB2jrxOrWphutROv8gOMsLXvyR1Qeg/4MsfD4GWxBYN4Zsr8hvXfFIXZHlD1HD9a1 pXYWsduMl5ym/97fJpdadKX95aZrrwloZvE82ZDXJHGJRWlc/lXbNKiqk1pzFHFHEKZu kC4g== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:in-reply-to:content-disposition :mime-version:references:message-id:subject:cc:to:from:date :arc-authentication-results; bh=4fTGVMd0rej6+9DR9YyZYMownDhIt580jM/556IB2KA=; b=BGE81Ymobl3jCnqfhzMfQhLZFfPIcxaj5w2eYRW9mYRzzoIEKMS0omzrV6r9TU4rFb mua6g4qtB6QGBQ1rHR6mnVaVDWWVNJNZZC8PYtt3xT4Dm1y44J3fvjqj9Adi52C3h9Zz LzN9y1j/68PyjqI5WZHBdTB+Vv6GtzyBqkkhs9Wanjt3d7ZuaDPiw7WJckHmx29AkXLm P+GReAGFIPqaNGKsuB95P9HeTfivODgJ2/bMRxziURSIj3BqTLX35g3+tmgA7MPMc8xs H1e8MF4WSBpZl+o6oJsIYV1Wa4IyIWCIS0XnTlQ1d2VaS/Up78WbvKa02smfgPPDQ6e/ HOdA== 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; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=redhat.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id t134si1150651pgc.664.2018.02.28.07.31.24; Wed, 28 Feb 2018 07:31:40 -0800 (PST) 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; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=redhat.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S932891AbeB1P14 (ORCPT + 99 others); Wed, 28 Feb 2018 10:27:56 -0500 Received: from mx1.redhat.com ([209.132.183.28]:47674 "EHLO mx1.redhat.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S933021AbeB1P1v (ORCPT ); Wed, 28 Feb 2018 10:27:51 -0500 Received: from smtp.corp.redhat.com (int-mx06.intmail.prod.int.phx2.redhat.com [10.5.11.16]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id AD796356D5; Wed, 28 Feb 2018 15:27:51 +0000 (UTC) Received: from redhat.com (ovpn-123-220.rdu2.redhat.com [10.10.123.220]) by smtp.corp.redhat.com (Postfix) with SMTP id 0B1405E1D0; Wed, 28 Feb 2018 15:27:50 +0000 (UTC) Date: Wed, 28 Feb 2018 17:27:44 +0200 From: "Michael S. Tsirkin" To: Jason Wang Cc: virtualization@lists.linux-foundation.org, netdev@vger.kernel.org, linux-kernel@vger.kernel.org Subject: Re: [PATCH net] virtio-net: disable NAPI only when enabled during XDP set Message-ID: <20180228172739-mutt-send-email-mst@kernel.org> References: <1519813204-10002-1-git-send-email-jasowang@redhat.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <1519813204-10002-1-git-send-email-jasowang@redhat.com> X-Scanned-By: MIMEDefang 2.79 on 10.5.11.16 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.30]); Wed, 28 Feb 2018 15:27:51 +0000 (UTC) Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Wed, Feb 28, 2018 at 06:20:04PM +0800, Jason Wang wrote: > We try to disable NAPI to prevent a single XDP TX queue being used by > multiple cpus. But we don't check if device is up (NAPI is enabled), > this could result stall because of infinite wait in > napi_disable(). Fixing this by checking device state through > netif_running() before. > > Fixes: 4941d472bf95b ("virtio-net: do not reset during XDP set") > Signed-off-by: Jason Wang Acked-by: Michael S. Tsirkin > --- > drivers/net/virtio_net.c | 8 +++++--- > 1 file changed, 5 insertions(+), 3 deletions(-) > > diff --git a/drivers/net/virtio_net.c b/drivers/net/virtio_net.c > index 9bb9e56..2d54123 100644 > --- a/drivers/net/virtio_net.c > +++ b/drivers/net/virtio_net.c > @@ -2185,8 +2185,9 @@ static int virtnet_xdp_set(struct net_device *dev, struct bpf_prog *prog, > } > > /* Make sure NAPI is not using any XDP TX queues for RX. */ > - for (i = 0; i < vi->max_queue_pairs; i++) > - napi_disable(&vi->rq[i].napi); > + if (netif_running(dev)) > + for (i = 0; i < vi->max_queue_pairs; i++) > + napi_disable(&vi->rq[i].napi); > > netif_set_real_num_rx_queues(dev, curr_qp + xdp_qp); > err = _virtnet_set_queues(vi, curr_qp + xdp_qp); > @@ -2205,7 +2206,8 @@ static int virtnet_xdp_set(struct net_device *dev, struct bpf_prog *prog, > } > if (old_prog) > bpf_prog_put(old_prog); > - virtnet_napi_enable(vi->rq[i].vq, &vi->rq[i].napi); > + if (netif_running(dev)) > + virtnet_napi_enable(vi->rq[i].vq, &vi->rq[i].napi); > } > > return 0; > -- > 2.7.4