Skip to content

Commit e7ff4eb

Browse files
paulmckrcuKAGA-KOKO
authored andcommitted
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 8fbbc4b ("x86: merge tsc_init and clocksource code") and by the previous relevant commit 7e69f2b ("clocksource: Remove the update callback"). The clocksource drivers were added by commit 5d0cf41 ("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: Zhengxu Chen <[email protected]> Reported-by: Danielle Costantino <[email protected]> Signed-off-by: Paul E. McKenney <[email protected]> Signed-off-by: Thomas Gleixner <[email protected]> Link: https://lore.kernel.org/all/[email protected]
1 parent 531b2ca commit e7ff4eb

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

arch/x86/kernel/tsc.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1288,7 +1288,7 @@ int unsynchronized_tsc(void)
12881288
*/
12891289
if (boot_cpu_data.x86_vendor != X86_VENDOR_INTEL) {
12901290
/* assume multi socket systems are not synchronized: */
1291-
if (num_possible_cpus() > 1)
1291+
if (topology_max_packages() > 1)
12921292
return 1;
12931293
}
12941294

0 commit comments

Comments
 (0)