Skip to content

Commit 26b41d9

Browse files
committed
x86/smpboot: moves x86_topology to static initialize and truncate
JIRA: https://issues.redhat.com/browse/RHEL-118964 commit fbc2010 Author: Li Chen <chenl311@chinatelecom.cn> Date: Thu Jul 10 18:57:09 2025 +0800 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 <tglx@linutronix.de> Signed-off-by: Li Chen <chenl311@chinatelecom.cn> Signed-off-by: Peter Zijlstra (Intel) <peterz@infradead.org> Reviewed-by: K Prateek Nayak <kprateek.nayak@amd.com> Tested-by: K Prateek Nayak <kprateek.nayak@amd.com> Link: https://lore.kernel.org/r/20250710105715.66594-4-me@linux.beauty Signed-off-by: Phil Auld <pauld@redhat.com>
1 parent e222e2c commit 26b41d9

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
@@ -504,32 +504,30 @@ static int x86_cluster_flags(void)
504504
*/
505505
static bool x86_has_numa_in_package;
506506

507-
static struct sched_domain_topology_level x86_topology[6];
508-
509-
static void __init build_sched_topology(void)
510-
{
511-
int i = 0;
512-
513-
x86_topology[i++] = SDTL_INIT(cpu_smt_mask, cpu_smt_flags, SMT);
507+
static struct sched_domain_topology_level x86_topology[] = {
508+
SDTL_INIT(cpu_smt_mask, cpu_smt_flags, SMT),
514509
#ifdef CONFIG_SCHED_CLUSTER
515-
x86_topology[i++] = SDTL_INIT(cpu_clustergroup_mask, x86_cluster_flags, CLS);
510+
SDTL_INIT(cpu_clustergroup_mask, x86_cluster_flags, CLS),
516511
#endif
517512
#ifdef CONFIG_SCHED_MC
518-
x86_topology[i++] = SDTL_INIT(cpu_coregroup_mask, x86_core_flags, MC);
513+
SDTL_INIT(cpu_coregroup_mask, x86_core_flags, MC),
519514
#endif
520-
/*
521-
* When there is NUMA topology inside the package skip the PKG domain
522-
* since the NUMA domains will auto-magically create the right spanning
523-
* domains based on the SLIT.
524-
*/
525-
if (!x86_has_numa_in_package)
526-
x86_topology[i++] = SDTL_INIT(cpu_cpu_mask, x86_sched_itmt_flags, PKG);
515+
SDTL_INIT(cpu_cpu_mask, x86_sched_itmt_flags, PKG),
516+
{ NULL },
517+
};
527518

519+
static void __init build_sched_topology(void)
520+
{
528521
/*
529-
* There must be one trailing NULL entry left.
522+
* When there is NUMA topology inside the package invalidate the
523+
* PKG domain since the NUMA domains will auto-magically create the
524+
* right spanning domains based on the SLIT.
530525
*/
531-
BUG_ON(i >= ARRAY_SIZE(x86_topology) - 1);
526+
if (x86_has_numa_in_package) {
527+
unsigned int pkgdom = ARRAY_SIZE(x86_topology) - 2;
532528

529+
memset(&x86_topology[pkgdom], 0, sizeof(x86_topology[pkgdom]));
530+
}
533531
set_sched_topology(x86_topology);
534532
}
535533

0 commit comments

Comments
 (0)