Skip to content

veth: fix lost NAPI wakeup with threaded NAPI

[email protected] bpf netdev 1 version In review

Get series with b4
b4 am [email protected]

Versions newest first

  1. v1 Latest3 patches 1 replyIn review

Patches in v1 No applies recorded yet

#Subject and filesSizeRepliesApplied
1/3veth: enable dev_watchdog and recover stalled peer NAPIdrivers/net/veth.c+37 -00 replies
2/3veth: order rx_notify_masked store before __napi_schedule()drivers/net/veth.c+2 -00 replies
3/3veth: order rx_notify_masked store in the veth_poll() re-arm pathdrivers/net/veth.c+15 -130 replies

Reviews trailers per patch

No Reviewed-by, Acked-by or Tested-by trailers for v1 yet.

Read the v1 thread

Cover letter [PATCH net 0/3] veth: fix lost NAPI wakeup with threaded NAPI

From: Jesper Dangaard Brouer <[email protected]>

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(-)
Signature · 1 line
2.43.0