Skip to content

Commit 0958d65

Browse files
committed
Merge tag 'wq-for-7.0-rc6-fixes' of git://git.kernel.org/pub/scm/linux/kernel/git/tj/wq
Pull workqueue fix from Tejun Heo: - Fix false positive stall reports on weakly ordered architectures where the lockless worklist/timestamp check in the watchdog can observe stale values due to memory reordering. Recheck under pool->lock to confirm. * tag 'wq-for-7.0-rc6-fixes' of git://git.kernel.org/pub/scm/linux/kernel/git/tj/wq: workqueue: Better describe stall check workqueue: Fix false positive stall reports
2 parents 53d85a2 + e398978 commit 0958d65

1 file changed

Lines changed: 22 additions & 3 deletions

File tree

kernel/workqueue.c

Lines changed: 22 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -7699,8 +7699,29 @@ static void wq_watchdog_timer_fn(struct timer_list *unused)
76997699
else
77007700
ts = touched;
77017701

7702-
/* did we stall? */
7702+
/*
7703+
* Did we stall?
7704+
*
7705+
* Do a lockless check first to do not disturb the system.
7706+
*
7707+
* Prevent false positives by double checking the timestamp
7708+
* under pool->lock. The lock makes sure that the check reads
7709+
* an updated pool->last_progress_ts when this CPU saw
7710+
* an already updated pool->worklist above. It seems better
7711+
* than adding another barrier into __queue_work() which
7712+
* is a hotter path.
7713+
*/
77037714
if (time_after(now, ts + thresh)) {
7715+
scoped_guard(raw_spinlock_irqsave, &pool->lock) {
7716+
pool_ts = pool->last_progress_ts;
7717+
if (time_after(pool_ts, touched))
7718+
ts = pool_ts;
7719+
else
7720+
ts = touched;
7721+
}
7722+
if (!time_after(now, ts + thresh))
7723+
continue;
7724+
77047725
lockup_detected = true;
77057726
stall_time = jiffies_to_msecs(now - pool_ts) / 1000;
77067727
max_stall_time = max(max_stall_time, stall_time);
@@ -7712,8 +7733,6 @@ static void wq_watchdog_timer_fn(struct timer_list *unused)
77127733
pr_cont_pool_info(pool);
77137734
pr_cont(" stuck for %us!\n", stall_time);
77147735
}
7715-
7716-
77177736
}
77187737

77197738
if (lockup_detected)

0 commit comments

Comments
 (0)