๐Ÿš€ go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: linux.kernel.netdev
Article #16505

Re: [PATCH net-next v2 1/3] veth: refactor NAPI enable paths

#16505
From: netdev-bot+sashiko
Date: Sun, 15 Nov 2026 02:13
80 lines
11016 bytes
Thank you for your contribution! Sashiko AI review found more severe
issue(s) in other patches of this series. This mail is only an FYI, in case
you want to address the nit picks below when you respin.

Low priority / nit picks for your consideration:

- [Low] This patch changes the order of NAPI setup in
  veth_napi_enable_range() (drivers/net/veth.c).

--

veth: refactor NAPI enable paths

This patch stops passing rq->xdp_napi.napi_id to xdp_rxq_info_reg(). It
moves netif_napi_add() out of veth_enable_xdp_range() and the old
veth_napi_enable_range() wrapper and into the loop in
__veth_napi_enable_range() that enables each NAPI. The trivial wrappers
are removed, and the double-underscore helpers take over their names.

> diff --git a/drivers/net/veth.c b/drivers/net/veth.c
> index 0539b3661793d..f5097696df15e 100644
> --- a/drivers/net/veth.c
> +++ b/drivers/net/veth.c

[ ... ]

> @@ -1059,6 +1059,7 @@ static int __veth_napi_enable_range(struct net_device *dev, int start, int end)
>  	for (i = start; i < end; i++) {
>  		struct veth_rq *rq = &priv->rq[i];
>  
> +		netif_napi_add(dev, &rq->xdp_napi, veth_poll);
>  		rcu_assign_pointer(rq->xdp_prog, priv->_xdp_prog);
>  		napi_enable(&rq->xdp_napi);

[Severity: Low]
Can this leave a veth device with threaded NAPI half on and half off?

Before this patch, every caller added all NAPIs in the range before it
enabled any of them. The core seems to depend on that order.
netif_napi_add_weight_locked() in net/core/dev.c says:

	/* Create kthread for this napi if dev->threaded is set.
	 * Clear dev->threaded if kthread creation failed so that
	 * threaded mode will not be enabled in napi_enable().
	 */
	if (napi_get_threaded_config(dev, napi))
		if (napi_kthread_create(napi))
			dev->threaded = NETDEV_NAPI_THREADED_DISABLED;

napi_enable_locked() reads dev->threaded at the time it runs:

	if (n->dev->threaded && n->thread)
		new |= NAPIF_STATE_THREADED;

With add and enable now in the same loop, suppose threaded mode is on and
napi_kthread_create() fails for some queue k > start. Queues start..k-1
have already been enabled with NAPIF_STATE_THREADED. Queue k and the
queues after it come up non-threaded, and dev->threaded is cleared.

The device then reports threaded mode as disabled through sysfs and
netlink, while some of its NAPIs are still polled by kthreads. This can
happen in any path that reaches veth_napi_enable_range():
veth_set_features() toggling GRO, veth_set_channels() calling
veth_enable_range_safe(), veth_open(), and veth_enable_xdp(). The
kthread_run() failure can come from ENOMEM or from a pending fatal
signal.

netif_set_threaded() avoids this state by reverting all NAPIs when
kthread creation fails, but this path doesn't do that.

Could netif_napi_add() stay in its own loop over the whole range? It
could sit after the page_pool and ptr_ring allocations that can fail and
before the napi_enable() loop. That would keep the new error handling
and the old ordering.

[ ... ]

-- 
Sashiko AI review ยท https://netdev-ai.bots.linux.dev/sashiko/#/patchset/20261111015922.67745-1-tianyi%40cloudflare.com
Technical Details
Message-ID: <179470883254.2199510.15270739408094114749@kernel.org>
Path: mbox-mo1.pugleaf.net!news-lax.pugleaf.net!usenet.blueworldhosting.com!diablo1.usenet.blueworldhosting.com!usenet.network!.POSTED!vger.kernel.org!netdev+bounces-363526-linux-kernel-netdev=dewy.ru
References: <20261111015922.67745-2-tianyi@cloudflare.com>

Show Full Headers
Complete Article Headers
Path: mbox-mo1.pugleaf.net!news-lax.pugleaf.net!usenet.blueworldhosting.com!diablo1.usenet.blueworldhosting.com!usenet.network!.POSTED!vger.kernel.org!netdev+bounces-363526-linux-kernel-netdev=dewy.ru
From: netdev-bot+sashiko@kernel.org
Newsgroups: linux.kernel.netdev
Subject: Re: [PATCH net-next v2 1/3] veth: refactor NAPI enable paths
Date: Sun, 15 Nov 2026 02:13:52 +0000
Organization: Usenet Network
Message-ID: <179470883254.2199510.15270739408094114749@kernel.org>
References: <20261111015922.67745-2-tianyi@cloudflare.com>
MIME-Version: 1.0
Content-Type: text/plain; charset="utf-8"
Content-Transfer-Encoding: 8bit
Injection-Info: usenet.network;
	logging-data="1710094"; mail-complaints-to="abuse@usenet.network"
Cancel-Lock: sha1:xcrX6l4znyk5hww2ipjUEajItwI= sha256:ITdnldhbBTB4EZRGfrWmVlanbSMqiq0fli7YU2WMub4=
	sha1:gf/R9PVm/gis3y3SA4EPJnxI2xg= sha256:+PB9LJEEX470H0Kp9Aw1NFjdFvCz4ze+qUQSnZUy7e0=
List-ID: <netdev.vger.kernel.org>
X-Mailpost-Empty-Hdrs: X-Spam-Level
X-Received: from localhost (localhost [127.0.0.1])
	by mail.dewy.ru (Postfix) with ESMTP id 6BBCC11491A; Sun, 15 Nov 2026 05:14:25 +0300 (MSK)
X-Virus-Scanned: Debian amavisd-new at usenet.network
X-Spam-Flag: NO
X-Spam-Score: -3.501
X-Spam-Status: No, score=-3.501 tagged_above=-9999 required=6.31
	tests=[DKIMWL_WL_HIGH=-0.001, DKIM_SIGNED=0.1, DKIM_VALID=-0.1,
	DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, MAILING_LIST_MULTI=-1,
	RCVD_IN_DNSWL_MED=-2.3, SPF_HELO_NONE=0.001, SPF_PASS=-0.001]
	autolearn=ham autolearn_force=no
X-Authentication-Results: mail.dewy.ru (amavisd-new); dkim=pass (2048-bit key)
	header.d=kernel.org
X-Received: from mail.dewy.ru ([127.0.0.1])
	by localhost (mail.dewy.ru [127.0.0.1]) (amavisd-new, port 10024)
	with ESMTP id d6Zywu1t_PLd;
	Sun, 15 Nov 2026 05:14:21 +0300 (MSK)
X-Received-SPF: Pass (mailfrom) identity=mailfrom; client-ip=172.232.135.74; helo=sto.lore.kernel.org; envelope-from=netdev+bounces-363526-linux-kernel-netdev=dewy.ru@vger.kernel.org; receiver=<UNKNOWN> 
X-Authentication-Results: OpenDMARC; dmarc=pass (p=quarantine dis=none) header.from=kernel.org
X-Received: from sto.lore.kernel.org (sto.lore.kernel.org [172.232.135.74])
	by mail.dewy.ru (Postfix) with ESMTPS id 1D9581148AD; Sun, 15 Nov 2026 05:14:11 +0300 (MSK)
X-Received: from smtp.subspace.kernel.org (conduit.subspace.kernel.org [100.77.114.92])
	by sto.lore.kernel.org (Postfix) with ESMTP id 15C8C60DE57; Sun, 15 Nov 2026 02:14:07 +0000 (UTC)
X-Authentication-Results: smtp.subspace.kernel.org; arc=pass header.oldest-pass=0 smtp.remote-ip=127.0.0.1
X-ARC-Seal: i=2; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=pass;
	t=1794708840;
	b=qqAC/8JbQRZ6tyj75OmhgBlIs/6th06MMYLDMxIFzMh0TBnMDtBaDDt1IzGcq23S20B7
	 XSIXSWXYoTrnCkkDabhQ5fFYdctAMVu4RftvLC6rM4aNpVuqA33mbpGFfWNtad6lusUwr
	 p/FEv99CnwgUtcr+pmiUH7RdRrEI5QPJYfICn1xyU7nc13CKAHy+ouIonh14Dj74J7nDQ
	 74fgZOux3rlMLX6+DQb6fzd2d+46xdqY6OP+v1nBVsqJHKiC5GVW8D7smf6q0kwiVF6qS
	 dHra+QPmI4r+DXStiLRtGQIUt/5zXBZmmleX2v4s0Z9AmNzgG4poXo6fy2Hc82ReniA==
X-ARC-Message-Signature: i=2; d=subspace.kernel.org; s=arc20261015;
	a=rsa-sha256; c=relaxed/relaxed; t=1794708840;
	h=X-Original-To:Received:Received:DKIM-Signature:Subject:From:To:Cc:
	 Date:Message-ID:In-Reply-To:References:X-sashiko-severity:
	 Content-Type:Content-Transfer-Encoding:X-Mailing-List:List-Id:
	 List-Post:List-Help:List-Subscribe:List-Unsubscribe:List-Owner:
	 Precedence:MIME-Version;
	bh=sbNcZKPG9w7AwGG2dtrY7nVCYbAVfu7qnvLtENI0C/U=;
	b=tnHW3t6fpkaR8e26/VTKgnzYDyISnCqvoNr4p6Z7CLXTitxZetK1ue0EGEnLgidRt7X1
	 6uwuG/4HtYuEklpg9KHqFyQy1J+13DCf1FX4SLI1u+8Tt9fnhcUawhXFC8ARc33jt6xCF
	 0XMezPmT3Lc8vinQ+ZRSMG8ze//mVxvgV8dOCzIpGxme3Mw4rKZaXqTWoVSH/yJBwLMz0
	 SFL9i/gq8tyNZPIDMfcyE/NEfI58cEMm4+uBVPSfWoh12S6RLhqYbbogc9dj+2bdH7de8
	 uvva26aXHAkpx53pYD+OI5RY8jqCB+hdl4fZQHl+nydprlaCN+s/ygjfIeB+vHiPXCg==
X-ARC-Authentication-Results: i=2; smtp.subspace.kernel.org; 
	dkim=pass header.d=kernel.org header.i=@kernel.org header.a=rsa-sha256 header.s=k20260515 header.b="U+/SfPFx";
	arc=pass header.oldest-pass=0 smtp.remote-ip=127.0.0.1
X-Received: from localhost.localdomain (localhost [127.0.0.1])
	by smtp.subspace.kernel.org (Postfix) with ESMTP id 4E992606A32C;
	Sun, 15 Nov 2026 02:14:00 +0000 (UTC)
X-Authentication-Results: smtp.subspace.kernel.org;
	dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.a=rsa-sha256 header.s=k20260515 header.b=U+/SfPFx
X-Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.remote-ip=100.103.45.18
X-ARC-Seal: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=none;
	t=1794708834;
	b=hBaL7uxZ3L/s0QE5uYVjhdnOaCEnj031gHgJSRrVwbVQS1SI3BFA2Wq3B9NsVBtkJMv/
	 P1n4atrkNo5llXSVO4bgomQOXW9lHJJgNqKzzhedryujKMbPwUfX536SPd6k9KzOA4f6f
	 m4Xt9BMZfvSYAfb269GMZ/8/1OWi1IrBnFLkIkXM0ooNkpb7j+b5aC+OFpfdYX3Vj7C85
	 3A2hbpT0cyTxJS5NnrtRhvjiOx5PMH7PXGHBZVI4DNvBc2bqwRUReIGF6A45sVZqIjXIs
	 ecFvOh0Mv2kYN6woTL5GNXTs/W2pqS7jjPOA7se0QbI5uBonKqPrLQqkoMpqtDXhzWQ==
X-ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015;
	a=rsa-sha256; c=relaxed/relaxed; t=1794708834;
	h=Received:DKIM-Signature:Subject:From:To:Cc:Date:Message-ID:
	 In-Reply-To:References:X-sashiko-severity:Content-Type:
	 Content-Transfer-Encoding:MIME-Version;
	bh=sbNcZKPG9w7AwGG2dtrY7nVCYbAVfu7qnvLtENI0C/U=;
	b=n24Zt7DlsIp9jO3epLVbFHdPn+LS8+La3GCVNpCp//rClMCACqWrLAFeP04YTIgP0x4X
	 280ssk4yF50/6WTbs9D7rqaGd14Nr/1/AFncvMkTqJEAjFprgYdoOsZTCT1IcfzqXB2xg
	 3FDyZlB05W9CWIWRMhE9UIjeulIixxvhHFHHx/Huo5PrWzix5cph+YFORSk2sE1f/cSoB
	 nYQ2mTc3z1kuIEN0irn06Jlcok0Sf1cM8QM241bxZslqlN+rh+f2UUzVuqlGkgP7VtG+1
	 5LFDLT3BDlh6CO2SiepA0SzTEUNbixsfTEgvta3p+VIMJDE1FMRp8NpnrEAnfJl3itg==
X-ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; 
	dkim=pass header.d=kernel.org header.i=@kernel.org header.a=rsa-sha256 header.s=k20260515 header.b="U+/SfPFx";
	arc=none smtp.remote-ip=100.103.45.18
X-Received: from smtp.kernel.org (quasi.space.kernel.org [100.103.45.18])
	(using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)
	 key-exchange X25519 server-signature ECDSA (prime256v1))
	(No client certificate requested)
	by smtp.subspace.kernel.org (Postfix) with ESMTPS id 697E1606A323;
	Sun, 15 Nov 2026 02:13:54 +0000 (UTC)
X-Received: by smtp.kernel.org (Postfix) with ESMTPSA id 02AE11F000C5;
	Sun, 15 Nov 2026 02:13:52 +0000 (UTC)
X-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=kernel.org;
	s=k20260515; t=1794708833;
	bh=sbNcZKPG9w7AwGG2dtrY7nVCYbAVfu7qnvLtENI0C/U=;
	h=Subject:From:To:Cc:Date:In-Reply-To:References;
	b=U+/SfPFxkpqYB8YbpJNl7wi+RwjaQguYH2qsk0ik2i0LfvoepIKL1gAe3Kwmji6au
	 iAw8IJ/Je3//m3O6cRD8HfnlpiBZc85vDUl/1uJOlEMZPEyZjrnXG/4CnUrd96kO83
	 5OcrqesJHVQsQB0f40OAJnJaEF/rEC9uws8y0Wob8BxJpdPF2oABrL6TrBkQoSNywd
	 1p13ouLUf/8AK136C5g7ifRe7zz3K3nLKHEcC9bDH5Nj/pknYigYeC+W+3reGdZqDE
	 d0+KDB9KF5JzNAfmwHFLybA4Vl4ExLBxGxxQKL12U3riHGmujXBgKALKeqTjGbRp0e
	 bjl/qiizpQn7A==
X-Cc: netdev@vger.kernel.org, andrew+netdev@lunn.ch, davem@davemloft.net,
 edumazet@kernel.org, kuba@kernel.org, pabeni@redhat.com, toke@redhat.com,
 lorenzo@kernel.org, horms@kernel.org, bpf@vger.kernel.org, shuah@kernel.org,
 hawk@kernel.org, kernel-team@cloudflare.com, ast@kernel.org,
 daniel@iogearbox.net, john.fastabend@gmail.com, sdf@fomichev.me,
 linux-kselftest@vger.kernel.org
X-In-Reply-To: <20261111015922.67745-2-tianyi@cloudflare.com>
X-sashiko-severity: Low
X-Mailing-List: netdev@vger.kernel.org
X-List-Post: <mailto:netdev@vger.kernel.org>
X-List-Help: <mailto:netdev+help@vger.kernel.org>
X-List-Subscribe: <mailto:netdev+subscribe@vger.kernel.org>
X-List-Unsubscribe: <mailto:netdev+unsubscribe@vger.kernel.org>
X-List-Owner: <mailto:netdev+owner@vger.kernel.org>
X-Precedence: list