Skip to contentSkip to conversation

net: sched: readjust the execution conditions for dev_watchdog()

PATCH In review Tonghao Zhang 2 participants 2 messages Oct 21, 2025 – Oct 23, 2025

Subsystems (3)
lore
Share & tools
lore
#0 lore raw

PATCH 1/1 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 <[email protected]>
Cc Cong Wang <[email protected]>
Cc Jiri Pirko <[email protected]>
Cc "David S. Miller" <[email protected]>
Cc Eric Dumazet <[email protected]>
Cc Jakub Kicinski <[email protected]>
Cc Paolo Abeni <[email protected]>
Cc Simon Horman <[email protected]>
---
 net/sched/sch_generic.c | 82 ++++++++++++++++++++---------------------
 1 file changed, 40 insertions(+), 42 deletions(-)
net/sched/sch_generic.c +40 -42
index 16afb834fe4a..1b905cc05520 100644
@@ -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);
 
Signature · 1 line
2.34.1
maintainer
#1 lore raw
Quoted 12 lines · Tonghao Zhang

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

Cc Jamal Hadi Salim <[email protected]>
Cc Cong Wang <[email protected]>
Cc Jiri Pirko <[email protected]>
Cc "David S. Miller" <[email protected]>
Cc Eric Dumazet <[email protected]>
Cc Jakub Kicinski <[email protected]>
Cc Paolo Abeni <[email protected]>
Cc Simon Horman <[email protected]>

This kind of changes with large diffstat to just move around whitespaces are justified only within the scope of larger functional refactor and/or new features.

/P