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 2/2] net: net_test: add tests for netif_tx_stop_queue() trans_start
Date: Thu, 19 Nov 2026 05:38:24 +0000 [thread overview]
Message-ID: <179506670414.3136.7943679597590478564@kernel.org> (raw)
In-Reply-To: <20261116143716.367451-3-cmcburney@telcobridges.com>
Thank you for your contribution! Sashiko AI review found 1 potential
issue(s) to consider.
Critical: 0 · High: 0 · Medium: 1 · Low: 0
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 patchset changes netif_tx_stop_queue()
(include/linux/netdevice.h:3814-3821) so that it decides whether to…
--
net: net_test: add tests for netif_tx_stop_queue() trans_start
This adds four KUnit cases to net/core/net_test.c. They check how
netif_tx_stop_queue() updates txq->trans_start on a running queue, a
queue already stopped by the driver, a restarted queue and a queue
stopped only by BQL. They cover the previous patch, which skips the
trans_start write when __QUEUE_STATE_DRV_XOFF is already set.
> diff --git a/net/core/net_test.c b/net/core/net_test.c
> index 2b5080c226636..c69d34d0e2306 100644
> --- a/net/core/net_test.c
> +++ b/net/core/net_test.c
[ ... ]
> +/* A stop on a queue that is already stopped keeps the first stop time, so
> + * repeated stops from a driver hang check do not postpone dev_watchdog()
> + */
> +static void txq_stop_keeps_stamp_stopped_queue(struct kunit *test)
> +{
> + struct netdev_queue *txq = txq_test_alloc(test);
> + unsigned long old, stamp;
> +
> + netif_tx_stop_queue(txq);
> + old = jiffies - TXQ_TEST_OLD_DELTA;
> + WRITE_ONCE(txq->trans_start, old);
> + netif_tx_stop_queue(txq);
> + stamp = READ_ONCE(txq->trans_start);
[Severity: Medium]
This test treats the check-then-set behaviour added to
netif_tx_stop_queue() by the previous patch as the intended contract.
Is that behaviour safe when netif_tx_wake_queue() runs at the same time?
include/linux/netdevice.h:netif_tx_stop_queue() {
if (!test_bit(__QUEUE_STATE_DRV_XOFF, &dev_queue->state))
WRITE_ONCE(dev_queue->trans_start, jiffies);
/* This barrier is paired with smp_mb() from dev_watchdog() */
smp_mb__before_atomic();
/* Must be an atomic op see netif_txq_try_stop() */
set_bit(__QUEUE_STATE_DRV_XOFF, &dev_queue->state);
}
The test_bit() and the set_bit() do not happen as one atomic step.
Suppose TX completion clears the bit locklessly between them. The
set_bit() is then a real 0->1 transition, but trans_start still holds
the stamp from the earlier stop:
CPU1 (queue stopped, trans_start == T0) CPU2
netif_tx_stop_queue()
test_bit(DRV_XOFF) == 1
(trans_start not written)
netif_tx_wake_queue()
test_and_clear_bit(DRV_XOFF)
(queue idle, no
txq_trans_update())
set_bit(DRV_XOFF)
After that, dev_watchdog() sees a stopped queue with trans_start == T0:
trans_start = READ_ONCE(txq->trans_start);
if (time_after(jiffies, trans_start + dev->watchdog_timeo)) {
Can this report a NETDEV WATCHDOG timeout and call ndo_tx_timeout()
right after the queue was stopped again? Before the previous patch, the
stamp was always written before set_bit(). So a stop could never leave
the queue stopped with an old stamp.
The previous commit says "A timeout is then reported only if both stops
together last longer than watchdog_timeo". Does that still hold when
the caller can be preempted?
For example, e1000_print_hw_hang() runs from the print_hang_task work
item. It can call netif_stop_queue() on a queue that is already
stopped:
drivers/net/ethernet/intel/e1000e/netdev.c:e1000_print_hw_hang() {
...
/* Real hang detected */
netif_stop_queue(netdev);
...
}
If it is preempted after test_bit(), the queue can be woken and then
sit idle for any length of time. That running time also counts
against watchdog_timeo.
These tests all run on a single thread, so they can't catch this
window.
> +
> + KUNIT_EXPECT_TRUE(test, netif_tx_queue_stopped(txq));
> + KUNIT_EXPECT_EQ_MSG(test, stamp, old,
> + "second stop moved trans_start forward by %lu jiffies",
> + stamp - old);
> +}
[ ... ]
--
Sashiko AI review · https://netdev-ai.bots.linux.dev/sashiko/#/patchset/20261116143716.367451-1-cmcburney%40telcobridges.com
next prev parent 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] net: keep txq->trans_start on repeated netif_tx_stop_queue() Curtis McBurney
2026-11-16 14:37 ` [PATCH net 1/2] " Curtis McBurney
2026-11-19 5:38 ` netdev-bot+sashiko
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 [this message]
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=179506670414.3136.7943679597590478564@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®