Skip to content

Commit fbc2010

Browse files
FirstLoveLifePeter Zijlstra
authored andcommitted
x86/smpboot: moves x86_topology to static initialize and truncate
The #ifdeffery and the initializers in build_sched_topology() are just disgusting. Statically initialize the domain levels in the topology array and let build_sched_topology() invalidate the package domain level when NUMA in package is available. Suggested-by: Thomas Gleixner <[email protected]> Signed-off-by: Li Chen <[email protected]> Signed-off-by: Peter Zijlstra (Intel) <[email protected]> Reviewed-by: K Prateek Nayak <[email protected]> Tested-by: K Prateek Nayak <[email protected]> Link: https://lore.kernel.org/r/[email protected]
1 parent 992de2b commit fbc2010

File tree

1 file changed

+16
-18
lines changed

1 file changed

+16
-18
lines changed

arch/x86/kernel/smpboot.c

Lines changed: 16 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -478,32 +478,30 @@ static int x86_cluster_flags(void)
478478
*/
479479
static bool x86_has_numa_in_package;
480480

481-
static struct sched_domain_topology_level x86_topology[6];
482-
483-
static void __init build_sched_topology(void)
484-
{
485-
int i = 0;
486-
487-
x86_topology[i++] = SDTL_INIT(cpu_smt_mask, cpu_smt_flags, SMT);
481+
static struct sched_domain_topology_level x86_topology[] = {
482+
SDTL_INIT(cpu_smt_mask, cpu_smt_flags, SMT),
488483
#ifdef CONFIG_SCHED_CLUSTER
489-
x86_topology[i++] = SDTL_INIT(cpu_clustergroup_mask, x86_cluster_flags, CLS);
484+
SDTL_INIT(cpu_clustergroup_mask, x86_cluster_flags, CLS),
490485
#endif
491486
#ifdef CONFIG_SCHED_MC
492-
x86_topology[i++] = SDTL_INIT(cpu_coregroup_mask, x86_core_flags, MC);
487+
SDTL_INIT(cpu_coregroup_mask, x86_core_flags, MC),
493488
#endif
494-
/*
495-
* When there is NUMA topology inside the package skip the PKG domain
496-
* since the NUMA domains will auto-magically create the right spanning
497-
* domains based on the SLIT.
498-
*/
499-
if (!x86_has_numa_in_package)
500-
x86_topology[i++] = SDTL_INIT(cpu_cpu_mask, x86_sched_itmt_flags, PKG);
489+
SDTL_INIT(cpu_cpu_mask, x86_sched_itmt_flags, PKG),
490+
{ NULL },
491+
};
501492

493+
static void __init build_sched_topology(void)
494+
{
502495
/*
503-
* There must be one trailing NULL entry left.
496+
* When there is NUMA topology inside the package invalidate the
497+
* PKG domain since the NUMA domains will auto-magically create the
498+
* right spanning domains based on the SLIT.
504499
*/
505-
BUG_ON(i >= ARRAY_SIZE(x86_topology) - 1);
500+
if (x86_has_numa_in_package) {
501+
unsigned int pkgdom = ARRAY_SIZE(x86_topology) - 2;
506502

503+
memset(&x86_topology[pkgdom], 0, sizeof(x86_topology[pkgdom]));
504+
}
507505
set_sched_topology(x86_topology);
508506
}
509507

0 commit comments

Comments
 (0)