Skip to content

Commit 9fbaa44

Browse files
rikvanrielNeeraj Upadhyay
authored andcommitted
smp: print only local CPU info when sched_clock goes backward
About 40% of all csd_lock warnings observed in our fleet appear to be due to sched_clock() going backward in time (usually only a little bit), resulting in ts0 being larger than ts2. When the local CPU is at fault, we should print out a message reflecting that, rather than trying to get the remote CPU's stack trace. Signed-off-by: Rik van Riel <[email protected]> Tested-by: "Paul E. McKenney" <[email protected]> Signed-off-by: Neeraj Upadhyay <[email protected]>
1 parent d40760d commit 9fbaa44

File tree

1 file changed

+8
-0
lines changed

1 file changed

+8
-0
lines changed

kernel/smp.c

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -254,6 +254,14 @@ static bool csd_lock_wait_toolong(call_single_data_t *csd, u64 ts0, u64 *ts1, in
254254
csd_lock_timeout_ns == 0))
255255
return false;
256256

257+
if (ts0 > ts2) {
258+
/* Our own sched_clock went backward; don't blame another CPU. */
259+
ts_delta = ts0 - ts2;
260+
pr_alert("sched_clock on CPU %d went backward by %llu ns\n", raw_smp_processor_id(), ts_delta);
261+
*ts1 = ts2;
262+
return false;
263+
}
264+
257265
firsttime = !*bug_id;
258266
if (firsttime)
259267
*bug_id = atomic_inc_return(&csd_bug_count);

0 commit comments

Comments
 (0)