All of lore.kernel.org
 help / color / mirror / Atom feed
* locking/csd-lock: Switch from sched_clock() to ktime_get_mono_fast_ns()
@ 2024-10-09 17:57 Paul E. McKenney
  2024-10-09 18:07 ` Peter Zijlstra
  2024-10-10 15:13 ` Rik van Riel
  0 siblings, 2 replies; 8+ messages in thread
From: Paul E. McKenney @ 2024-10-09 17:57 UTC (permalink / raw)
  To: linux-kernel; +Cc: neeraj.upadhyay, riel, leobras, tglx, peterz, qiyuzhu2

Currently, the CONFIG_CSD_LOCK_WAIT_DEBUG code uses sched_clock()
to check for excessive CSD-lock wait times.  This works, but does not
guarantee monotonic timestamps.  Therefore, switch from sched_clock()
to ktime_get_mono_fast_ns(), which does guarantee monotonic timestamps,
at least in the absence of calls from NMI handlers, which are not involved
in this code path.

Signed-off-by: Paul E. McKenney <paulmck@kernel.org>
Cc: Neeraj Upadhyay <neeraj.upadhyay@kernel.org>
Cc: Rik van Riel <riel@surriel.com>
Cc: Leonardo Bras <leobras@redhat.com>
Cc: Thomas Gleixner <tglx@linutronix.de>
Cc: "Peter Zijlstra (Intel)" <peterz@infradead.org>

diff --git a/kernel/smp.c b/kernel/smp.c
index f25e20617b7eb..27dc31a146a35 100644
--- a/kernel/smp.c
+++ b/kernel/smp.c
@@ -246,7 +246,7 @@ static bool csd_lock_wait_toolong(call_single_data_t *csd, u64 ts0, u64 *ts1, in
 		return true;
 	}
 
-	ts2 = sched_clock();
+	ts2 = ktime_get_mono_fast_ns();
 	/* How long since we last checked for a stuck CSD lock.*/
 	ts_delta = ts2 - *ts1;
 	if (likely(ts_delta <= csd_lock_timeout_ns * (*nmessages + 1) *
@@ -321,7 +321,7 @@ static void __csd_lock_wait(call_single_data_t *csd)
 	int bug_id = 0;
 	u64 ts0, ts1;
 
-	ts1 = ts0 = sched_clock();
+	ts1 = ts0 = ktime_get_mono_fast_ns();
 	for (;;) {
 		if (csd_lock_wait_toolong(csd, ts0, &ts1, &bug_id, &nmessages))
 			break;

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

end of thread, other threads:[~2024-10-11 17:41 UTC | newest]

Thread overview: 8+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2024-10-09 17:57 locking/csd-lock: Switch from sched_clock() to ktime_get_mono_fast_ns() Paul E. McKenney
2024-10-09 18:07 ` Peter Zijlstra
2024-10-09 18:18   ` Paul E. McKenney
2024-10-10 11:21     ` Peter Zijlstra
2024-10-10 14:13       ` Paul E. McKenney
2024-10-10 15:13 ` Rik van Riel
2024-10-10 18:31   ` Paul E. McKenney
2024-10-11 17:40     ` Paul E. McKenney

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.