[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Date: Thu, 4 Apr 2024 13:08:56 +0800
From: Feng Tang <feng.tang@...el.com>
To: "Paul E. McKenney" <paulmck@...nel.org>
CC: <linux-kernel@...r.kernel.org>, <x86@...nel.org>, Zhengxu Chen
<zhxchen17@...a.com>, Danielle Costantino <dcostantino@...a.com>, "Thomas
Gleixner" <tglx@...utronix.de>, Ingo Molnar <mingo@...hat.com>, "Borislav
Petkov" <bp@...en8.de>, Dave Hansen <dave.hansen@...ux.intel.com>, "H. Peter
Anvin" <hpa@...or.com>, Peter Zijlstra <peterz@...radead.org>, Waiman Long
<longman@...hat.com>, John Stultz <jstultz@...gle.com>, Boqun Feng
<boqun.feng@...il.com>, Neeraj Upadhyay <Neeraj.Upadhyay@....com>
Subject: Re: [PATCH RFC v2 tsc] Check for sockets instead of CPUs to make
code match comment
On Wed, Apr 03, 2024 at 12:10:41PM -0700, Paul E. McKenney wrote:
> 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 8fbbc4b45ce3 ("x86: merge tsc_init and clocksource code") and
> by the previous relevant commit 7e69f2b1ead2 ("clocksource: Remove the
> update callback").
>
> The clocksource drivers were added by commit 5d0cf410e94b ("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.
>
> Changes since v1:
>
> o Forward-port to v6.9-rc1.
>
> Reported-by: Zhengxu Chen <zhxchen17@...a.com>
> Reported-by: Danielle Costantino <dcostantino@...a.com>
> Signed-off-by: Paul E. McKenney <paulmck@...nel.org>
> Cc: Thomas Gleixner <tglx@...utronix.de>
> Cc: Ingo Molnar <mingo@...hat.com>
> Cc: Borislav Petkov <bp@...en8.de>
> Cc: Dave Hansen <dave.hansen@...ux.intel.com>
> Cc: "H. Peter Anvin" <hpa@...or.com>
> Cc: Peter Zijlstra <peterz@...radead.org>
> Cc: Feng Tang <feng.tang@...el.com>
> Cc: Waiman Long <longman@...hat.com>
> Cc: John Stultz <jstultz@...gle.com>
> Cc: Neeraj Upadhyay <Neeraj.Upadhyay@....com>
> Cc: <x86@...nel.org>
>
> diff --git a/arch/x86/kernel/tsc.c b/arch/x86/kernel/tsc.c
> index 5a69a49acc963..e938b990bea19 100644
> --- a/arch/x86/kernel/tsc.c
> +++ b/arch/x86/kernel/tsc.c
> @@ -1289,7 +1289,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 (nr_online_nodes > 1)
Regarding package/socket number, Thomas' topology refactoring patchset
(merged in 6.9-rc1) makes topology_max_packages() more accurate than
nr_online_nodes(), more details in https://lore.kernel.org/lkml/20240327025105.2861341-1-feng.tang@intel.com/
Thanks,
Feng
Powered by blists - more mailing lists