@@ -563,50 +563,57 @@ static int x86_cluster_flags(void)
563
563
#endif
564
564
#endif
565
565
566
- static struct sched_domain_topology_level x86_numa_in_package_topology [] = {
567
- #ifdef CONFIG_SCHED_SMT
568
- { cpu_smt_mask , x86_smt_flags , SD_INIT_NAME (SMT ) },
569
- #endif
570
- #ifdef CONFIG_SCHED_CLUSTER
571
- { cpu_clustergroup_mask , x86_cluster_flags , SD_INIT_NAME (CLS ) },
572
- #endif
573
- #ifdef CONFIG_SCHED_MC
574
- { cpu_coregroup_mask , x86_core_flags , SD_INIT_NAME (MC ) },
575
- #endif
576
- { NULL , },
577
- };
566
+ /*
567
+ * Set if a package/die has multiple NUMA nodes inside.
568
+ * AMD Magny-Cours, Intel Cluster-on-Die, and Intel
569
+ * Sub-NUMA Clustering have this.
570
+ */
571
+ static bool x86_has_numa_in_package ;
578
572
579
- static struct sched_domain_topology_level x86_hybrid_topology [] = {
580
- #ifdef CONFIG_SCHED_SMT
581
- { cpu_smt_mask , x86_smt_flags , SD_INIT_NAME (SMT ) },
582
- #endif
583
- #ifdef CONFIG_SCHED_MC
584
- { cpu_coregroup_mask , x86_core_flags , SD_INIT_NAME (MC ) },
585
- #endif
586
- { cpu_cpu_mask , x86_sched_itmt_flags , SD_INIT_NAME (DIE ) },
587
- { NULL , },
588
- };
573
+ static struct sched_domain_topology_level x86_topology [6 ];
574
+
575
+ static void __init build_sched_topology (void )
576
+ {
577
+ int i = 0 ;
589
578
590
- static struct sched_domain_topology_level x86_topology [] = {
591
579
#ifdef CONFIG_SCHED_SMT
592
- { cpu_smt_mask , x86_smt_flags , SD_INIT_NAME (SMT ) },
580
+ x86_topology [i ++ ] = (struct sched_domain_topology_level ){
581
+ cpu_smt_mask , x86_smt_flags , SD_INIT_NAME (SMT )
582
+ };
593
583
#endif
594
584
#ifdef CONFIG_SCHED_CLUSTER
595
- { cpu_clustergroup_mask , x86_cluster_flags , SD_INIT_NAME (CLS ) },
585
+ /*
586
+ * For now, skip the cluster domain on Hybrid.
587
+ */
588
+ if (!cpu_feature_enabled (X86_FEATURE_HYBRID_CPU )) {
589
+ x86_topology [i ++ ] = (struct sched_domain_topology_level ){
590
+ cpu_clustergroup_mask , x86_cluster_flags , SD_INIT_NAME (CLS )
591
+ };
592
+ }
596
593
#endif
597
594
#ifdef CONFIG_SCHED_MC
598
- { cpu_coregroup_mask , x86_core_flags , SD_INIT_NAME (MC ) },
595
+ x86_topology [i ++ ] = (struct sched_domain_topology_level ){
596
+ cpu_coregroup_mask , x86_core_flags , SD_INIT_NAME (MC )
597
+ };
599
598
#endif
600
- { cpu_cpu_mask , SD_INIT_NAME (DIE ) },
601
- { NULL , },
602
- };
599
+ /*
600
+ * When there is NUMA topology inside the package skip the DIE domain
601
+ * since the NUMA domains will auto-magically create the right spanning
602
+ * domains based on the SLIT.
603
+ */
604
+ if (!x86_has_numa_in_package ) {
605
+ x86_topology [i ++ ] = (struct sched_domain_topology_level ){
606
+ cpu_cpu_mask , SD_INIT_NAME (DIE )
607
+ };
608
+ }
603
609
604
- /*
605
- * Set if a package/die has multiple NUMA nodes inside.
606
- * AMD Magny-Cours, Intel Cluster-on-Die, and Intel
607
- * Sub-NUMA Clustering have this.
608
- */
609
- static bool x86_has_numa_in_package ;
610
+ /*
611
+ * There must be one trailing NULL entry left.
612
+ */
613
+ BUG_ON (i >= ARRAY_SIZE (x86_topology )- 1 );
614
+
615
+ set_sched_topology (x86_topology );
616
+ }
610
617
611
618
void set_cpu_sibling_map (int cpu )
612
619
{
@@ -1390,15 +1397,6 @@ void __init smp_prepare_cpus_common(void)
1390
1397
zalloc_cpumask_var (& per_cpu (cpu_l2c_shared_map , i ), GFP_KERNEL );
1391
1398
}
1392
1399
1393
- /*
1394
- * Set 'default' x86 topology, this matches default_topology() in that
1395
- * it has NUMA nodes as a topology level. See also
1396
- * native_smp_cpus_done().
1397
- *
1398
- * Must be done before set_cpus_sibling_map() is ran.
1399
- */
1400
- set_sched_topology (x86_topology );
1401
-
1402
1400
set_cpu_sibling_map (0 );
1403
1401
}
1404
1402
@@ -1490,13 +1488,7 @@ void __init native_smp_cpus_done(unsigned int max_cpus)
1490
1488
pr_debug ("Boot done\n" );
1491
1489
1492
1490
calculate_max_logical_packages ();
1493
-
1494
- /* XXX for now assume numa-in-package and hybrid don't overlap */
1495
- if (x86_has_numa_in_package )
1496
- set_sched_topology (x86_numa_in_package_topology );
1497
- if (cpu_feature_enabled (X86_FEATURE_HYBRID_CPU ))
1498
- set_sched_topology (x86_hybrid_topology );
1499
-
1491
+ build_sched_topology ();
1500
1492
nmi_selftest ();
1501
1493
impress_friends ();
1502
1494
cache_aps_init ();
0 commit comments