🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: linux.kernel.netdev
Article #18967

Re: [PATCH net 1/2] net: keep txq->trans_start on repeated netif_tx_stop_queue()

#18967
From: netdev-bot+sashiko
Date: Thu, 19 Nov 2026 05:38
150 lines
13734 bytes
Thank you for your contribution! Sashiko AI review found 2 potential
issue(s) to consider.

Critical: 0 · High: 0 · Medium: 1 · Low: 1

If you believe none of the issues are legitimate, please reply to each
issue of Medium severity or higher and explain why the AI is wrong.
If any of them are legitimate and you plan to respin, please let patchwork
know by including "pw-bot: cr" as a separate line at the end of your reply
(one such reply per series is enough).

- [Medium] The patch makes netif_tx_stop_queue() skip the trans_start
  write when `test_bit(__QUEUE_STATE_DRV_XOFF)` reads the bit as set,…
- [Low] The new comment in netif_tx_stop_queue()
  (include/linux/netdevice.h) says trans_start is written "only ... on…

--

net: keep txq->trans_start on repeated netif_tx_stop_queue()

With this patch, netif_tx_stop_queue() writes txq->trans_start only when
__QUEUE_STATE_DRV_XOFF is not already set. e1000, e1000e, igb and igc stop
the queue again on every periodic hang check. Since commit 95ecba62e2fd,
each of those calls moved trans_start forward, so dev_watchdog() never
fired.

> diff --git a/include/linux/netdevice.h b/include/linux/netdevice.h
> index 435be7880d7e5..6a488245db1ea 100644
> --- a/include/linux/netdevice.h
> +++ b/include/linux/netdevice.h
> @@ -3805,8 +3805,15 @@ static inline void netif_tx_wake_all_queues(struct net_device *dev)
>  
>  static __always_inline void netif_tx_stop_queue(struct netdev_queue *dev_queue)
>  {
> -	/* Paired with READ_ONCE() from dev_watchdog() */
> -	WRITE_ONCE(dev_queue->trans_start, jiffies);
> +	/* Only write trans_start on the initial state transition
> +	 * (when the DRV_XOFF bit changes from 0 to 1).
> +	 * This prevents recursive driver watchdog polls from continuously
> +	 * resetting the timeout timeline and blinding dev_watchdog().

[Severity: Low]
Is this comment accurate? The code below it calls test_bit() and then a
separate set_bit() after smp_mb__before_atomic(). Because of that, DRV_XOFF
can really go from 0 to 1 at set_bit() without any trans_start write.

That happens if netif_tx_wake_queue() clears the bit between the two:

net/core/dev.c:netif_tx_wake_queue() {
	if (test_and_clear_bit(__QUEUE_STATE_DRV_XOFF, &dev_queue->state)) {
	...
}

In that case set_bit() in netif_tx_stop_queue() makes the 0 to 1
transition, but the WRITE_ONCE() was already skipped.

The changelog describes this race. The comment, though, says the timestamp
follows every 0 to 1 transition. Readers of dev_watchdog() and
netif_xmit_timeout_ms() could take that at face value. Could the comment
mention the race?

Also, the repeated hang check stops are periodic, not recursive. Would
"repeated" be a better word than "recursive" here?

> +	 *
> +	 * Paired with READ_ONCE() from dev_watchdog()
> +	 */
> +	if (!test_bit(__QUEUE_STATE_DRV_XOFF, &dev_queue->state))
> +		WRITE_ONCE(dev_queue->trans_start, jiffies);

[Severity: Medium]
Can this leave a newly stopped queue with a stale trans_start, and lead to
a spurious "NETDEV WATCHDOG" timeout?

Take a queue that has been DRV_XOFF since T0:

CPU A                                  CPU B
netif_tx_stop_queue()
  test_bit(DRV_XOFF) == true
  (trans_start write skipped)
                                       netif_tx_wake_queue()
                                         test_and_clear_bit(DRV_XOFF)
  smp_mb__before_atomic()
  set_bit(DRV_XOFF)

The queue is now held by a new stop, but trans_start is still T0.

If nothing is transmitted between the wake and the re-stop,
txq_trans_cond_update() does not run. dev_watchdog() then sees
netif_xmit_stopped() and checks:

net/sched/sch_generic.c:dev_watchdog() {
	...
	trans_start = READ_ONCE(txq->trans_start);
	...
	if (time_after(jiffies, trans_start + dev->watchdog_timeo)) {
	...
}

This can call ndo_tx_timeout() and reset the adapter, even though the
current stop is much shorter than watchdog_timeo.

T0 can be quite old. netif_device_detach() stops all queues at suspend
time, and netif_device_attach() wakes them without refreshing trans_start:

net/core/dev.c:netif_device_attach() {
	if (!test_and_set_bit(__LINK_STATE_PRESENT, &dev->state) &&
	    netif_running(dev)) {
		netif_tx_wake_all_queues(dev);
		netdev_watchdog_up(dev);
	}
}

Suppose a stop of an already stopped queue races with this wake, for
example from a driver hang check. The queue stays stopped with a timestamp
from before the suspend, just as the watchdog is armed.

The window has no fixed limit either. Drivers call
netif_tx_stop_all_queues() from preemptible process context (ndo_stop,
reset, ring reconfiguration) without the tx lock. Preemption or an
interrupt between test_bit() and set_bit() can make the window longer.

dev_activate() does not have this problem, because transition_one_qdisc()
writes trans_start for each tx queue.

The changelog says:

    A timeout is then reported only if both stops together last longer than
    watchdog_timeo.

Does that hold only when the wake and the re-stop come back to back?
Otherwise, the interval that dev_watchdog() measures also includes the time
the queue was running.

Before this patch, every stop wrote jiffies before set_bit(), so a queue
seen as stopped always had a current timestamp. The KUnit test patch later
in the series does not change netif_tx_stop_queue(), so the window is still
there at the end of the series.

Would any of these work instead: rewriting trans_start when an atomic RMW
on DRV_XOFF shows the bit was actually clear, keeping a separate "stopped
since" timestamp, or refreshing trans_start in the wake path?

>  
>  	/* This barrier is paired with smp_mb() from dev_watchdog() */
>  	smp_mb__before_atomic();

-- 
Sashiko AI review · https://netdev-ai.bots.linux.dev/sashiko/#/patchset/20261116143716.367451-1-cmcburney%40telcobridges.com
Technical Details
Message-ID: <179506670286.3136.15475785780493881467@kernel.org>
Path: mbox-mo1.pugleaf.net!news-lax.pugleaf.net!srl.newsdeef.eu!news.mb-net.net!open-news-network.org!3.eu.feeder.erje.net!feeder.erje.net!feeder1.feed.ams11.usenet.farm!feed.usenet.farm!peer01.ams4!peer.am4.highwinds-media.com!news.highwinds-media.com!feeder.usenetexpress.com!tr3.eu1.usenetexpress.com!news.neodome.net!usenet.network!.POSTED!vger.kernel.org!netdev+bounces-366745-linux-kernel-netdev=dewy.ru
References: <20261116143716.367451-2-cmcburney@telcobridges.com>

Show Full Headers
Complete Article Headers
Path: mbox-mo1.pugleaf.net!news-lax.pugleaf.net!srl.newsdeef.eu!news.mb-net.net!open-news-network.org!3.eu.feeder.erje.net!feeder.erje.net!feeder1.feed.ams11.usenet.farm!feed.usenet.farm!peer01.ams4!peer.am4.highwinds-media.com!news.highwinds-media.com!feeder.usenetexpress.com!tr3.eu1.usenetexpress.com!news.neodome.net!usenet.network!.POSTED!vger.kernel.org!netdev+bounces-366745-linux-kernel-netdev=dewy.ru
From: netdev-bot+sashiko@kernel.org
Newsgroups: linux.kernel.netdev
Subject: Re: [PATCH net 1/2] net: keep txq->trans_start on repeated netif_tx_stop_queue()
Date: Thu, 19 Nov 2026 05:38:22 +0000
Organization: Usenet Network
Message-ID: <179506670286.3136.15475785780493881467@kernel.org>
References: <20261116143716.367451-2-cmcburney@telcobridges.com>
MIME-Version: 1.0
Content-Type: text/plain; charset="utf-8"
Content-Transfer-Encoding: 8bit
Injection-Info: usenet.network; logging-data="2797821"; mail-complaints-to="abuse@usenet.network"
Cancel-Lock: sha1:7sFlNN/BFsQuEhk0UN4tzWcYTCE= sha256:0EKyCkK3eUhww7kysgdooFIOj3AIrXKs+nEqQJpWIzs= sha1:3D4v6f0lVyp6uoch5e2RkPZYmYI= sha256:zETGUTAZrq3mj13XZBHWiypk7YZc5/Zi4K/BZTmA3Kk=
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 AE2511154F7; Thu, 19 Nov 2026 08:38:56 +0300 (MSK)
X-Virus-Scanned: Debian amavisd-new at usenet.network
X-Spam-Flag: NO
X-Spam-Score: -3.5
X-Spam-Status: No, score=-3.5 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, URIBL_BLOCKED=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 qnFwCeMQjUyl; Thu, 19 Nov 2026 08:38:53 +0300 (MSK)
X-Received-SPF: Pass (mailfrom) identity=mailfrom; client-ip=172.232.135.74; helo=sto.lore.kernel.org; envelope-from=netdev+bounces-366745-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 sto.lore.kernel.org (sto.lore.kernel.org [172.232.135.74]) by mail.dewy.ru (Postfix) with ESMTPS id EB8FD1154F4; Thu, 19 Nov 2026 08:38:44 +0300 (MSK)
X-Received: from smtp.subspace.kernel.org (conduit.subspace.kernel.org [100.77.114.92]) by sto.lore.kernel.org (Postfix) with ESMTP id 4AFAF78052E; Thu, 19 Nov 2026 05:38:44 +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=1795066705; b=JrYk8fsRbI8VQn3kl/Ll353ZuQb7Gk9N9bp/A7HzqqvbubmdgclM/oLNU0SQMa+2E2aV bA2bmvWUgYlVwDY9r1bj7QJlg3D3ENJIny1ZpQv9c2rwtMy+H+5DmvgS5vEN/tIX58sDK ZhY3+cHHhocJQvFUub10/wQOT2yQOLie1WcGocEdCB5o7J5/IIyYoxqBiwgIUwuVUZ0hU hq+AYyE7VZ+h5tFrX8AufYuJK275Qr1IA6QkxCzgaVpxGacpE+H/S4nUlSIqDgu4OCKG9 ihRYm1zhO1Ui8rI+1+Z6ESEUpe7Gn0FbwSRjIcP3Mn0FIRgKi6fekjHsBFj33ObIUvQ==
X-ARC-Message-Signature: i=2; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1795066705; h=X-Original-To:Received:Received:DKIM-Signature:Subject:From:To:Cc: Date:Message-ID:In-Reply-To:References:X-sashiko-severity: Content-Type:Content-Transfer-Encoding:X-Mailing-List:List-Id: List-Post:List-Help:List-Subscribe:List-Unsubscribe:List-Owner: Precedence:MIME-Version; bh=R25rAJ2/bRQZbcpu1wkz5IDIm8PQU+pT8fh7Bl5TT58=; b=I5ta4BWiLyqjtWk277hfAKQ5hTpu1/xofXhqAK73Z8/NoVx1ZL35KzYcVwZN8TFe2JFT a5Yk1Ase7b98Mgw4ibFYo7d2YzeFRmO4WWPGEX7GNO5VDPfNiZBi+rgCiOMBAswNpZ6Y8 kyN2NIjs3jxuif8oh+A8NB5bEBGsePW1u1M+ji88XutfOqBA8jMu9yVdQ7Qrc6HicKb7v WUEBiWtwVZKBox/RfR7/vCsAd840RkQAp7kMNxhleiWHGR7KeaiBl0d65XNRs36YaM6/B Cs0EBiufU2BMxJD6GtJSRfT8GcE3YJw+QRHBsKeVydlxCUaDpQvQsVQVlrL+Lx6t3Vw==
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="i4W2g/bn"; 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 3494B606A6DA; Thu, 19 Nov 2026 05:38:25 +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=i4W2g/bn
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=1795066704; b=lqfTHTu8/NdQj6KZLCMcGFXa5zcnrhAS8fizvfwyfP05njjyCZo2EQcJjmGj1CZXZO3K qsHye+jTvF0IsKRGtVIwOjLQmX1AD0BztMpZWGyZG9IuL2bcjV7dKJFpiJnmP++Plh7hY ECFiSdRmp0Ms6L0XXykTMalx2fE8ZESqUd3RdtLqVyoCKYCyHeoA+/AwJxhRtz/JWzxg9 pob+j07VFk+MBJb/HoodLXlqNbjf2JdZoo7oc0Uc2KeS+7EYfiY10VPeyI3ZDh4ds99TO 1cgqzwEDL0CkJcWJWa010LMRpRqixr9hLXhNrqfmeD7svZoXoDvN8cO/yF7oyU6NvWg==
X-ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1795066704; h=Received:DKIM-Signature:Subject:From:To:Cc:Date:Message-ID: In-Reply-To:References:X-sashiko-severity:Content-Type: Content-Transfer-Encoding:MIME-Version; bh=R25rAJ2/bRQZbcpu1wkz5IDIm8PQU+pT8fh7Bl5TT58=; b=1RiKUj6dVmEwgoCEUfL6QXoCFcZ6t2Q2sfoSah/mA4XPnbVh6Nw/l/nXmhgsqWnP7hjm 7erc+JCG6wR/+ReTYabmI74U/lz8AY5zxSo5S/AAiNgtGllmTKcWYSQ2zc1KpdMBfum/h OZobDT7W8SXdsBYQeaq4UBoOEUh1EJb5SfvNkdD53IwBBbVGP8PNybnXNLHsjs+9pE/mL wRBeG8UnZS9YP7HzHmU/S0U87fVySFmfjNY5tF2tto0lfRDJHRgJGhF1jBe9PMDE9mo7S lqR3vlkthbiHfNW52ajtg9NUBU+y/GGrnrRauNcyduYyQzF7PGs7V4zwJGRZz+lUsvg==
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="i4W2g/bn"; 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 54695606A32A; Thu, 19 Nov 2026 05:38:24 +0000 (UTC)
X-Received: by smtp.kernel.org (Postfix) with ESMTPSA id 5606E1F000C5; Thu, 19 Nov 2026 05:38:23 +0000 (UTC)
X-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=kernel.org; s=k20260515; t=1795066704; bh=R25rAJ2/bRQZbcpu1wkz5IDIm8PQU+pT8fh7Bl5TT58=; h=Subject:From:To:Cc:Date:In-Reply-To:References; b=i4W2g/bnjee/9TFtciHpyCgJ6WzfN3ADmdGr+DEjTUOdCKVANvuducRiqTgfRGH8n Xbb6BnmbLv/tVcDh8VnIYC4xzlHZEFt2Umrq8zu5iPdHq7FipLqy9tkEFGN53H+2Tw 7HlR0RzBebzKPdqofjlL2fQy3e91zxMW+KhXK2o2hDLTbtZqDzBs+8AGcl+ubuMPNk YgyatkydpG8g/Zn9rzvRVVhj559x+KtoxoaU5VGl7QaNBu14eNiSAxGz25TO/X7W7v Ayd9rQCWyeg38KRUDYLUlH5rZCiW20TA9zDukwFAZ2lrlsNS+yyBMEyvjFu6/bVOaw 5N769JnXrzfkw==
X-Cc: netdev@vger.kernel.org, davem@davemloft.net, edumazet@kernel.org, kuba@kernel.org, pabeni@redhat.com, horms@kernel.org, andrew+netdev@lunn.ch, willemb@google.com, toke@redhat.com, linux-kernel@vger.kernel.org, stable@vger.kernel.org
X-In-Reply-To: <20261116143716.367451-2-cmcburney@telcobridges.com>
X-sashiko-severity: Medium
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
X-Received-Bytes: 13448