lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [day] [month] [year] [list]
Message-Id: <20251021095336.65626-1-tonghao@bamaicloud.com>
Date: Tue, 21 Oct 2025 17:53:36 +0800
From: Tonghao Zhang <tonghao@...aicloud.com>
To: netdev@...r.kernel.org
Cc: Tonghao Zhang <tonghao@...aicloud.com>,
	Jamal Hadi Salim <jhs@...atatu.com>,
	Cong Wang <xiyou.wangcong@...il.com>,
	Jiri Pirko <jiri@...nulli.us>,
	"David S. Miller" <davem@...emloft.net>,
	Eric Dumazet <edumazet@...gle.com>,
	Jakub Kicinski <kuba@...nel.org>,
	Paolo Abeni <pabeni@...hat.com>,
	Simon Horman <horms@...nel.org>
Subject: [PATCH net-next] net: sched: readjust the execution conditions for dev_watchdog()

readjust the execution conditions for dev_watchdog() and reduce
the tab indentation of the code.

Cc: Jamal Hadi Salim <jhs@...atatu.com>
Cc: Cong Wang <xiyou.wangcong@...il.com>
Cc: Jiri Pirko <jiri@...nulli.us>
Cc: "David S. Miller" <davem@...emloft.net>
Cc: Eric Dumazet <edumazet@...gle.com>
Cc: Jakub Kicinski <kuba@...nel.org>
Cc: Paolo Abeni <pabeni@...hat.com>
Cc: Simon Horman <horms@...nel.org>
Signed-off-by: Tonghao Zhang <tonghao@...aicloud.com>
---
 net/sched/sch_generic.c | 82 ++++++++++++++++++++---------------------
 1 file changed, 40 insertions(+), 42 deletions(-)

diff --git a/net/sched/sch_generic.c b/net/sched/sch_generic.c
index 16afb834fe4a..1b905cc05520 100644
--- a/net/sched/sch_generic.c
+++ b/net/sched/sch_generic.c
@@ -500,51 +500,49 @@ static void dev_watchdog(struct timer_list *t)
 	bool release = true;
 
 	spin_lock(&dev->tx_global_lock);
-	if (!qdisc_tx_is_noop(dev)) {
-		if (netif_device_present(dev) &&
-		    netif_running(dev) &&
-		    netif_carrier_ok(dev)) {
-			unsigned int timedout_ms = 0;
-			unsigned int i;
-			unsigned long trans_start;
-			unsigned long oldest_start = jiffies;
-
-			for (i = 0; i < dev->num_tx_queues; i++) {
-				struct netdev_queue *txq;
-
-				txq = netdev_get_tx_queue(dev, i);
-				if (!netif_xmit_stopped(txq))
-					continue;
-
-				/* Paired with WRITE_ONCE() + smp_mb...() in
-				 * netdev_tx_sent_queue() and netif_tx_stop_queue().
-				 */
-				smp_mb();
-				trans_start = READ_ONCE(txq->trans_start);
-
-				if (time_after(jiffies, trans_start + dev->watchdog_timeo)) {
-					timedout_ms = jiffies_to_msecs(jiffies - trans_start);
-					atomic_long_inc(&txq->trans_timeout);
-					break;
-				}
-				if (time_after(oldest_start, trans_start))
-					oldest_start = trans_start;
-			}
+	if (!qdisc_tx_is_noop(dev) &&
+	    netif_device_present(dev) &&
+	    netif_running(dev) && netif_carrier_ok(dev)) {
+		unsigned int timedout_ms = 0;
+		unsigned int i;
+		unsigned long trans_start;
+		unsigned long oldest_start = jiffies;
+
+		for (i = 0; i < dev->num_tx_queues; i++) {
+			struct netdev_queue *txq;
+
+			txq = netdev_get_tx_queue(dev, i);
+			if (!netif_xmit_stopped(txq))
+				continue;
+
+			/* Paired with WRITE_ONCE() + smp_mb...() in
+			 * netdev_tx_sent_queue() and netif_tx_stop_queue().
+			 */
+			smp_mb();
+			trans_start = READ_ONCE(txq->trans_start);
 
-			if (unlikely(timedout_ms)) {
-				trace_net_dev_xmit_timeout(dev, i);
-				netdev_crit(dev, "NETDEV WATCHDOG: CPU: %d: transmit queue %u timed out %u ms\n",
-					    raw_smp_processor_id(),
-					    i, timedout_ms);
-				netif_freeze_queues(dev);
-				dev->netdev_ops->ndo_tx_timeout(dev, i);
-				netif_unfreeze_queues(dev);
+			if (time_after(jiffies, trans_start + dev->watchdog_timeo)) {
+				timedout_ms = jiffies_to_msecs(jiffies - trans_start);
+				atomic_long_inc(&txq->trans_timeout);
+				break;
 			}
-			if (!mod_timer(&dev->watchdog_timer,
-				       round_jiffies(oldest_start +
-						     dev->watchdog_timeo)))
-				release = false;
+			if (time_after(oldest_start, trans_start))
+				oldest_start = trans_start;
+		}
+
+		if (unlikely(timedout_ms)) {
+			trace_net_dev_xmit_timeout(dev, i);
+			netdev_crit(dev, "NETDEV WATCHDOG: CPU: %d: transmit queue %u timed out %u ms\n",
+				    raw_smp_processor_id(),
+				    i, timedout_ms);
+			netif_freeze_queues(dev);
+			dev->netdev_ops->ndo_tx_timeout(dev, i);
+			netif_unfreeze_queues(dev);
 		}
+		if (!mod_timer(&dev->watchdog_timer,
+			       round_jiffies(oldest_start +
+					     dev->watchdog_timeo)))
+			release = false;
 	}
 	spin_unlock(&dev->tx_global_lock);
 
-- 
2.34.1


Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ