BPF List
 help / color / mirror / Atom feed
* [PATCH net 0/3] veth: fix lost NAPI wakeup with threaded NAPI
@ 2026-11-30  9:39 hawk
  2026-11-30  9:39 ` [PATCH net 1/3] veth: enable dev_watchdog and recover stalled peer NAPI hawk
                   ` (3 more replies)
  0 siblings, 4 replies; 5+ messages in thread
From: hawk @ 2026-11-30  9:39 UTC (permalink / raw)
  To: netdev
  Cc: bpf, mkroemeke, matt, kernel-team, hawk, simon.schippers,
	Andrew Lunn, David S. Miller, Eric Dumazet, Jakub Kicinski,
	Paolo Abeni, Alexei Starovoitov, Daniel Borkmann, John Fastabend,
	Stanislav Fomichev, Toshiaki Makita

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


^ permalink raw reply	[flat|nested] 5+ messages in thread

end of thread, other threads:[~2026-11-30 11:35 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-11-30  9:39 [PATCH net 0/3] veth: fix lost NAPI wakeup with threaded NAPI hawk
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

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox