Netdev List
 help / color / mirror / Atom feed
From: netdev-bot+sashiko@kernel.org
To: tianyi@cloudflare.com
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
Subject: Re: [PATCH net-next v2 1/3] veth: refactor NAPI enable paths
Date: Sun, 15 Nov 2026 02:13:52 +0000	[thread overview]
Message-ID: <179470883254.2199510.15270739408094114749@kernel.org> (raw)
In-Reply-To: <20261111015922.67745-2-tianyi@cloudflare.com>

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

  reply	other threads:[~2026-11-15  2:13 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-11-11  1:59 [PATCH net-next v2 0/3] veth: link RX queues to their NAPI instances Tianyi Gao
2026-11-11  1:59 ` [PATCH net-next v2 1/3] veth: refactor NAPI enable paths Tianyi Gao
2026-11-15  2:13   ` netdev-bot+sashiko [this message]
2026-11-11  1:59 ` [PATCH net-next v2 2/3] veth: link RX queues to their NAPI instances Tianyi Gao
2026-11-15  2:13   ` netdev-bot+sashiko
2026-11-11  1:59 ` [PATCH net-next v2 3/3] selftests: net: veth: test RX queue NAPI links Tianyi Gao

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=179470883254.2199510.15270739408094114749@kernel.org \
    --to=netdev-bot+sashiko@kernel.org \
    --cc=andrew+netdev@lunn.ch \
    --cc=ast@kernel.org \
    --cc=bpf@vger.kernel.org \
    --cc=daniel@iogearbox.net \
    --cc=davem@davemloft.net \
    --cc=edumazet@kernel.org \
    --cc=hawk@kernel.org \
    --cc=horms@kernel.org \
    --cc=john.fastabend@gmail.com \
    --cc=kernel-team@cloudflare.com \
    --cc=kuba@kernel.org \
    --cc=linux-kselftest@vger.kernel.org \
    --cc=lorenzo@kernel.org \
    --cc=netdev@vger.kernel.org \
    --cc=pabeni@redhat.com \
    --cc=sdf@fomichev.me \
    --cc=shuah@kernel.org \
    --cc=tianyi@cloudflare.com \
    --cc=toke@redhat.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox