BPF List
 help / color / mirror / Atom feed
From: hawk@kernel.org
To: netdev@vger.kernel.org
Cc: bpf@vger.kernel.org, mkroemeke@cloudflare.com,
	matt@readmodwrite.com, kernel-team@cloudflare.com,
	hawk@kernel.org, simon.schippers@tu-dortmund.de,
	Andrew Lunn <andrew+netdev@lunn.ch>,
	"David S. Miller" <davem@davemloft.net>,
	Eric Dumazet <edumazet@kernel.org>,
	Jakub Kicinski <kuba@kernel.org>, Paolo Abeni <pabeni@redhat.com>,
	Alexei Starovoitov <ast@kernel.org>,
	Daniel Borkmann <daniel@iogearbox.net>,
	John Fastabend <john.fastabend@gmail.com>,
	Stanislav Fomichev <sdf@fomichev.me>,
	Toshiaki Makita <toshiaki.makita1@gmail.com>
Subject: [PATCH net 0/3] veth: fix lost NAPI wakeup with threaded NAPI
Date: Mon, 30 Nov 2026 10:39:57 +0100	[thread overview]
Message-ID: <20261130094000.2022376-1-hawk@kernel.org> (raw)

From: Jesper Dangaard Brouer <hawk@kernel.org>

On ARM64 servers (Ampere Altra Max) with threaded NAPI, veth TX queues
can stall permanently. The peer rq has rx_notify_masked set while its
NAPI is idle. Producers then skip scheduling NAPI, and nothing drains
the ptr_ring. With a qdisc, the TXQ stays stopped, because of commit
dc82a33297fc ("veth: apply qdisc backpressure on full ptr_ring to
reduce TX drops"). Without a qdisc, veth silently drops all packets for
that queue.

The cause is a missing write barrier. __veth_xdp_flush() stores
rx_notify_masked = true, then __napi_schedule() sets
NAPI_STATE_SCHED_THREADED with a relaxed set_bit(). On ARM64 the second
store can become visible first. An awake NAPI kthread on another CPU
then runs a full poll and stores rx_notify_masked = false, and the late
true store lands after it. Commit 68468d8c4cd4 ("veth: fix races around
rq->rx_notify_masked") opened this window, when it moved
napi_schedule_prep() before the store.

Patch 1 is a failsafe. It enables dev_watchdog for veth and recovers
the peer NAPI on TX timeout. A TXQ wake alone does not help, because
veth_xmit() hits the full ring and stops the TXQ again. We found the
bug fixed by commit 5442a9da6978 ("veth: more robust handing of race to
avoid txq getting stuck") with a similar watchdog patch in production.

Patch 2 is the fix: smp_wmb() in __veth_xdp_flush().

Patch 3 adds the same barrier to the re-arm path in veth_poll(). That
path can only race when a socket busy-polls a threaded NAPI. The patch
moves the schedule sequence into one helper, so both paths share it.

herd7 litmus tests back both patches, for LKMM and for herd7's arm64
model. Without a barrier, the bad state is reachable. With patch 2
only, it is still reachable through the busy poll re-arm. With both
patches, no test reaches it. Tests and results:

  https://github.com/netoptimizer/veth-backpressure-performance-testing/pull/15

Testing: in virtme-ng we starved the peer NAPI kthread for 12 seconds
under a UDP flood, on 6.18 and on the net tree. The watchdog fired, the
queue recovered, and the kernel log had no warnings. The test cannot
reproduce the ARM64 race, but it shows that the watchdog recovery
works. selftests/net/veth.sh passes. The test is here:

  https://github.com/netoptimizer/veth-backpressure-performance-testing/pull/14

Jesper Dangaard Brouer (2):
  veth: enable dev_watchdog and recover stalled peer NAPI
  veth: order rx_notify_masked store in the veth_poll() re-arm path

Marek Kroemeke (1):
  veth: order rx_notify_masked store before __napi_schedule()

 drivers/net/veth.c | 63 ++++++++++++++++++++++++++++++++++++++--------
 1 file changed, 52 insertions(+), 11 deletions(-)

-- 
2.43.0


             reply	other threads:[~2026-11-30  9:40 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-11-30  9:39 hawk [this message]
2026-11-30  9:39 ` [PATCH net 1/3] veth: enable dev_watchdog and recover stalled peer NAPI hawk
2026-11-30  9:39 ` [PATCH net 2/3] veth: order rx_notify_masked store before __napi_schedule() hawk
2026-11-30  9:40 ` [PATCH net 3/3] veth: order rx_notify_masked store in the veth_poll() re-arm path hawk
2026-11-30 11:35 ` [PATCH net 0/3] veth: fix lost NAPI wakeup with threaded NAPI Jesper Dangaard Brouer

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=20261130094000.2022376-1-hawk@kernel.org \
    --to=hawk@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=john.fastabend@gmail.com \
    --cc=kernel-team@cloudflare.com \
    --cc=kuba@kernel.org \
    --cc=matt@readmodwrite.com \
    --cc=mkroemeke@cloudflare.com \
    --cc=netdev@vger.kernel.org \
    --cc=pabeni@redhat.com \
    --cc=sdf@fomichev.me \
    --cc=simon.schippers@tu-dortmund.de \
    --cc=toshiaki.makita1@gmail.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