mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: netdev-bot+sashiko@kernel.org
To: cmcburney@telcobridges.com
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
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	[thread overview]
Message-ID: <179506670286.3136.15475785780493881467@kernel.org> (raw)
In-Reply-To: <20261116143716.367451-2-cmcburney@telcobridges.com>

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

  reply	other threads:[~2026-11-19  5:38 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-11-16 14:37 [PATCH net 0/2] " Curtis McBurney
2026-11-16 14:37 ` [PATCH net 1/2] " Curtis McBurney
2026-11-19  5:38   ` netdev-bot+sashiko [this message]
2026-11-16 14:37 ` [PATCH net 2/2] net: net_test: add tests for netif_tx_stop_queue() trans_start Curtis McBurney
2026-11-19  5:38   ` netdev-bot+sashiko
2026-11-17  3:11 ` [PATCH net 0/2] net: keep txq->trans_start on repeated netif_tx_stop_queue() Xia Yan

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=179506670286.3136.15475785780493881467@kernel.org \
    --to=netdev-bot+sashiko@kernel.org \
    --cc=andrew+netdev@lunn.ch \
    --cc=cmcburney@telcobridges.com \
    --cc=davem@davemloft.net \
    --cc=edumazet@kernel.org \
    --cc=horms@kernel.org \
    --cc=kuba@kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=netdev@vger.kernel.org \
    --cc=pabeni@redhat.com \
    --cc=stable@vger.kernel.org \
    --cc=toke@redhat.com \
    --cc=willemb@google.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

all inboxes | Powered by JetHome®