@@ -471,7 +471,7 @@ static bool match_die(struct cpuinfo_x86 *c, struct cpuinfo_x86 *o)
471
471
return false;
472
472
}
473
473
474
- static struct sched_domain_topology_level numa_inside_package_topology [] = {
474
+ static struct sched_domain_topology_level x86_numa_in_package_topology [] = {
475
475
#ifdef CONFIG_SCHED_SMT
476
476
{ cpu_smt_mask , cpu_smt_flags , SD_INIT_NAME (SMT ) },
477
477
#endif
@@ -480,22 +480,23 @@ static struct sched_domain_topology_level numa_inside_package_topology[] = {
480
480
#endif
481
481
{ NULL , },
482
482
};
483
+
484
+ static struct sched_domain_topology_level x86_topology [] = {
485
+ #ifdef CONFIG_SCHED_SMT
486
+ { cpu_smt_mask , cpu_smt_flags , SD_INIT_NAME (SMT ) },
487
+ #endif
488
+ #ifdef CONFIG_SCHED_MC
489
+ { cpu_coregroup_mask , cpu_core_flags , SD_INIT_NAME (MC ) },
490
+ #endif
491
+ { cpu_cpu_mask , SD_INIT_NAME (DIE ) },
492
+ { NULL , },
493
+ };
494
+
483
495
/*
484
- * set_sched_topology() sets the topology internal to a CPU. The
485
- * NUMA topologies are layered on top of it to build the full
486
- * system topology.
487
- *
488
- * If NUMA nodes are observed to occur within a CPU package, this
489
- * function should be called. It forces the sched domain code to
490
- * only use the SMT level for the CPU portion of the topology.
491
- * This essentially falls back to relying on NUMA information
492
- * from the SRAT table to describe the entire system topology
493
- * (except for hyperthreads).
496
+ * Set if a package/die has multiple NUMA nodes inside.
497
+ * AMD Magny-Cours and Intel Cluster-on-Die have this.
494
498
*/
495
- static void primarily_use_numa_for_topology (void )
496
- {
497
- set_sched_topology (numa_inside_package_topology );
498
- }
499
+ static bool x86_has_numa_in_package ;
499
500
500
501
void set_cpu_sibling_map (int cpu )
501
502
{
@@ -558,7 +559,7 @@ void set_cpu_sibling_map(int cpu)
558
559
c -> booted_cores = cpu_data (i ).booted_cores ;
559
560
}
560
561
if (match_die (c , o ) && !topology_same_node (c , o ))
561
- primarily_use_numa_for_topology () ;
562
+ x86_has_numa_in_package = true ;
562
563
}
563
564
564
565
threads = cpumask_weight (topology_sibling_cpumask (cpu ));
@@ -1304,6 +1305,16 @@ void __init native_smp_prepare_cpus(unsigned int max_cpus)
1304
1305
zalloc_cpumask_var (& per_cpu (cpu_core_map , i ), GFP_KERNEL );
1305
1306
zalloc_cpumask_var (& per_cpu (cpu_llc_shared_map , i ), GFP_KERNEL );
1306
1307
}
1308
+
1309
+ /*
1310
+ * Set 'default' x86 topology, this matches default_topology() in that
1311
+ * it has NUMA nodes as a topology level. See also
1312
+ * native_smp_cpus_done().
1313
+ *
1314
+ * Must be done before set_cpus_sibling_map() is ran.
1315
+ */
1316
+ set_sched_topology (x86_topology );
1317
+
1307
1318
set_cpu_sibling_map (0 );
1308
1319
1309
1320
switch (smp_sanity_check (max_cpus )) {
@@ -1370,6 +1381,9 @@ void __init native_smp_cpus_done(unsigned int max_cpus)
1370
1381
{
1371
1382
pr_debug ("Boot done\n" );
1372
1383
1384
+ if (x86_has_numa_in_package )
1385
+ set_sched_topology (x86_numa_in_package_topology );
1386
+
1373
1387
nmi_selftest ();
1374
1388
impress_friends ();
1375
1389
setup_ioapic_dest ();
0 commit comments