linux-yocto/kernel/time
Guilherme G. Piccoli c28421685c 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:07:31 +01:00
..
alarmtimer.c alarmtimer: Prevent starvation by small intervals and SIG_IGN 2023-02-22 12:59:55 +01:00
clockevents.c clockevents: Use dedicated list iterator variable 2022-04-10 12:38:45 +02:00
clocksource-wdtest.c clocksource: Scale the watchdog read retries automatically 2024-08-14 13:52:57 +02:00
clocksource.c clocksource: Fix the CPUs' choice in the watchdog per CPU verification 2025-06-27 11:07:31 +01:00
hrtimer.c hrtimers: Force migrate away hrtimers queued after CPUHP_AP_HRTIMERS_DYING 2025-06-04 14:40:22 +02:00
itimer.c
jiffies.c clocksource: Make clocksource watchdog test safe for slow-HZ systems 2021-08-28 17:01:32 +02:00
Kconfig context_tracking: Take idle eqs entrypoints over RCU 2022-07-05 13:32:16 -07:00
Makefile time: Improve performance of time64_to_tm() 2021-06-24 11:51:59 +02:00
namespace.c memcg: enable accounting for new namesapces and struct nsproxy 2021-09-03 09:58:12 -07:00
ntp_internal.h
ntp.c ntp: Remove invalid cast in time offset math 2024-12-14 19:54:26 +01:00
posix-clock.c posix-clock: posix-clock: Fix unbalanced locking in pc_clock_settime() 2024-11-01 01:56:05 +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:07:24 +01:00
posix-stubs.c timers: Prevent union confusion from unexpected restart_syscall() 2023-03-10 09:33:49 +01:00
posix-timers.c posix-timers: Add cond_resched() to posix_timer_add() search loop 2025-06-04 14:40:06 +02:00
posix-timers.h
sched_clock.c seqlock/latch: Provide raw_read_seqcount_latch_retry() 2024-12-14 19:53:19 +01:00
test_udelay.c time/debug: Fix memory leak with using debugfs_lookup() 2023-03-10 09:33:52 +01:00
tick-broadcast-hrtimer.c
tick-broadcast.c tick/broadcast: Move per CPU pointer access into the atomic section 2024-08-14 13:52:56 +02:00
tick-common.c tick/nohz_full: Don't abuse smp_call_function_single() in tick_setup_device() 2024-06-21 14:35:59 +02:00
tick-internal.h clocksource: Make clocksource watchdog test safe for slow-HZ systems 2021-08-28 17:01:32 +02:00
tick-legacy.c
tick-oneshot.c
tick-sched.c tick/sched: Preserve number of idle sleeps across CPU hotplug events 2024-01-31 16:17:12 -08:00
tick-sched.h tick: Detect and fix jiffies update stall 2022-03-07 23:01:19 +01:00
time_test.c time: test: Fix incorrect format specifier 2024-03-26 18:20:29 -04:00
time.c time: Fix references to _msecs_to_jiffies() handling of values 2024-12-14 19:53:19 +01:00
timeconst.bc
timeconv.c time: Improve performance of time64_to_tm() 2021-06-24 11:51:59 +02:00
timecounter.c
timekeeping_debug.c
timekeeping_internal.h
timekeeping.c seqlock/latch: Provide raw_read_seqcount_latch_retry() 2024-12-14 19:53:19 +01:00
timekeeping.h
timer_list.c timer_list: Don't use %pK through printk() 2025-06-04 14:40:07 +02:00
timer.c timers: Rename del_timer() to timer_delete() 2024-05-17 11:56:13 +02:00
vsyscall.c