Merge branch 'veth-fix-txqs-that-are-never-woken-after-backpressure'

Simon Schippers says:

====================
veth: fix txqs that are never woken after backpressure

While debugging the veth BQL series [1], I found two ways in which a veth
txq that veth_xmit() stopped on a full ptr_ring is never woken again.

Patch 1 lets veth_poll() wake txqs beyond real_num_tx_queues, as a txq
stopped before a TX channel shrink is otherwise left stopped.

Patch 2 wakes the peer txq when NAPI is deleted, as veth_xmit() can stop
it after the last poll.

The reproducers are below the --- of each patch. Patch 1 reproduces
without changes to the kernel, patch 2 needs a debug-only udelay() to
widen the race window.

Claude Opus 5.5 was used heavily for this series, to find and reproduce
both bugs and to write the patches.

[1] https://lore.kernel.org/netdev/[email protected]/
====================

Link: https://patch.msgid.link/[email protected]
Signed-off-by: Paolo Abeni <[email protected]>
This commit is contained in:
Paolo Abeni
2026-11-19 11:51:05 +01:00
+8 -1
View File
@@ -984,7 +984,7 @@ static int veth_poll(struct napi_struct *napi, int budget)
/* NAPI functions as RCU section */
peer_dev = rcu_dereference_check(priv->peer, rcu_read_lock_bh_held());
peer_txq = (peer_dev && queue_idx < peer_dev->real_num_tx_queues) ?
peer_txq = (peer_dev && queue_idx < peer_dev->num_tx_queues) ?
netdev_get_tx_queue(peer_dev, queue_idx) : NULL;
xdp_set_return_frame_no_direct();
@@ -1087,6 +1087,7 @@ static int __veth_napi_enable(struct net_device *dev)
static void veth_napi_del_range(struct net_device *dev, int start, int end)
{
struct veth_priv *priv = netdev_priv(dev);
struct net_device *peer;
int i;
for (i = start; i < end; i++) {
@@ -1099,11 +1100,17 @@ static void veth_napi_del_range(struct net_device *dev, int start, int end)
}
synchronize_net();
peer = rtnl_dereference(priv->peer);
for (i = start; i < end; i++) {
struct veth_rq *rq = &priv->rq[i];
rq->rx_notify_masked = false;
ptr_ring_cleanup(&rq->xdp_ring, veth_ptr_free);
/* veth_poll() can no longer wake a txq stopped on a full ring */
if (peer && i < peer->num_tx_queues)
netif_wake_subqueue(peer, i);
}
for (i = start; i < end; i++) {