Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux
1
fork

Configure Feed

Select the types of activity you want to include in your feed.

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

authored by

Li Chen and committed by
Peter Zijlstra
fbc2010d 992de2b0

+18 -20
+18 -20
arch/x86/kernel/smpboot.c
··· 478 478 */ 479 479 static bool x86_has_numa_in_package; 480 480 481 - static struct sched_domain_topology_level x86_topology[6]; 481 + static struct sched_domain_topology_level x86_topology[] = { 482 + SDTL_INIT(cpu_smt_mask, cpu_smt_flags, SMT), 483 + #ifdef CONFIG_SCHED_CLUSTER 484 + SDTL_INIT(cpu_clustergroup_mask, x86_cluster_flags, CLS), 485 + #endif 486 + #ifdef CONFIG_SCHED_MC 487 + SDTL_INIT(cpu_coregroup_mask, x86_core_flags, MC), 488 + #endif 489 + SDTL_INIT(cpu_cpu_mask, x86_sched_itmt_flags, PKG), 490 + { NULL }, 491 + }; 482 492 483 493 static void __init build_sched_topology(void) 484 494 { 485 - int i = 0; 486 - 487 - x86_topology[i++] = SDTL_INIT(cpu_smt_mask, cpu_smt_flags, SMT); 488 - #ifdef CONFIG_SCHED_CLUSTER 489 - x86_topology[i++] = SDTL_INIT(cpu_clustergroup_mask, x86_cluster_flags, CLS); 490 - #endif 491 - #ifdef CONFIG_SCHED_MC 492 - x86_topology[i++] = SDTL_INIT(cpu_coregroup_mask, x86_core_flags, MC); 493 - #endif 494 495 /* 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. 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. 498 499 */ 499 - if (!x86_has_numa_in_package) 500 - x86_topology[i++] = SDTL_INIT(cpu_cpu_mask, x86_sched_itmt_flags, PKG); 500 + if (x86_has_numa_in_package) { 501 + unsigned int pkgdom = ARRAY_SIZE(x86_topology) - 2; 501 502 502 - /* 503 - * There must be one trailing NULL entry left. 504 - */ 505 - BUG_ON(i >= ARRAY_SIZE(x86_topology) - 1); 506 - 503 + memset(&x86_topology[pkgdom], 0, sizeof(x86_topology[pkgdom])); 504 + } 507 505 set_sched_topology(x86_topology); 508 506 } 509 507