]> www.infradead.org Git - users/dwmw2/linux.git/commitdiff
x86/smpboot: Get rid of cpu_init_secondary()
authorThomas Gleixner <tglx@linutronix.de>
Mon, 27 Mar 2023 08:05:08 +0000 (10:05 +0200)
committerDavid Woodhouse <dwmw@amazon.co.uk>
Thu, 30 Mar 2023 12:27:04 +0000 (14:27 +0200)
The synchronization of the AP with the control CPU is a SMP boot problem
and has nothing to do with cpu_init().

Open code cpu_init_secondary() in start_secondary() and move
wait_for_master_cpu() into the SMP boot code.

Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
arch/x86/include/asm/processor.h
arch/x86/kernel/cpu/common.c
arch/x86/kernel/smpboot.c

index a1e4fa58b357464a631f4028879ce28baf9a177b..d46300e94f853ae12659b9cf887b0a96444905b6 100644 (file)
@@ -551,7 +551,6 @@ extern void switch_gdt_and_percpu_base(int);
 extern void load_direct_gdt(int);
 extern void load_fixmap_gdt(int);
 extern void cpu_init(void);
-extern void cpu_init_secondary(void);
 extern void cpu_init_exception_handling(void);
 extern void cr4_init(void);
 
index 8cd4126d825391514c1a4bbb9fa09cac8c53a53c..6968784010867ef43807f91286d56db647f0d20c 100644 (file)
@@ -2122,19 +2122,6 @@ static void dbg_restore_debug_regs(void)
 #define dbg_restore_debug_regs()
 #endif /* ! CONFIG_KGDB */
 
-static void wait_for_master_cpu(int cpu)
-{
-#ifdef CONFIG_SMP
-       /*
-        * wait for ACK from master CPU before continuing
-        * with AP initialization
-        */
-       WARN_ON(cpumask_test_and_set_cpu(cpu, cpu_initialized_mask));
-       while (!cpumask_test_cpu(cpu, cpu_callout_mask))
-               cpu_relax();
-#endif
-}
-
 static inline void setup_getcpu(int cpu)
 {
        unsigned long cpudata = vdso_encode_cpunode(cpu, early_cpu_to_node(cpu));
@@ -2238,8 +2225,6 @@ void cpu_init(void)
        struct task_struct *cur = current;
        int cpu = raw_smp_processor_id();
 
-       wait_for_master_cpu(cpu);
-
        ucode_cpu_init(cpu);
 
 #ifdef CONFIG_NUMA
@@ -2292,18 +2277,6 @@ void cpu_init(void)
        load_fixmap_gdt(cpu);
 }
 
-#ifdef CONFIG_SMP
-void cpu_init_secondary(void)
-{
-       /*
-        * Relies on the BP having set-up the IDT tables, which are loaded
-        * on this CPU in cpu_init_exception_handling().
-        */
-       cpu_init_exception_handling();
-       cpu_init();
-}
-#endif
-
 #ifdef CONFIG_MICROCODE_LATE_LOADING
 /**
  * store_cpu_caps() - Store a snapshot of CPU capabilities
index ecc5a58ce17dc090908cd0df63aad7ec145bfeab..614a6c7be2141b46862beb1e6f1aada4be99292e 100644 (file)
@@ -216,6 +216,17 @@ static void smp_callin(void)
        cpumask_set_cpu(cpuid, cpu_callin_mask);
 }
 
+static void wait_for_master_cpu(int cpu)
+{
+       /*
+        * Wait for release by control CPU before continuing with AP
+        * initialization.
+        */
+       WARN_ON(cpumask_test_and_set_cpu(cpu, cpu_initialized_mask));
+       while (!cpumask_test_cpu(cpu, cpu_callout_mask))
+               cpu_relax();
+}
+
 /*
  * Activate a secondary processor.
  */
@@ -233,13 +244,16 @@ static void notrace start_secondary(void *unused)
        load_cr3(swapper_pg_dir);
        __flush_tlb_all();
 #endif
+       cpu_init_exception_handling();
+
        /*
-        * Sync point with wait_cpu_initialized(). Before proceeding through
-        * cpu_init(), the AP will call wait_for_master_cpu() which sets its
-        * own bit in cpu_initialized_mask and then waits for the BSP to set
-        * its bit in cpu_callout_mask to release it.
+        * Sync point with wait_cpu_initialized(). Sets AP in
+        * cpu_initialized_mask and then waits for the control CPU
+        * to release it.
         */
-       cpu_init_secondary();
+       wait_for_master_cpu(raw_smp_processor_id());
+
+       cpu_init();
        rcu_cpu_starting(raw_smp_processor_id());
        x86_cpuinit.early_percpu_clock_init();