Article View: linux.kernel.netdev
Article #24535[PATCH net 1/3] veth: enable dev_watchdog and recover stalled peer NAPI
From: hawk
Date: Mon, 30 Nov 2026 09:39
Date: Mon, 30 Nov 2026 09:39
115 lines
12725 bytes
12725 bytes
From: Jesper Dangaard Brouer <hawk@kernel.org>
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 <hawk@kernel.org>
---
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
Technical Details
Message-ID:
<20261130094000.2022376-2-hawk@kernel.org>Path:
mbox-mo1.pugleaf.net!srv.newsdeef.eu!newsfeed.bofh.team!news.nntp4.net!nntp.xenet.de!news.neodome.net!usenet.network!.POSTED!vger.kernel.org!netdev+bounces-374076-linux-kernel-netdev=dewy.ruReferences:
<20261130094000.2022376-1-hawk@kernel.org>Show Full Headers
Complete Article Headers
Path: mbox-mo1.pugleaf.net!srv.newsdeef.eu!newsfeed.bofh.team!news.nntp4.net!nntp.xenet.de!news.neodome.net!usenet.network!.POSTED!vger.kernel.org!netdev+bounces-374076-linux-kernel-netdev=dewy.ru From: hawk@kernel.org Newsgroups: linux.kernel.netdev Subject: [PATCH net 1/3] veth: enable dev_watchdog and recover stalled peer NAPI Date: Mon, 30 Nov 2026 10:39:58 +0100 Organization: Usenet Network Message-ID: <20261130094000.2022376-2-hawk@kernel.org> References: <20261130094000.2022376-1-hawk@kernel.org> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Injection-Info: usenet.network; logging-data="1395157"; mail-complaints-to="abuse@usenet.network" Cancel-Lock: sha1:f0lbQvFPAvNgFmWLvp2ofUkOKt8= sha256:YgFNdu4txd1j19uKE3wScJwK8xSbIj+NhDV+SO/vVD8= sha1:uy8E1++/qeAQ/cqoKDjcNWjzYxI= sha256:iKyoH1wczbotw7kTZYLdOa09I+Y1sAb+RGm9rr7RZlM= List-ID: <netdev.vger.kernel.org> X-Mailpost-Empty-Hdrs: X-Spam-Level X-Received: from localhost (localhost [127.0.0.1]) by mail.dewy.ru (Postfix) with ESMTP id ABB81125FD5; Mon, 30 Nov 2026 12:40:26 +0300 (MSK) X-Virus-Scanned: Debian amavisd-new at usenet.network X-Spam-Flag: NO X-Spam-Score: -3.501 X-Spam-Status: No, score=-3.501 tagged_above=-9999 required=6.31 tests=[DKIMWL_WL_HIGH=-0.001, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, MAILING_LIST_MULTI=-1, RCVD_IN_DNSWL_MED=-2.3, SPF_HELO_NONE=0.001, SPF_PASS=-0.001] autolearn=ham autolearn_force=no X-Authentication-Results: mail.dewy.ru (amavisd-new); dkim=pass (2048-bit key) header.d=kernel.org X-Received: from mail.dewy.ru ([127.0.0.1]) by localhost (mail.dewy.ru [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id SiTTYaA4oOF6; Mon, 30 Nov 2026 12:40:23 +0300 (MSK) X-Received-SPF: Pass (mailfrom) identity=mailfrom; client-ip=172.105.105.114; helo=tor.lore.kernel.org; envelope-from=netdev+bounces-374076-linux-kernel-netdev=dewy.ru@vger.kernel.org; receiver=<UNKNOWN> X-Authentication-Results: OpenDMARC; dmarc=pass (p=quarantine dis=none) header.from=kernel.org X-Received: from tor.lore.kernel.org (tor.lore.kernel.org [172.105.105.114]) by mail.dewy.ru (Postfix) with ESMTPS id 2512C125FD2; Mon, 30 Nov 2026 12:40:14 +0300 (MSK) X-Received: from smtp.subspace.kernel.org (conduit.subspace.kernel.org [100.77.114.92]) by tor.lore.kernel.org (Postfix) with ESMTP id 477E422CA8; Mon, 30 Nov 2026 09:40:12 +0000 (UTC) X-Authentication-Results: smtp.subspace.kernel.org; arc=pass header.oldest-pass=0 smtp.remote-ip=127.0.0.1 X-ARC-Seal: i=2; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=pass; t=1796031611; b=K2jF0eJ9T/0dBjGtWAXLIV5uGa4cvLZXSt4IbFDjh+qTAimL6Clb2eaOJM9YBwt6C6wb ftIqAFzB7aQwqT8EOvKOJmJ4lRBIszzRomCahPOEMzOjEVs7gHEuOHlMYjAyXspNgxVcX YCamMVPlUa1WlRUYGTiWmfGyDE/VEEO2zTMeFP+ZmGYv+cTP7J9SLjs/QSo9q3fZsTPd0 M4IGlVL5KpWCdhARnKliyXZnyaXj17gfQ2ca2EdxPwwhWwNUix9YaEp9ScJYB5hfac5Fp 15dhaL8ri0RGUiW7NAUGZU8B8sevtPexIXLYGLRu76d/6wbKaBY42m52YvighQzudYQ== X-ARC-Message-Signature: i=2; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1796031611; h=X-Original-To:Received:Received:DKIM-Signature:From:To:Cc:Subject: Date:Message-ID:X-Mailer:In-Reply-To:References:X-Mailing-List: List-Id:List-Post:List-Help:List-Subscribe:List-Unsubscribe: List-Owner:Precedence:MIME-Version:Content-Transfer-Encoding; bh=MiZyyytx2S5+YiDpYRSItrXwsGkyLh6X4AHsr13WaQU=; b=Umd72TzTedRGrgBeTloF2Q98ZizNmv4b4kfu85h69Tis1H2/lZxodRVYBrmXk+yHQS0J OgEFj4upVMY3U5jfYga8XCWE837i8tjiuo6QAIPOtjNU147UFjMLSTQEvgUoKtQ6lFsf2 heTgJkRkVpK0TB6djNuj//+wFujnMsQ1EEM8H0+beVlgPf4ivtXlhdBeBjBRTbablGPWn o+FAckNER/s2kdTW63eccEZWPjkirV9SFZabbn0g+5WW4wZls1KghFqxBCuiVIhIo23bf vQMd4YLB6PWEkGA1uffi6+pE6/NAkjJEYEZ1hlktfmCAa2jfsfilI2xOhE3ZhQUXhTA== X-ARC-Authentication-Results: i=2; 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=pass header.oldest-pass=0 smtp.remote-ip=127.0.0.1 X-Received: from localhost.localdomain (localhost [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 1D88B606A337; Mon, 30 Nov 2026 09:40:11 +0000 (UTC) X-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 X-Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.remote-ip=100.103.45.18 X-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== X-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== X-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 X-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) X-Received: by smtp.kernel.org (Postfix) with ESMTPSA id 8F7C81F00919; Mon, 30 Nov 2026 09:40:06 +0000 (UTC) X-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== X-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 <andrew+netdev@lunn.ch>, "David S. Miller" <davem@davemloft.net>, Eric Dumazet <edumazet@kernel.org>, Jakub Kicinski <kuba@kernel.org>, Paolo Abeni <pabeni@redhat.com>, Alexei Starovoitov <ast@kernel.org>, Daniel Borkmann <daniel@iogearbox.net>, John Fastabend <john.fastabend@gmail.com>, Stanislav Fomichev <sdf@fomichev.me>, Toshiaki Makita <toshiaki.makita1@gmail.com> X-Mailer: git-send-email 2.43.0 X-In-Reply-To: <20261130094000.2022376-1-hawk@kernel.org> X-Mailing-List: netdev@vger.kernel.org X-List-Post: <mailto:netdev@vger.kernel.org> X-List-Help: <mailto:netdev+help@vger.kernel.org> X-List-Subscribe: <mailto:netdev+subscribe@vger.kernel.org> X-List-Unsubscribe: <mailto:netdev+unsubscribe@vger.kernel.org> X-List-Owner: <mailto:netdev+owner@vger.kernel.org> X-Precedence: list