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 2/3] veth: link RX queues to their NAPI instances
Date: Sun, 15 Nov 2026 02:13:54 +0000	[thread overview]
Message-ID: <179470883411.2199510.13825316417997386083@kernel.org> (raw)
In-Reply-To: <20261111015922.67745-3-tianyi@cloudflare.com>

Thank you for your contribution! Sashiko AI review found 1 potential
issue(s) to consider.

Critical: 0 · High: 0 · Medium: 1 · Low: 0

If you believe none of the issues are legitimate, please reply to each
issue of Medium severity or higher and explain why the AI is wrong.
If any of them are legitimate and you plan to respin, please let patchwork
know by including "pw-bot: cr" as a separate line at the end of your reply
(one such reply per series is enough).

- [Medium] In drivers/net/veth.c, veth_napi_enable_range() still creates
  the per-queue NAPI with plain netif_napi_add(dev, &rq->xdp_napi,…

--

veth: link RX queues to their NAPI instances

This patch links each veth RX queue to its NAPI instance with
netif_queue_set_napi(). The link is set after napi_enable() and cleared
before napi_disable(). With it, queue-get reports a napi-id, and AF_XDP
copy-mode sockets bound to a veth queue get a NAPI ID for busy polling.

> diff --git a/drivers/net/veth.c b/drivers/net/veth.c
> index f5097696df15e..c042771864051 100644
> --- a/drivers/net/veth.c
> +++ b/drivers/net/veth.c
> @@ -1062,6 +1062,8 @@ static int veth_napi_enable_range(struct net_device *dev, int start, int end)
>  		netif_napi_add(dev, &rq->xdp_napi, veth_poll);
>  		rcu_assign_pointer(rq->xdp_prog, priv->_xdp_prog);
>  		napi_enable(&rq->xdp_napi);
> +		netif_queue_set_napi(dev, i, NETDEV_QUEUE_TYPE_RX,
> +				     &rq->xdp_napi);

[Severity: Medium]
Should this be netif_napi_add_config(dev, &rq->xdp_napi, veth_poll, i)
rather than netif_napi_add()?

As written, the queue-to-NAPI link only holds until the next
reconfiguration. veth_napi_del_range() deletes the NAPI completely, via
napi_disable() and then __netif_napi_del(). On the next enable,
napi_enable_locked() finds no n->config and allocates a new ID:

net/core/dev.c:napi_enable_locked() {
    ...
	if (n->config)
		napi_restore_config(n);
	else
		napi_hash_add(n);
    ...
}

So the same queue gets a new napi-id after each of these:

  - ip link set down/up (veth_close()/veth_open())
  - XDP detach and re-attach (veth_xdp_set())
  - a GRO toggle without XDP (veth_set_features())
  - ethtool -L (veth_disable_range_safe()/veth_enable_range_safe())

Any per-NAPI settings applied with napi-set are dropped silently on each
of these paths. That covers defer-hard-irqs, gro-flush-timeout,
irq-suspend-timeout and threaded.

An AF_XDP copy-mode socket is affected the same way. xsk_bind() records
the ID only once:

net/xdp/xsk.c:xsk_bind() {
    ...
		if (rxq->napi)
			__sk_mark_napi_id_once(sk, rxq->napi->napi_id);
    ...
}

The xsk notifier only unbinds on NETDEV_UNREGISTER, so the socket stays
bound across a down/up and keeps the old ID. Would sk_busy_loop() then
call napi_busy_loop() with an ID that no longer resolves, so busy polling
stops without any error?

The commit message gives napi-set and AF_XDP busy polling as the
motivation. Documentation/networking/napi.rst ("Persistent NAPI config")
says "Drivers should try to use netif_napi_add_config() whenever
possible." The queue index i is already available here, and
dev->napi_config has max(num_tx_queues, num_rx_queues) entries.

The selftest added later in this series ("selftests: net: veth: test RX
queue NAPI links") checks that the IDs match napi-get after each step.
It does not check that they stay the same across these reconfigurations.

>  		rcu_assign_pointer(priv->rq[i].napi, &priv->rq[i].xdp_napi);
>  	}
>  

[ ... ]

-- 
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
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 [this message]
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=179470883411.2199510.13825316417997386083@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