From mboxrd@z Thu Jan 1 00:00:00 1970 Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.remote-ip=100.103.45.18 ARC-Seal: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=none; t=1796031610; b=fY7SS7+GafSyaVtx21Yp8+ucidCOTICUX7GQXgpEQDLlq9n8OADy8uHkbHbldozQUwY9 58/0yZ+nIfknLPzonIImrPmzaUMyTWy/Zrw0iRhAvEqWqY6y9VCOJ47G/hx4YSgkGkEkF rpcu6i0DaXzsc7Lyf5h9F9SQ1OvCbAJ0OxULoxVrf5zbJeA/2o9A8qfonypZok+ROXpfX gUG3i8EHekaOFBJVctG7/+Kigy7422dpNR/YKlbXBuVjATszqOFAZSB4T0fd6aDkT+Wzt MwaqiaeqWb9EdDHit9h8jC4/jXDdvp6mg+nDLsii0nY7YdV3vfkSyYNF7dUNnW7CxCw== ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1796031610; h=Received:DKIM-Signature:From:To:Cc:Subject:Date:Message-ID:X-Mailer: In-Reply-To:References:MIME-Version:Content-Transfer-Encoding; bh=MiZyyytx2S5+YiDpYRSItrXwsGkyLh6X4AHsr13WaQU=; b=McuRcBtwD1IwhgE87H+DykNJctMvrBwBP7SiPNdY2NZuKr42KPvfUKS/sun5WD0VtPjG EUefy8pY7Kyx2T7j3NbwXqezuALHP71kde6dRobkKDBn1TZEN2ZrD9uwLGzWgZMqpaJiH cyMfc16hxeYY6GJ9nsoKBrVrqMZYyKj2rxwYxC4aPDbSekkJvTt2QK1ekfWjRIGBmtU08 l1i4nqIiDiVl1BD5mUBu9W6jSn5DNDYIJvUmk+UqbxSojxAklf/LRMU1s9yxverxJHb6S t+k+4OSDT7DZx4HYfLrYVMFOxrgKfdYp2GO6t+3XHRMgE2xTcfUYoeiJd1O+FegzjLQ== ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass header.d=kernel.org header.i=@kernel.org header.a=rsa-sha256 header.s=k20260515 header.b=nQYZe4aW; arc=none smtp.remote-ip=100.103.45.18 Received: from smtp.kernel.org (quasi.space.kernel.org [100.103.45.18]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (prime256v1)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 3FE1B606A325; Mon, 30 Nov 2026 09:40:10 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.a=rsa-sha256 header.s=k20260515 header.b=nQYZe4aW Received: by smtp.kernel.org (Postfix) with ESMTPSA id 8F7C81F00919; Mon, 30 Nov 2026 09:40:06 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=kernel.org; s=k20260515; t=1796031609; bh=MiZyyytx2S5+YiDpYRSItrXwsGkyLh6X4AHsr13WaQU=; h=From:To:Cc:Subject:Date:In-Reply-To:References; b=nQYZe4aWx+knTou2IPlZArDgnR+5Z2UkuNOdO9JQXn9GiXvlEmXpogTK/OeadyrDJ vEIlpZaRAnrkcsTUX3o4FGmtDBm/n/csJdSlLy0BUUNI4yeP/ZZl5vRvQRsST1uZLE Wed1Qs/faNdoMn65XvgPTJXe1chN/f5ZKm5Dy+XqTIXE0Ig1K1hOjWhlLYw/sHLH5W B5sIiP0+Yc9lkH4zbvPh7mmlnXGPeZ13KX4FL/yabjgTydVwMp9L6R/6hZckUhrvlS CAsGUmyo3bwXCWASOK39+fb+wQC2nA2qIqwdbS46eQOQH4kx+GxbVtfJHgbgMRgu61 AoUnUl8ygTeiA== 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 , "David S. Miller" , Eric Dumazet , Jakub Kicinski , Paolo Abeni , Alexei Starovoitov , Daniel Borkmann , John Fastabend , Stanislav Fomichev , Toshiaki Makita Subject: [PATCH net 1/3] veth: enable dev_watchdog and recover stalled peer NAPI Date: Mon, 30 Nov 2026 10:39:58 +0100 Message-ID: <20261130094000.2022376-2-hawk@kernel.org> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20261130094000.2022376-1-hawk@kernel.org> References: <20261130094000.2022376-1-hawk@kernel.org> X-Mailing-List: bpf@vger.kernel.org List-Id: List-Post: List-Help: List-Subscribe: List-Unsubscribe: List-Owner: Precedence: list MIME-Version: 1.0 Content-Transfer-Encoding: 8bit From: Jesper Dangaard Brouer Since commit dc82a33297fc ("veth: apply qdisc backpressure on full ptr_ring to reduce TX drops"), veth stops the TXQ when the peer ptr_ring is full, and only the peer veth_poll() wakes it again. If a race loses the NAPI wakeup, the TXQ stays stopped and the qdisc cannot send. We now hit such a race on ARM64: the peer rq has rx_notify_masked set while NAPI is idle, so __veth_xdp_flush() never schedules NAPI and nothing drains the ring. The patches "veth: order rx_notify_masked store before __napi_schedule()" and "veth: order rx_notify_masked store in the veth_poll() re-arm path" fix that race. Enable dev_watchdog as a failsafe, with a 5 second timeout. On timeout, if the peer NAPI is not scheduled, clear rx_notify_masked on the peer rq and call __veth_xdp_flush() to schedule NAPI. Then wake the TXQ. A TXQ wake alone does not help, because veth_xmit() hits the full ring and stops the TXQ again. If the peer NAPI is already scheduled, rx_notify_masked is correct, and the handler only wakes the TXQ. The timer runs on every veth with carrier, like on any driver with ndo_tx_timeout. Each run scans dev->num_tx_queues, which for veth is num_possible_cpus(). This watchdog is a fix in its own right, and it belongs in stable. Lost wakeups in this path keep showing up. Commit 5442a9da6978 ("veth: more robust handing of race to avoid txq getting stuck") and commit 60db47f02bfa ("veth: fix queue index used to wake the peer txq in veth_poll") each fixed one. Each of them caused a permanent TXQ stall, because veth has no ndo_tx_timeout. We found the first one with a watchdog like this one, which never went upstream. The watchdog covers the whole class on veths with a qdisc. If a race we do not know about yet loses a wakeup, the TXQ stalls for about 5 seconds instead of permanently, and the log shows the state needed to debug it. Without a qdisc the TXQ never stops, so the watchdog cannot help there. dev_watchdog() handles one timed-out queue per run, so with several stalled queues, each one waits for its own run. The log line prints the peer rq state from before the recovery, to show which lost wakeup happened. The state is the raw napi_struct state word, for diagnostics only (hinic and hns3 print it the same way): veth0: NETDEV WATCHDOG: CPU: 34: transmit queue 0 timed out 5393 ms veth0: veth backpressure stalled(n:1) TXQ(0) re-enable peer napi:1 masked:1 state:0x110 Fixes: dc82a33297fc ("veth: apply qdisc backpressure on full ptr_ring to reduce TX drops") Signed-off-by: Jesper Dangaard Brouer --- drivers/net/veth.c | 37 +++++++++++++++++++++++++++++++++++++ 1 file changed, 37 insertions(+) diff --git a/drivers/net/veth.c b/drivers/net/veth.c index faa837acea7b..819ae6141b41 100644 --- a/drivers/net/veth.c +++ b/drivers/net/veth.c @@ -1403,6 +1403,41 @@ static int veth_set_channels(struct net_device *dev, goto out; } +static void veth_tx_timeout(struct net_device *dev, unsigned int txqueue) +{ + struct netdev_queue *txq = netdev_get_tx_queue(dev, txqueue); + struct veth_priv *priv = netdev_priv(dev); + bool masked = false, napi = false; + unsigned long napi_state = 0; + struct net_device *rcv; + + rcu_read_lock(); + rcv = rcu_dereference(priv->peer); + if (rcv && txqueue < rcv->real_num_rx_queues) { + struct veth_priv *rcv_priv = netdev_priv(rcv); + struct veth_rq *rq = &rcv_priv->rq[txqueue]; + + if (rcu_access_pointer(rq->napi)) { + napi = true; + masked = READ_ONCE(rq->rx_notify_masked); + napi_state = READ_ONCE(rq->xdp_napi.state); + /* Recover lost NAPI wakeup if rx_notify_masked stuck */ + if (!(napi_state & NAPIF_STATE_SCHED)) { + WRITE_ONCE(rq->rx_notify_masked, false); + __veth_xdp_flush(rq); + } + } + } + rcu_read_unlock(); + + netdev_err(dev, + "veth backpressure stalled(n:%ld) TXQ(%u) re-enable peer napi:%d masked:%d state:%#lx\n", + atomic_long_read(&txq->trans_timeout), txqueue, + napi, masked, napi_state); + + netif_tx_wake_queue(txq); +} + static int veth_open(struct net_device *dev) { struct veth_priv *priv = netdev_priv(dev); @@ -1741,6 +1776,7 @@ static const struct net_device_ops veth_netdev_ops = { .ndo_bpf = veth_xdp, .ndo_xdp_xmit = veth_ndo_xdp_xmit, .ndo_get_peer_dev = veth_peer_dev, + .ndo_tx_timeout = veth_tx_timeout, }; static const struct xdp_metadata_ops veth_xdp_metadata_ops = { @@ -1779,6 +1815,7 @@ static void veth_setup(struct net_device *dev) dev->priv_destructor = veth_dev_free; dev->pcpu_stat_type = NETDEV_PCPU_STAT_TSTATS; dev->max_mtu = ETH_MAX_MTU; + dev->watchdog_timeo = msecs_to_jiffies(5000); dev->hw_features = VETH_FEATURES; dev->hw_enc_features = VETH_FEATURES; -- 2.43.0