]> git.dujemihanovic.xyz Git - linux.git/commit
clocksource: Set cs_watchdog_read() checks based on .uncertainty_margin
authorPaul E. McKenney <paulmck@kernel.org>
Fri, 2 Aug 2024 15:46:17 +0000 (08:46 -0700)
committerThomas Gleixner <tglx@linutronix.de>
Fri, 2 Aug 2024 16:37:13 +0000 (18:37 +0200)
commit4ac1dd3245b9067f929ab30141bb0475e9e32fc5
treeed88e578ab43ce539cd5dac73b5f81953b6d792e
parentf33a5d4bd9c2e545857b2cf7481eb721bcab867c
clocksource: Set cs_watchdog_read() checks based on .uncertainty_margin

Right now, cs_watchdog_read() does clocksource sanity checks based
on WATCHDOG_MAX_SKEW, which sets a floor on any clocksource's
.uncertainty_margin.  These sanity checks can therefore act
inappropriately for clocksources with large uncertainty margins.

One reason for a clocksource to have a large .uncertainty_margin is when
that clocksource has long read-out latency, given that it does not make
sense for the .uncertainty_margin to be smaller than the read-out latency.
With the current checks, cs_watchdog_read() could reject all normal
reads from a clocksource with long read-out latencies, such as those
from legacy clocksources that are no longer implemented in hardware.

Therefore, recast the cs_watchdog_read() checks in terms of the
.uncertainty_margin values of the clocksources involved in the timespan in
question.  The first covers two watchdog reads and one cs read, so use
twice the watchdog .uncertainty_margin plus that of the cs.  The second
covers only a pair of watchdog reads, so use twice the watchdog
.uncertainty_margin.

Reported-by: Borislav Petkov <bp@alien8.de>
Signed-off-by: Paul E. McKenney <paulmck@kernel.org>
Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
Link: https://lore.kernel.org/all/20240802154618.4149953-4-paulmck@kernel.org
kernel/time/clocksource.c