Skip to content

Commit 7126107

Browse files
KAGA-KOKOIngo Molnar
authored andcommitted
smp: Consolidate smp_prepare_boot_cpu()
There is no point in having seven architectures implementing the same empty stub. Provide a weak function in the init code and remove the stubs. This also allows to utilize the function on UP which is required to sanitize the per CPU handling on X86 UP. Signed-off-by: Thomas Gleixner <tglx@linutronix.de> Signed-off-by: Ingo Molnar <mingo@kernel.org> Link: https://lore.kernel.org/r/20240304005104.567671691@linutronix.de
1 parent 5323922 commit 7126107

File tree

11 files changed

+15
-42
lines changed

11 files changed

+15
-42
lines changed

arch/alpha/kernel/smp.c

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -467,11 +467,6 @@ smp_prepare_cpus(unsigned int max_cpus)
467467
smp_num_cpus = smp_num_probed;
468468
}
469469

470-
void
471-
smp_prepare_boot_cpu(void)
472-
{
473-
}
474-
475470
int
476471
__cpu_up(unsigned int cpu, struct task_struct *tidle)
477472
{

arch/arc/kernel/smp.c

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -39,11 +39,6 @@ struct plat_smp_ops __weak plat_smp_ops;
3939
/* XXX: per cpu ? Only needed once in early secondary boot */
4040
struct task_struct *secondary_idle_tsk;
4141

42-
/* Called from start_kernel */
43-
void __init smp_prepare_boot_cpu(void)
44-
{
45-
}
46-
4742
static int __init arc_get_cpu_map(const char *name, struct cpumask *cpumask)
4843
{
4944
unsigned long dt_root = of_get_flat_dt_root();

arch/csky/kernel/smp.c

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -152,10 +152,6 @@ void arch_irq_work_raise(void)
152152
}
153153
#endif
154154

155-
void __init smp_prepare_boot_cpu(void)
156-
{
157-
}
158-
159155
void __init smp_prepare_cpus(unsigned int max_cpus)
160156
{
161157
}

arch/hexagon/kernel/smp.c

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -114,10 +114,6 @@ void send_ipi(const struct cpumask *cpumask, enum ipi_message_type msg)
114114
local_irq_restore(flags);
115115
}
116116

117-
void __init smp_prepare_boot_cpu(void)
118-
{
119-
}
120-
121117
/*
122118
* interrupts should already be disabled from the VM
123119
* SP should already be correct; need to set THREADINFO_REG

arch/openrisc/kernel/smp.c

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -57,10 +57,6 @@ static void boot_secondary(unsigned int cpu, struct task_struct *idle)
5757
spin_unlock(&boot_lock);
5858
}
5959

60-
void __init smp_prepare_boot_cpu(void)
61-
{
62-
}
63-
6460
void __init smp_init_cpus(void)
6561
{
6662
struct device_node *cpu;

arch/riscv/kernel/smpboot.c

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -42,10 +42,6 @@
4242

4343
static DECLARE_COMPLETION(cpu_running);
4444

45-
void __init smp_prepare_boot_cpu(void)
46-
{
47-
}
48-
4945
void __init smp_prepare_cpus(unsigned int max_cpus)
5046
{
5147
int cpuid;

arch/sparc/kernel/smp_64.c

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1206,10 +1206,6 @@ void __init smp_prepare_cpus(unsigned int max_cpus)
12061206
{
12071207
}
12081208

1209-
void smp_prepare_boot_cpu(void)
1210-
{
1211-
}
1212-
12131209
void __init smp_setup_processor_id(void)
12141210
{
12151211
if (tlb_type == spitfire)

arch/x86/include/asm/smp.h

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -59,11 +59,6 @@ static inline void stop_other_cpus(void)
5959
smp_ops.stop_other_cpus(1);
6060
}
6161

62-
static inline void smp_prepare_boot_cpu(void)
63-
{
64-
smp_ops.smp_prepare_boot_cpu();
65-
}
66-
6762
static inline void smp_prepare_cpus(unsigned int max_cpus)
6863
{
6964
smp_ops.smp_prepare_cpus(max_cpus);

arch/x86/kernel/smpboot.c

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1187,6 +1187,11 @@ void __init smp_prepare_cpus_common(void)
11871187
set_cpu_sibling_map(0);
11881188
}
11891189

1190+
void __init smp_prepare_boot_cpu(void)
1191+
{
1192+
smp_ops.smp_prepare_boot_cpu();
1193+
}
1194+
11901195
#ifdef CONFIG_X86_64
11911196
/* Establish whether parallel bringup can be supported. */
11921197
bool __init arch_cpuhp_init_parallel_bringup(void)

include/linux/smp.h

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -105,6 +105,12 @@ static inline void on_each_cpu_cond(smp_cond_func_t cond_func,
105105
on_each_cpu_cond_mask(cond_func, func, info, wait, cpu_online_mask);
106106
}
107107

108+
/*
109+
* Architecture specific boot CPU setup. Defined as empty weak function in
110+
* init/main.c. Architectures can override it.
111+
*/
112+
void smp_prepare_boot_cpu(void);
113+
108114
#ifdef CONFIG_SMP
109115

110116
#include <linux/preempt.h>
@@ -171,12 +177,6 @@ void generic_smp_call_function_single_interrupt(void);
171177
#define generic_smp_call_function_interrupt \
172178
generic_smp_call_function_single_interrupt
173179

174-
/*
175-
* Mark the boot cpu "online" so that it can call console drivers in
176-
* printk() and can access its per-cpu storage.
177-
*/
178-
void smp_prepare_boot_cpu(void);
179-
180180
extern unsigned int setup_max_cpus;
181181
extern void __init setup_nr_cpu_ids(void);
182182
extern void __init smp_init(void);
@@ -203,7 +203,6 @@ static inline void up_smp_call_function(smp_call_func_t func, void *info)
203203
(up_smp_call_function(func, info))
204204

205205
static inline void smp_send_reschedule(int cpu) { }
206-
#define smp_prepare_boot_cpu() do {} while (0)
207206
#define smp_call_function_many(mask, func, info, wait) \
208207
(up_smp_call_function(func, info))
209208
static inline void call_function_init(void) { }

0 commit comments

Comments
 (0)