linux-yocto/kernel/time
Guilherme G. Piccoli 106a648780 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:05:27 +01:00
..
alarmtimer.c
clockevents.c
clocksource-wdtest.c clocksource: Scale the watchdog read retries automatically 2024-08-19 05:45:45 +02:00
clocksource.c clocksource: Fix the CPUs' choice in the watchdog per CPU verification 2025-06-27 11:05:27 +01:00
hrtimer.c hrtimers: Mark is_migration_base() with __always_inline 2025-04-10 14:31:50 +02:00
itimer.c
jiffies.c
Kconfig
Makefile
namespace.c
ntp_internal.h
ntp.c ntp: Safeguard against time_constant overflow 2024-08-19 05:45:45 +02:00
posix-clock.c posix-clock: posix-clock: Fix unbalanced locking in pc_clock_settime() 2024-11-01 01:52:37 +01:00
posix-cpu-timers.c posix-cpu-timers: fix race between handle_posix_cpu_timers() and posix_cpu_timer_del() 2025-06-27 11:05:21 +01:00
posix-stubs.c
posix-timers.c posix-timers: Add cond_resched() to posix_timer_add() search loop 2025-06-04 14:37:57 +02:00
posix-timers.h
sched_clock.c seqlock/latch: Provide raw_read_seqcount_latch_retry() 2024-12-14 19:50:46 +01:00
test_udelay.c time/debug: Fix memory leak with using debugfs_lookup() 2023-03-10 09:39:51 +01:00
tick-broadcast-hrtimer.c
tick-broadcast.c tick/broadcast: Move per CPU pointer access into the atomic section 2024-08-19 05:45:44 +02:00
tick-common.c tick/nohz_full: Don't abuse smp_call_function_single() in tick_setup_device() 2024-07-05 09:14:22 +02:00
tick-internal.h
tick-legacy.c
tick-oneshot.c
tick-sched.c tick/sched: Preserve number of idle sleeps across CPU hotplug events 2024-02-23 08:54:36 +01:00
tick-sched.h tick: Detect and fix jiffies update stall 2023-08-16 18:22:04 +02:00
time_test.c time: test: Fix incorrect format specifier 2024-03-26 18:21:15 -04:00
time.c time: Fix references to _msecs_to_jiffies() handling of values 2024-12-14 19:50:45 +01:00
timeconst.bc
timeconv.c
timecounter.c
timekeeping_debug.c
timekeeping_internal.h
timekeeping.c seqlock/latch: Provide raw_read_seqcount_latch_retry() 2024-12-14 19:50:46 +01:00
timekeeping.h
timer_list.c timer_list: Don't use %pK through printk() 2025-06-04 14:37:57 +02:00
timer.c timers: Rename del_timer_sync() to timer_delete_sync() 2024-04-10 16:18:33 +02:00
vsyscall.c