Skip to content

Commit 33fb988

Browse files
pkannojukuba-moo
authored andcommitted
net/sched: adjust device watchdog timer to detect stopped queue at right time
Applications are sensitive to long network latency, particularly heartbeat monitoring ones. Longer the tx timeout recovery higher the risk with such applications on a production machines. This patch remedies, yet honoring device set tx timeout. Modify watchdog next timeout to be shorter than the device specified. Compute the next timeout be equal to device watchdog timeout less the how long ago queue stop had been done. At next watchdog timeout tx timeout handler is called into if still in stopped state. Either called or not called, restore the watchdog timeout back to device specified. Signed-off-by: Praveen Kumar Kannoju <[email protected]> Link: https://lore.kernel.org/r/[email protected] Signed-off-by: Jakub Kicinski <[email protected]>
1 parent 60e0f98 commit 33fb988

File tree

1 file changed

+7
-4
lines changed

1 file changed

+7
-4
lines changed

net/sched/sch_generic.c

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -506,19 +506,22 @@ static void dev_watchdog(struct timer_list *t)
506506
unsigned int timedout_ms = 0;
507507
unsigned int i;
508508
unsigned long trans_start;
509+
unsigned long oldest_start = jiffies;
509510

510511
for (i = 0; i < dev->num_tx_queues; i++) {
511512
struct netdev_queue *txq;
512513

513514
txq = netdev_get_tx_queue(dev, i);
514515
trans_start = READ_ONCE(txq->trans_start);
515-
if (netif_xmit_stopped(txq) &&
516-
time_after(jiffies, (trans_start +
517-
dev->watchdog_timeo))) {
516+
if (!netif_xmit_stopped(txq))
517+
continue;
518+
if (time_after(jiffies, trans_start + dev->watchdog_timeo)) {
518519
timedout_ms = jiffies_to_msecs(jiffies - trans_start);
519520
atomic_long_inc(&txq->trans_timeout);
520521
break;
521522
}
523+
if (time_after(oldest_start, trans_start))
524+
oldest_start = trans_start;
522525
}
523526

524527
if (unlikely(timedout_ms)) {
@@ -531,7 +534,7 @@ static void dev_watchdog(struct timer_list *t)
531534
netif_unfreeze_queues(dev);
532535
}
533536
if (!mod_timer(&dev->watchdog_timer,
534-
round_jiffies(jiffies +
537+
round_jiffies(oldest_start +
535538
dev->watchdog_timeo)))
536539
release = false;
537540
}

0 commit comments

Comments
 (0)