From: Jesper Dangaard Brouer <ha…@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