Skip to content

Commit e94cd15

Browse files
KAGA-KOKOPeter Zijlstra
authored andcommitted
x86/smpboot: Get rid of cpu_init_secondary()
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. No functional change. Signed-off-by: Thomas Gleixner <[email protected]> Signed-off-by: Peter Zijlstra (Intel) <[email protected]> Tested-by: Michael Kelley <[email protected]> Tested-by: Oleksandr Natalenko <[email protected]> Tested-by: Helge Deller <[email protected]> # parisc Tested-by: Guilherme G. Piccoli <[email protected]> # Steam Deck Link: https://lore.kernel.org/r/[email protected]
1 parent 2b3be65 commit e94cd15

File tree

3 files changed

+19
-33
lines changed

3 files changed

+19
-33
lines changed

arch/x86/include/asm/processor.h

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -551,7 +551,6 @@ extern void switch_gdt_and_percpu_base(int);
551551
extern void load_direct_gdt(int);
552552
extern void load_fixmap_gdt(int);
553553
extern void cpu_init(void);
554-
extern void cpu_init_secondary(void);
555554
extern void cpu_init_exception_handling(void);
556555
extern void cr4_init(void);
557556

arch/x86/kernel/cpu/common.c

Lines changed: 0 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -2123,19 +2123,6 @@ static void dbg_restore_debug_regs(void)
21232123
#define dbg_restore_debug_regs()
21242124
#endif /* ! CONFIG_KGDB */
21252125

2126-
static void wait_for_master_cpu(int cpu)
2127-
{
2128-
#ifdef CONFIG_SMP
2129-
/*
2130-
* wait for ACK from master CPU before continuing
2131-
* with AP initialization
2132-
*/
2133-
WARN_ON(cpumask_test_and_set_cpu(cpu, cpu_initialized_mask));
2134-
while (!cpumask_test_cpu(cpu, cpu_callout_mask))
2135-
cpu_relax();
2136-
#endif
2137-
}
2138-
21392126
static inline void setup_getcpu(int cpu)
21402127
{
21412128
unsigned long cpudata = vdso_encode_cpunode(cpu, early_cpu_to_node(cpu));
@@ -2239,8 +2226,6 @@ void cpu_init(void)
22392226
struct task_struct *cur = current;
22402227
int cpu = raw_smp_processor_id();
22412228

2242-
wait_for_master_cpu(cpu);
2243-
22442229
ucode_cpu_init(cpu);
22452230

22462231
#ifdef CONFIG_NUMA
@@ -2293,18 +2278,6 @@ void cpu_init(void)
22932278
load_fixmap_gdt(cpu);
22942279
}
22952280

2296-
#ifdef CONFIG_SMP
2297-
void cpu_init_secondary(void)
2298-
{
2299-
/*
2300-
* Relies on the BP having set-up the IDT tables, which are loaded
2301-
* on this CPU in cpu_init_exception_handling().
2302-
*/
2303-
cpu_init_exception_handling();
2304-
cpu_init();
2305-
}
2306-
#endif
2307-
23082281
#ifdef CONFIG_MICROCODE_LATE_LOADING
23092282
/**
23102283
* store_cpu_caps() - Store a snapshot of CPU capabilities

arch/x86/kernel/smpboot.c

Lines changed: 19 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -220,6 +220,17 @@ static void ap_calibrate_delay(void)
220220
cpu_data(smp_processor_id()).loops_per_jiffy = loops_per_jiffy;
221221
}
222222

223+
static void wait_for_master_cpu(int cpu)
224+
{
225+
/*
226+
* Wait for release by control CPU before continuing with AP
227+
* initialization.
228+
*/
229+
WARN_ON(cpumask_test_and_set_cpu(cpu, cpu_initialized_mask));
230+
while (!cpumask_test_cpu(cpu, cpu_callout_mask))
231+
cpu_relax();
232+
}
233+
223234
/*
224235
* Activate a secondary processor.
225236
*/
@@ -237,13 +248,16 @@ static void notrace start_secondary(void *unused)
237248
load_cr3(swapper_pg_dir);
238249
__flush_tlb_all();
239250
#endif
251+
cpu_init_exception_handling();
252+
240253
/*
241-
* Sync point with wait_cpu_initialized(). Before proceeding through
242-
* cpu_init(), the AP will call wait_for_master_cpu() which sets its
243-
* own bit in cpu_initialized_mask and then waits for the BSP to set
244-
* its bit in cpu_callout_mask to release it.
254+
* Sync point with wait_cpu_initialized(). Sets AP in
255+
* cpu_initialized_mask and then waits for the control CPU
256+
* to release it.
245257
*/
246-
cpu_init_secondary();
258+
wait_for_master_cpu(raw_smp_processor_id());
259+
260+
cpu_init();
247261
rcu_cpu_starting(raw_smp_processor_id());
248262
x86_cpuinit.early_percpu_clock_init();
249263

0 commit comments

Comments
 (0)