Skip to contentSkip to conversation

x86/smpboot: set topology CPU mask before use.

PATCH New [email protected] 1 participant 1 message Nov 21, 2017 x86

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 x86/smpboot: set topology CPU mask before use.

From: Zhang Ning <[email protected]>

we detect topology CPU mask in tsc is used before it is set, it leads to longer bootup time.

let's check the code.

smpboot.c:smp_callin()

     ---> calibarate.c:calibrate_delay()
          ---> tsc.c: calibrate_delay_is_known()
               ---> topology_core_cpumask(): read topology CPU mask
     ---> set_cpu_sibling_map(raw_smp_processor_id())
          ---> cpumask_set_cpu(cpu, topology_core_cpumask(cpu));

from the calling chain, we know topology CPU mask is used before it actually set.

So move set_cpu_sibling_map before calibrate_delay.

Change-Id I4eb8facb8751fe7aa2c6d2eac32437266d92ec00
---
 arch/x86/kernel/smpboot.c | 12 +++++++-----
 1 file changed, 7 insertions(+), 5 deletions(-)
arch/x86/kernel/smpboot.c +7 -5
index 36171bcd91f8..acee1ca3ef43 100644
@@ -181,6 +181,12 @@ static void smp_callin(void)
 	smp_store_cpu_info(cpuid);
 
 	/*
+	 * This must be done before setting cpu_online_mask
+	 * or calling notify_cpu_starting.
+	 */
+	set_cpu_sibling_map(raw_smp_processor_id());
+
+	/*
 	 * Get our bogomips.
 	 * Update loops_per_jiffy in cpu_data. Previous call to
 	 * smp_store_cpu_info() stored a value that is close but not as
@@ -190,11 +196,7 @@ static void smp_callin(void)
 	cpu_data(cpuid).loops_per_jiffy = loops_per_jiffy;
 	pr_debug("Stack at about %p\n", &cpuid);
 
-	/*
-	 * This must be done before setting cpu_online_mask
-	 * or calling notify_cpu_starting.
-	 */
-	set_cpu_sibling_map(raw_smp_processor_id());
+
 	wmb();
 
 	notify_cpu_starting(cpuid);
Signature · 1 line
2.11.0