Re: locking/csd-lock: Switch from sched_clock() to ktime_get_mono_fast_ns()
From: Rik van Riel
Date: Thu Oct 10 2024 - 11:14:17 EST
On Wed, 2024-10-09 at 10:57 -0700, Paul E. McKenney wrote:
> 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@xxxxxxxxxx>
> Cc: Neeraj Upadhyay <neeraj.upadhyay@xxxxxxxxxx>
> Cc: Rik van Riel <riel@xxxxxxxxxxx>
> Cc: Leonardo Bras <leobras@xxxxxxxxxx>
> Cc: Thomas Gleixner <tglx@xxxxxxxxxxxxx>
> Cc: "Peter Zijlstra (Intel)" <peterz@xxxxxxxxxxxxx>
The functional change here is that sched_clock() uses rdtsc(),
while ktime_get_mono_fast_ns() uses rdtsc_ordered().
I don't know if sched_clock() should also be using rdtsc_ordered().
Reviewed-by: Rik van Riel <riel@xxxxxxxxxxx>
--
All Rights Reversed.