public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
* [PATCH] smp: print only local CPU info when sched_clock goes  backward
@ 2024-07-15 17:49 Rik van Riel
  2024-07-15 18:07 ` Paul E. McKenney
  2024-07-16  9:04 ` Peter Zijlstra
  0 siblings, 2 replies; 6+ messages in thread
From: Rik van Riel @ 2024-07-15 17:49 UTC (permalink / raw)
  To: Paul E. McKenney
  Cc: Peter Zijlstra (Intel), linux-kernel, kernel-team,
	neeraj.upadhyay, mingo, peterz, rostedt, Leonardo Bras

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 <riel@surriel.com>
---
 kernel/smp.c | 8 ++++++++
 1 file changed, 8 insertions(+)

diff --git a/kernel/smp.c b/kernel/smp.c
index f085ebcdf9e7..5656ef63ea82 100644
--- a/kernel/smp.c
+++ b/kernel/smp.c
@@ -237,6 +237,14 @@ static bool csd_lock_wait_toolong(call_single_data_t *csd, u64 ts0, u64 *ts1, in
 	if (likely(ts_delta <= csd_lock_timeout_ns || csd_lock_timeout_ns == 0))
 		return false;
 
+	if (ts0 > ts2) {
+		/* Our own sched_clock went backward; don't blame another CPU. */
+		ts_delta = ts0 - ts2;
+		pr_alert("sched_clock on CPU %d went backward by %llu ns\n", raw_smp_processor_id(), ts_delta);
+		*ts1 = ts2;
+		return false;
+	}
+
 	firsttime = !*bug_id;
 	if (firsttime)
 		*bug_id = atomic_inc_return(&csd_bug_count);
-- 
2.45.2


^ permalink raw reply related	[flat|nested] 6+ messages in thread

end of thread, other threads:[~2024-07-24 17:19 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2024-07-15 17:49 [PATCH] smp: print only local CPU info when sched_clock goes backward Rik van Riel
2024-07-15 18:07 ` Paul E. McKenney
2024-07-24 17:19   ` Neeraj Upadhyay
2024-07-16  9:04 ` Peter Zijlstra
2024-07-16 13:10   ` Rik van Riel
2024-07-16 13:47   ` Paul E. McKenney

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox