linux-yocto/kernel/time
Guilherme G. Piccoli 1c24a73897 clocksource: Fix the CPUs' choice in the watchdog per CPU verification
[ Upstream commit 08d7becc1a ]

Right now, if the clocksource watchdog detects a clocksource skew, it might
perform a per CPU check, for example in the TSC case on x86.  In other
words: supposing TSC is detected as unstable by the clocksource watchdog
running at CPU1, as part of marking TSC unstable the kernel will also run a
check of TSC readings on some CPUs to be sure it is synced between them
all.

But that check happens only on some CPUs, not all of them; this choice is
based on the parameter "verify_n_cpus" and in some random cpumask
calculation. So, the watchdog runs such per CPU checks on up to
"verify_n_cpus" random CPUs among all online CPUs, with the risk of
repeating CPUs (that aren't double checked) in the cpumask random
calculation.

But if "verify_n_cpus" > num_online_cpus(), it should skip the random
calculation and just go ahead and check the clocksource sync between
all online CPUs, without the risk of skipping some CPUs due to
duplicity in the random cpumask calculation.

Tests in a 4 CPU laptop with TSC skew detected led to some cases of the per
CPU verification skipping some CPU even with verify_n_cpus=8, due to the
duplicity on random cpumask generation. Skipping the randomization when the
number of online CPUs is smaller than verify_n_cpus, solves that.

Suggested-by: Thadeu Lima de Souza Cascardo <cascardo@igalia.com>
Signed-off-by: Guilherme G. Piccoli <gpiccoli@igalia.com>
Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
Reviewed-by: Paul E. McKenney <paulmck@kernel.org>
Link: https://lore.kernel.org/all/20250323173857.372390-1-gpiccoli@igalia.com
Signed-off-by: Sasha Levin <sashal@kernel.org>
2025-06-27 11:08:51 +01:00
..
alarmtimer.c
clockevents.c
clocksource-wdtest.c clocksource: Scale the watchdog read retries automatically 2024-08-14 13:58:56 +02:00
clocksource.c clocksource: Fix the CPUs' choice in the watchdog per CPU verification 2025-06-27 11:08:51 +01:00
hrtimer.c hrtimers: Force migrate away hrtimers queued after CPUHP_AP_HRTIMERS_DYING 2025-06-04 14:42:22 +02:00
itimer.c
jiffies.c
Kconfig
Makefile
namespace.c
ntp_internal.h
ntp.c ntp: Remove invalid cast in time offset math 2024-12-14 19:59:44 +01:00
posix-clock.c posix-clock: posix-clock: Fix unbalanced locking in pc_clock_settime() 2024-11-01 01:58:30 +01:00
posix-cpu-timers.c posix-cpu-timers: fix race between handle_posix_cpu_timers() and posix_cpu_timer_del() 2025-06-19 15:28:45 +02:00
posix-stubs.c
posix-timers.c posix-timers: Add cond_resched() to posix_timer_add() search loop 2025-06-04 14:41:59 +02:00
posix-timers.h
sched_clock.c
test_udelay.c
tick-broadcast-hrtimer.c
tick-broadcast.c
tick-common.c timekeeping: Add a lockdep override in tick_freeze() 2025-05-02 07:51:00 +02:00
tick-internal.h
tick-legacy.c
tick-oneshot.c
tick-sched.c
tick-sched.h tick: Move got_idle_tick away from common flags 2024-08-29 17:33:35 +02:00
time_test.c
time.c time: Fix references to _msecs_to_jiffies() handling of values 2024-12-09 10:31:50 +01:00
timeconst.bc
timeconv.c
timecounter.c
timekeeping_debug.c
timekeeping_internal.h
timekeeping.c timekeeping: Fix bogus clock_was_set() invocation in do_adjtimex() 2024-08-14 13:58:57 +02:00
timekeeping.h
timer_list.c timer_list: Don't use %pK through printk() 2025-06-04 14:41:59 +02:00
timer.c
vsyscall.c