@@ -180,16 +180,12 @@ static void smp_callin(void)
180
180
apic_ap_setup ();
181
181
182
182
/*
183
- * Save our processor parameters. Note: this information
184
- * is needed for clock calibration.
185
- */
186
- smp_store_cpu_info (cpuid );
187
-
188
- /*
183
+ * Save our processor parameters and update topology.
184
+ * Note: this information is needed for clock calibration.
189
185
* The topology information must be up to date before
190
186
* calibrate_delay() and notify_cpu_starting().
191
187
*/
192
- set_cpu_sibling_map ( raw_smp_processor_id () );
188
+ smp_store_cpu_info ( cpuid , false );
193
189
194
190
ap_init_aperfmperf ();
195
191
@@ -244,6 +240,12 @@ static void notrace start_secondary(void *unused)
244
240
* smp_callout_mask to release them.
245
241
*/
246
242
cpu_init_secondary ();
243
+
244
+ /*
245
+ * Even though notify_cpu_starting() will do this, it does so too late
246
+ * as the AP may already have triggered lockdep splats by then. See
247
+ * commit 29368e093 ("x86/smpboot: Move rcu_cpu_starting() earlier").
248
+ */
247
249
rcu_cpu_starting (raw_smp_processor_id ());
248
250
x86_cpuinit .early_percpu_clock_init ();
249
251
@@ -352,7 +354,7 @@ EXPORT_SYMBOL(topology_phys_to_logical_die);
352
354
* @pkg: The physical package id as retrieved via CPUID
353
355
* @cpu: The cpu for which this is updated
354
356
*/
355
- int topology_update_package_map (unsigned int pkg , unsigned int cpu )
357
+ static int topology_update_package_map (unsigned int pkg , unsigned int cpu )
356
358
{
357
359
int new ;
358
360
@@ -375,7 +377,7 @@ int topology_update_package_map(unsigned int pkg, unsigned int cpu)
375
377
* @die: The die id as retrieved via CPUID
376
378
* @cpu: The cpu for which this is updated
377
379
*/
378
- int topology_update_die_map (unsigned int die , unsigned int cpu )
380
+ static int topology_update_die_map (unsigned int die , unsigned int cpu )
379
381
{
380
382
int new ;
381
383
@@ -406,25 +408,7 @@ void __init smp_store_boot_cpu_info(void)
406
408
c -> initialized = true;
407
409
}
408
410
409
- /*
410
- * The bootstrap kernel entry code has set these up. Save them for
411
- * a given CPU
412
- */
413
- void smp_store_cpu_info (int id )
414
- {
415
- struct cpuinfo_x86 * c = & cpu_data (id );
416
-
417
- /* Copy boot_cpu_data only on the first bringup */
418
- if (!c -> initialized )
419
- * c = boot_cpu_data ;
420
- c -> cpu_index = id ;
421
- /*
422
- * During boot time, CPU0 has this setup already. Save the info when
423
- * bringing up AP or offlined CPU0.
424
- */
425
- identify_secondary_cpu (c );
426
- c -> initialized = true;
427
- }
411
+ static arch_spinlock_t topology_lock = __ARCH_SPIN_LOCK_UNLOCKED ;
428
412
429
413
static bool
430
414
topology_same_node (struct cpuinfo_x86 * c , struct cpuinfo_x86 * o )
@@ -630,7 +614,7 @@ static struct sched_domain_topology_level x86_topology[] = {
630
614
*/
631
615
static bool x86_has_numa_in_package ;
632
616
633
- void set_cpu_sibling_map (int cpu )
617
+ static void set_cpu_sibling_map (int cpu )
634
618
{
635
619
bool has_smt = smp_num_siblings > 1 ;
636
620
bool has_mp = has_smt || boot_cpu_data .x86_max_cores > 1 ;
@@ -709,6 +693,37 @@ void set_cpu_sibling_map(int cpu)
709
693
}
710
694
}
711
695
696
+ /*
697
+ * The bootstrap kernel entry code has set these up. Save them for
698
+ * a given CPU
699
+ */
700
+ void smp_store_cpu_info (int id , bool force_single_core )
701
+ {
702
+ struct cpuinfo_x86 * c = & cpu_data (id );
703
+
704
+ /* Copy boot_cpu_data only on the first bringup */
705
+ if (!c -> initialized )
706
+ * c = boot_cpu_data ;
707
+ c -> cpu_index = id ;
708
+ /*
709
+ * During boot time, CPU0 has this setup already. Save the info when
710
+ * bringing up AP or offlined CPU0.
711
+ */
712
+ identify_secondary_cpu (c );
713
+
714
+ arch_spin_lock (& topology_lock );
715
+ BUG_ON (topology_update_package_map (c -> phys_proc_id , id ));
716
+ BUG_ON (topology_update_die_map (c -> cpu_die_id , id ));
717
+ c -> initialized = true;
718
+
719
+ /* For Xen PV */
720
+ if (force_single_core )
721
+ c -> x86_max_cores = 1 ;
722
+
723
+ set_cpu_sibling_map (id );
724
+ arch_spin_unlock (& topology_lock );
725
+ }
726
+
712
727
/* maps the cpu to the sched domain representing multi-core */
713
728
const struct cpumask * cpu_coregroup_mask (int cpu )
714
729
{
0 commit comments