Commit e7ff4ebf authored by Paul E. McKenney's avatar Paul E. McKenney Committed by Thomas Gleixner

x86/tsc: Check for sockets instead of CPUs to make code match comment

The unsynchronized_tsc() eventually checks num_possible_cpus(), and if the
system is non-Intel and the number of possible CPUs is greater than one,
assumes that TSCs are unsynchronized.  This despite the comment saying
"assume multi socket systems are not synchronized", that is, socket rather
than CPU.  This behavior was preserved by commit 8fbbc4b4 ("x86: merge
tsc_init and clocksource code") and by the previous relevant commit
7e69f2b1 ("clocksource: Remove the update callback").

The clocksource drivers were added by commit 5d0cf410 ("Time: i386
Clocksource Drivers") back in 2006, and the comment still said "socket"
rather than "CPU".

Therefore, bravely (and perhaps foolishly) make the code match the
comment.

Note that it is possible to bypass both code and comment by booting
with tsc=reliable, but this also disables the clocksource watchdog,
which is undesirable when trust in the TSC is strictly limited.
Reported-by: default avatarZhengxu Chen <zhxchen17@meta.com>
Reported-by: default avatarDanielle Costantino <dcostantino@meta.com>
Signed-off-by: default avatarPaul E. McKenney <paulmck@kernel.org>
Signed-off-by: default avatarThomas Gleixner <tglx@linutronix.de>
Link: https://lore.kernel.org/all/20240802154618.4149953-5-paulmck@kernel.org
parent 531b2ca0
......@@ -1288,7 +1288,7 @@ int unsynchronized_tsc(void)
*/
if (boot_cpu_data.x86_vendor != X86_VENDOR_INTEL) {
/* assume multi socket systems are not synchronized: */
if (num_possible_cpus() > 1)
if (topology_max_packages() > 1)
return 1;
}
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment