Skip to content

Commit ce2612b

Browse files
bostrovsPeter Zijlstra
authored andcommitted
x86/smp: Factor out parts of native_smp_prepare_cpus()
Commit 66558b7 ("sched: Add cluster scheduler level for x86") introduced cpu_l2c_shared_map mask which is expected to be initialized by smp_op.smp_prepare_cpus(). That commit only updated native_smp_prepare_cpus() version but not xen_pv_smp_prepare_cpus(). As result Xen PV guests crash in set_cpu_sibling_map(). While the new mask can be allocated in xen_pv_smp_prepare_cpus() one can see that both versions of smp_prepare_cpus ops share a number of common operations that can be factored out. So do that instead. Fixes: 66558b7 ("sched: Add cluster scheduler level for x86") Signed-off-by: Boris Ostrovsky <[email protected]> Signed-off-by: Peter Zijlstra (Intel) <[email protected]> Reviewed-by: Juergen Gross <[email protected]> Link: https://lkml.kernel.org/r/[email protected]
1 parent debe436 commit ce2612b

File tree

3 files changed

+15
-16
lines changed

3 files changed

+15
-16
lines changed

arch/x86/include/asm/smp.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -126,6 +126,7 @@ static inline void arch_send_call_function_ipi_mask(const struct cpumask *mask)
126126

127127
void cpu_disable_common(void);
128128
void native_smp_prepare_boot_cpu(void);
129+
void smp_prepare_cpus_common(void);
129130
void native_smp_prepare_cpus(unsigned int max_cpus);
130131
void calculate_max_logical_packages(void);
131132
void native_smp_cpus_done(unsigned int max_cpus);

arch/x86/kernel/smpboot.c

Lines changed: 12 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1350,12 +1350,7 @@ static void __init smp_get_logical_apicid(void)
13501350
cpu0_logical_apicid = GET_APIC_LOGICAL_ID(apic_read(APIC_LDR));
13511351
}
13521352

1353-
/*
1354-
* Prepare for SMP bootup.
1355-
* @max_cpus: configured maximum number of CPUs, It is a legacy parameter
1356-
* for common interface support.
1357-
*/
1358-
void __init native_smp_prepare_cpus(unsigned int max_cpus)
1353+
void __init smp_prepare_cpus_common(void)
13591354
{
13601355
unsigned int i;
13611356

@@ -1386,6 +1381,17 @@ void __init native_smp_prepare_cpus(unsigned int max_cpus)
13861381
set_sched_topology(x86_topology);
13871382

13881383
set_cpu_sibling_map(0);
1384+
}
1385+
1386+
/*
1387+
* Prepare for SMP bootup.
1388+
* @max_cpus: configured maximum number of CPUs, It is a legacy parameter
1389+
* for common interface support.
1390+
*/
1391+
void __init native_smp_prepare_cpus(unsigned int max_cpus)
1392+
{
1393+
smp_prepare_cpus_common();
1394+
13891395
init_freq_invariance(false, false);
13901396
smp_sanity_check();
13911397

arch/x86/xen/smp_pv.c

Lines changed: 2 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -225,7 +225,6 @@ static void __init xen_pv_smp_prepare_boot_cpu(void)
225225
static void __init xen_pv_smp_prepare_cpus(unsigned int max_cpus)
226226
{
227227
unsigned cpu;
228-
unsigned int i;
229228

230229
if (skip_ioapic_setup) {
231230
char *m = (max_cpus == 0) ?
@@ -238,16 +237,9 @@ static void __init xen_pv_smp_prepare_cpus(unsigned int max_cpus)
238237
}
239238
xen_init_lock_cpu(0);
240239

241-
smp_store_boot_cpu_info();
242-
cpu_data(0).x86_max_cores = 1;
240+
smp_prepare_cpus_common();
243241

244-
for_each_possible_cpu(i) {
245-
zalloc_cpumask_var(&per_cpu(cpu_sibling_map, i), GFP_KERNEL);
246-
zalloc_cpumask_var(&per_cpu(cpu_core_map, i), GFP_KERNEL);
247-
zalloc_cpumask_var(&per_cpu(cpu_die_map, i), GFP_KERNEL);
248-
zalloc_cpumask_var(&per_cpu(cpu_llc_shared_map, i), GFP_KERNEL);
249-
}
250-
set_cpu_sibling_map(0);
242+
cpu_data(0).x86_max_cores = 1;
251243

252244
speculative_store_bypass_ht_init();
253245

0 commit comments

Comments
 (0)