Article View: linux.kernel.netdev
Article #18968Re: [PATCH net 2/2] net: net_test: add tests for netif_tx_stop_queue() trans_start
From: netdev-bot+sashiko
Date: Thu, 19 Nov 2026 05:38
Date: Thu, 19 Nov 2026 05:38
121 lines
12199 bytes
12199 bytes
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
Technical Details
Message-ID:
<179506670414.3136.7943679597590478564@kernel.org>Path:
mbox-mo1.pugleaf.net!news-lax.pugleaf.net!usenet.blueworldhosting.com!diablo1.usenet.blueworldhosting.com!usenet.network!.POSTED!vger.kernel.org!netdev+bounces-366746-linux-kernel-netdev=dewy.ruReferences:
<20261116143716.367451-3-cmcburney@telcobridges.com>Show Full Headers
Complete Article Headers
Path: mbox-mo1.pugleaf.net!news-lax.pugleaf.net!usenet.blueworldhosting.com!diablo1.usenet.blueworldhosting.com!usenet.network!.POSTED!vger.kernel.org!netdev+bounces-366746-linux-kernel-netdev=dewy.ru From: netdev-bot+sashiko@kernel.org Newsgroups: linux.kernel.netdev 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 Organization: Usenet Network Message-ID: <179506670414.3136.7943679597590478564@kernel.org> References: <20261116143716.367451-3-cmcburney@telcobridges.com> MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: 8bit Injection-Info: usenet.network; logging-data="2798377"; mail-complaints-to="abuse@usenet.network" Cancel-Lock: sha1:HnwskLcgQhXW1OFSYkb8CZsKu6Y= sha256:F9My9n/7QMcfVaPBj6YX+vi17I0j/4DgvgD26v20Wzc= sha1:pSwOK071ChoI0H/g4TtGCOcF7GQ= sha256:MKF70MUdAlKuD/poxnqeMP3FH7UoTY9RnQaq7/Iq+hU= 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 8EFC61154EE; Thu, 19 Nov 2026 08:40:05 +0300 (MSK) X-Virus-Scanned: Debian amavisd-new at usenet.network X-Spam-Flag: NO X-Spam-Score: -3.4 X-Spam-Status: No, score=-3.4 tagged_above=-9999 required=6.31 tests=[DCC_REPUT_70_89=0.1, 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 WfBQg9IZkkgF; Thu, 19 Nov 2026 08:40:01 +0300 (MSK) X-Received-SPF: Pass (mailfrom) identity=mailfrom; client-ip=172.234.253.10; helo=sea.lore.kernel.org; envelope-from=netdev+bounces-366746-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 sea.lore.kernel.org (sea.lore.kernel.org [172.234.253.10]) by mail.dewy.ru (Postfix) with ESMTPS id 91C331154E9; Thu, 19 Nov 2026 08:39:53 +0300 (MSK) X-Received: from smtp.subspace.kernel.org (conduit.subspace.kernel.org [100.77.114.92]) by sea.lore.kernel.org (Postfix) with ESMTP id 09EFC266B97; Thu, 19 Nov 2026 05:39:04 +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=1795066711; b=xKBUQq2uL3t2ixoboSrRmqMAnOunEyfiNxuxP0Sxe6TTrVpgHsqI0sSqkJcSxoUzGk4+ oJfvFg1Bzt4ekvr4DM4d7CGXtPC2fKrcHgqAyBLLen3vkbAFDhc08kVriinOBryLy02Hv hAY4EI3ejjS4qfTpogmzDTizFQLxDW+GHbSkgPQLoSGghcukXKvPsYAwj0zzOcN9ERTHN EK/7Qxggzy1iSqHexHwqkYblJ7rR/z3MRB4q08EdpeSc65/YnCE2S5WW/FVk2qBoVB/z4 pRjnyxrUHQ1ufCvJE3Q5w7Y27wfvbmi1m7cfsB6+nm+gU3pwtkTYy6momwQ41XHScIA== X-ARC-Message-Signature: i=2; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1795066711; 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=I6OBaNpH54Z8ktG2Qr+KnHkPf9hCrWPCQPiLHt0LY5E=; b=p1K0bt83kLKxZHbxv8gdLsloDMi9Vezrnw3k9V0L3nJvc4ZWoO/6xaOhc5zA/Xyzi/hM FklVCxqNaf4laalGSgzA0jAUotFrmAodTSdBWNF1gR9eLwKSXaCNgS3Ssp51q35wjCTc7 NYmMKZtjMOai3+bZncJaaLxWmgHIE0osrdHagwO31BR3QBo+8Yl2/93nYPZX96bEh2RZo UMEIc82MTiVZSp6ZzL/0l2s1IShNSIG7qzgepKLStS/gvlEuJKsFyM3zssp2rMj13xDo5 lJXyU72sfguqDBTJkae4fcUaExiOCWOxpwAj6Io7gt8wp+G16szq7/ur/qOcLD8QW5Q== 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=AZo3LM+H; 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 26046606B400; Thu, 19 Nov 2026 05:38:31 +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=AZo3LM+H 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=1795066705; b=eMUtahrUKd36x7K/nYzg/sU5T1lw27c5XxEzZvOj+KT/1vxdJ1Prj9UO5z99pZj+Zlpn Sv+00Q9bM25hKdcwdhAs/fngercDeDjw53Gq5SjNWqUbSABq4RH3akpVU78HSL17lC3k+ 38mMh9Zz588os2nio//ZQ0Fi3ln6YEkyk9J4pX51+4tK4VKtZGzqNrrxGhh8J0y3Oi9OF jqFeIBaBGyNpfdeLQQzCuYM4DYsg0np+xbxKyBWU1Aj+T71r4Wsi92fryL4rnrak2zyUA uug96KPpWapzrN5XUrpaEJX/0IquqdwAeS4wY8hA47BdyA+0o4N/OpcAc9UxwVfuqTw== X-ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1795066705; 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=I6OBaNpH54Z8ktG2Qr+KnHkPf9hCrWPCQPiLHt0LY5E=; b=fp1YE0oOdqq6W3jRaXPg2udVk5BrttcUoi3TH8clQTiI+t3NNhi2Y0/vfw/5HlT9V0Pq +BcL9TLoWgEWaQ2qr4Lx2zbVydBGipVObEMpdXSiGsHdo6zymTugrZnRI/tL1MTJVspB0 BSW0+fHUMm/mhaKQncFytu4GZlAy9lHw4VlC/9iH0WmaoYsnrIW6sO8jwy59hzJP17vhe 06ird9yh84hHwkBogX8WqqwW77ZeQ6+GLzAVFpt+51BfCEA13jO441F77WkWSEdRRfkRE NP8jcc++JVV2GL4dQIgp81sNaGGFGQh019WcbRGkqdGxQnB1zEkWJ8ARJrDSFW/JDjg== 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=AZo3LM+H; 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 4691B606A6DC; Thu, 19 Nov 2026 05:38:25 +0000 (UTC) X-Received: by smtp.kernel.org (Postfix) with ESMTPSA id 8956F1F000C4; Thu, 19 Nov 2026 05:38:24 +0000 (UTC) X-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=kernel.org; s=k20260515; t=1795066705; bh=I6OBaNpH54Z8ktG2Qr+KnHkPf9hCrWPCQPiLHt0LY5E=; h=Subject:From:To:Cc:Date:In-Reply-To:References; b=AZo3LM+HEufsnoEHwNocu1sUXZgqT5K95t2o5S05PlUJoiQWxERuf7H4IRhXyoEhz kr40LnZdMwkeUO4jlC6eC2D0UIDklFSmb7Y/bDqnW+B6s80i0vvxOQ+f4BZ1YxKO2A wrEUt1d/4R6dvJRoXaQ1c97IYK2HcJXOzj/fILTSSaS/u7LlGT37X3vEVJnxIPASg0 TA8FbRSNYjnGELvvaw0NUOe5oCavGM5wVXB5+nZmADgKNTQRcDdHDj0WYu55lLAkri PH24v5MJLijur/Qqw4aOaKJJXfDk129H7sTMEdFEcU8L066VwIWa6c8+hxw01if3Ho lcUXbNWlDsK3A== 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-3-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