Skip to content
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.

Commit 76ce7cf

Browse files
Pavel TatashinKAGA-KOKO
authored andcommittedNov 7, 2017
x86/smpboot: Make optimization of delay calibration work correctly
If the TSC has constant frequency then the delay calibration can be skipped when it has been calibrated for a package already. This is checked in calibrate_delay_is_known(), but that function is buggy in two aspects: It returns 'false' if (!tsc_disabled && !cpu_has(&cpu_data(cpu), X86_FEATURE_CONSTANT_TSC) which is obviously the reverse of the intended check and the check for the sibling mask cannot work either because the topology links have not been set up yet. Correct the condition and move the call to set_cpu_sibling_map() before invoking calibrate_delay() so the sibling check works correctly. [ tglx: Rewrote changelong ] Fixes: c25323c ("x86/tsc: Use topology functions") Signed-off-by: Pavel Tatashin <pasha.tatashin@oracle.com> Signed-off-by: Thomas Gleixner <tglx@linutronix.de> Cc: peterz@infradead.org Cc: bob.picco@oracle.com Cc: steven.sistare@oracle.com Cc: daniel.m.jordan@oracle.com Cc: stable@vger.kernel.org Link: https://lkml.kernel.org/r/20171028001100.26603-1-pasha.tatashin@oracle.com
1 parent e4880bc commit 76ce7cf

File tree

2 files changed

+9
-10
lines changed

2 files changed

+9
-10
lines changed
 

‎arch/x86/kernel/smpboot.c‎

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -193,6 +193,12 @@ static void smp_callin(void)
193193
*/
194194
smp_store_cpu_info(cpuid);
195195

196+
/*
197+
* The topology information must be up to date before
198+
* calibrate_delay() and notify_cpu_starting().
199+
*/
200+
set_cpu_sibling_map(raw_smp_processor_id());
201+
196202
/*
197203
* Get our bogomips.
198204
* Update loops_per_jiffy in cpu_data. Previous call to
@@ -203,11 +209,6 @@ static void smp_callin(void)
203209
cpu_data(cpuid).loops_per_jiffy = loops_per_jiffy;
204210
pr_debug("Stack at about %p\n", &cpuid);
205211

206-
/*
207-
* This must be done before setting cpu_online_mask
208-
* or calling notify_cpu_starting.
209-
*/
210-
set_cpu_sibling_map(raw_smp_processor_id());
211212
wmb();
212213

213214
notify_cpu_starting(cpuid);

‎arch/x86/kernel/tsc.c‎

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1346,12 +1346,10 @@ void __init tsc_init(void)
13461346
unsigned long calibrate_delay_is_known(void)
13471347
{
13481348
int sibling, cpu = smp_processor_id();
1349-
struct cpumask *mask = topology_core_cpumask(cpu);
1349+
int constant_tsc = cpu_has(&cpu_data(cpu), X86_FEATURE_CONSTANT_TSC);
1350+
const struct cpumask *mask = topology_core_cpumask(cpu);
13501351

1351-
if (!tsc_disabled && !cpu_has(&cpu_data(cpu), X86_FEATURE_CONSTANT_TSC))
1352-
return 0;
1353-
1354-
if (!mask)
1352+
if (tsc_disabled || !constant_tsc || !mask)
13551353
return 0;
13561354

13571355
sibling = cpumask_any_but(mask, cpu);

0 commit comments

Comments
 (0)
Failed to load comments.