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.

smpboot: introduce SDTL_INIT() helper to tidy sched topology setup

Define a small SDTL_INIT(maskfn, flagsfn, name) macro and use it to build the
sched_domain_topology_level array. Purely a cleanup; behaviour is unchanged.

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-2-me@linux.beauty

authored by

Li Chen and committed by
Peter Zijlstra
e075f436 634c2406

+31 -53
+10 -15
arch/powerpc/kernel/smp.c
··· 1700 1700 #ifdef CONFIG_SCHED_SMT 1701 1701 if (has_big_cores) { 1702 1702 pr_info("Big cores detected but using small core scheduling\n"); 1703 - powerpc_topology[i++] = (struct sched_domain_topology_level){ 1704 - smallcore_smt_mask, powerpc_smt_flags, SD_INIT_NAME(SMT) 1705 - }; 1703 + powerpc_topology[i++] = 1704 + SDTL_INIT(smallcore_smt_mask, powerpc_smt_flags, SMT); 1706 1705 } else { 1707 - powerpc_topology[i++] = (struct sched_domain_topology_level){ 1708 - cpu_smt_mask, powerpc_smt_flags, SD_INIT_NAME(SMT) 1709 - }; 1706 + powerpc_topology[i++] = SDTL_INIT(cpu_smt_mask, powerpc_smt_flags, SMT); 1710 1707 } 1711 1708 #endif 1712 1709 if (shared_caches) { 1713 - powerpc_topology[i++] = (struct sched_domain_topology_level){ 1714 - shared_cache_mask, powerpc_shared_cache_flags, SD_INIT_NAME(CACHE) 1715 - }; 1710 + powerpc_topology[i++] = 1711 + SDTL_INIT(shared_cache_mask, powerpc_shared_cache_flags, CACHE); 1716 1712 } 1713 + 1717 1714 if (has_coregroup_support()) { 1718 - powerpc_topology[i++] = (struct sched_domain_topology_level){ 1719 - cpu_mc_mask, powerpc_shared_proc_flags, SD_INIT_NAME(MC) 1720 - }; 1715 + powerpc_topology[i++] = 1716 + SDTL_INIT(cpu_mc_mask, powerpc_shared_proc_flags, MC); 1721 1717 } 1722 - powerpc_topology[i++] = (struct sched_domain_topology_level){ 1723 - cpu_cpu_mask, powerpc_shared_proc_flags, SD_INIT_NAME(PKG) 1724 - }; 1718 + 1719 + powerpc_topology[i++] = SDTL_INIT(cpu_cpu_mask, powerpc_shared_proc_flags, PKG); 1725 1720 1726 1721 /* There must be one trailing NULL entry left. */ 1727 1722 BUG_ON(i >= ARRAY_SIZE(powerpc_topology) - 1);
+5 -5
arch/s390/kernel/topology.c
··· 531 531 } 532 532 533 533 static struct sched_domain_topology_level s390_topology[] = { 534 - { cpu_thread_mask, cpu_smt_flags, SD_INIT_NAME(SMT) }, 535 - { cpu_coregroup_mask, cpu_core_flags, SD_INIT_NAME(MC) }, 536 - { cpu_book_mask, SD_INIT_NAME(BOOK) }, 537 - { cpu_drawer_mask, SD_INIT_NAME(DRAWER) }, 538 - { cpu_cpu_mask, SD_INIT_NAME(PKG) }, 534 + SDTL_INIT(cpu_thread_mask, cpu_smt_flags, SMT), 535 + SDTL_INIT(cpu_coregroup_mask, cpu_core_flags, MC), 536 + SDTL_INIT(cpu_book_mask, NULL, BOOK), 537 + SDTL_INIT(cpu_drawer_mask, NULL, DRAWER), 538 + SDTL_INIT(cpu_cpu_mask, NULL, PKG), 539 539 { NULL, }, 540 540 }; 541 541
+6 -15
arch/x86/kernel/smpboot.c
··· 485 485 int i = 0; 486 486 487 487 #ifdef CONFIG_SCHED_SMT 488 - x86_topology[i++] = (struct sched_domain_topology_level){ 489 - cpu_smt_mask, cpu_smt_flags, SD_INIT_NAME(SMT) 490 - }; 488 + x86_topology[i++] = SDTL_INIT(cpu_smt_mask, cpu_smt_flags, SMT); 491 489 #endif 492 490 #ifdef CONFIG_SCHED_CLUSTER 493 - x86_topology[i++] = (struct sched_domain_topology_level){ 494 - cpu_clustergroup_mask, x86_cluster_flags, SD_INIT_NAME(CLS) 495 - }; 491 + x86_topology[i++] = SDTL_INIT(cpu_clustergroup_mask, x86_cluster_flags, CLS); 496 492 #endif 497 493 #ifdef CONFIG_SCHED_MC 498 - x86_topology[i++] = (struct sched_domain_topology_level){ 499 - cpu_coregroup_mask, x86_core_flags, SD_INIT_NAME(MC) 500 - }; 494 + x86_topology[i++] = SDTL_INIT(cpu_coregroup_mask, x86_core_flags, MC); 501 495 #endif 502 496 /* 503 497 * When there is NUMA topology inside the package skip the PKG domain 504 498 * since the NUMA domains will auto-magically create the right spanning 505 499 * domains based on the SLIT. 506 500 */ 507 - if (!x86_has_numa_in_package) { 508 - x86_topology[i++] = (struct sched_domain_topology_level){ 509 - cpu_cpu_mask, x86_sched_itmt_flags, SD_INIT_NAME(PKG) 510 - }; 511 - } 501 + if (!x86_has_numa_in_package) 502 + x86_topology[i++] = SDTL_INIT(cpu_cpu_mask, x86_sched_itmt_flags, PKG); 512 503 513 504 /* 514 505 * There must be one trailing NULL entry left. 515 506 */ 516 - BUG_ON(i >= ARRAY_SIZE(x86_topology)-1); 507 + BUG_ON(i >= ARRAY_SIZE(x86_topology) - 1); 517 508 518 509 set_sched_topology(x86_topology); 519 510 }
+2 -2
include/linux/sched/topology.h
··· 196 196 extern void __init set_sched_topology(struct sched_domain_topology_level *tl); 197 197 extern void sched_update_asym_prefer_cpu(int cpu, int old_prio, int new_prio); 198 198 199 - 200 - # define SD_INIT_NAME(type) .name = #type 199 + #define SDTL_INIT(maskfn, flagsfn, dname) ((struct sched_domain_topology_level) \ 200 + { .mask = maskfn, .sd_flags = flagsfn, .name = #dname }) 201 201 202 202 #if defined(CONFIG_ENERGY_MODEL) && defined(CONFIG_CPU_FREQ_GOV_SCHEDUTIL) 203 203 extern void rebuild_sched_domains_energy(void);
+8 -16
kernel/sched/topology.c
··· 1737 1737 */ 1738 1738 static struct sched_domain_topology_level default_topology[] = { 1739 1739 #ifdef CONFIG_SCHED_SMT 1740 - { cpu_smt_mask, cpu_smt_flags, SD_INIT_NAME(SMT) }, 1740 + SDTL_INIT(cpu_smt_mask, cpu_smt_flags, SMT), 1741 1741 #endif 1742 1742 1743 1743 #ifdef CONFIG_SCHED_CLUSTER 1744 - { cpu_clustergroup_mask, cpu_cluster_flags, SD_INIT_NAME(CLS) }, 1744 + SDTL_INIT(cpu_clustergroup_mask, cpu_cluster_flags, CLS), 1745 1745 #endif 1746 1746 1747 1747 #ifdef CONFIG_SCHED_MC 1748 - { cpu_coregroup_mask, cpu_core_flags, SD_INIT_NAME(MC) }, 1748 + SDTL_INIT(cpu_coregroup_mask, cpu_core_flags, MC), 1749 1749 #endif 1750 - { cpu_cpu_mask, SD_INIT_NAME(PKG) }, 1750 + SDTL_INIT(cpu_cpu_mask, NULL, PKG), 1751 1751 { NULL, }, 1752 1752 }; 1753 1753 ··· 2008 2008 /* 2009 2009 * Add the NUMA identity distance, aka single NODE. 2010 2010 */ 2011 - tl[i++] = (struct sched_domain_topology_level){ 2012 - .mask = sd_numa_mask, 2013 - .numa_level = 0, 2014 - SD_INIT_NAME(NODE) 2015 - }; 2011 + tl[i++] = SDTL_INIT(sd_numa_mask, NULL, NODE); 2016 2012 2017 2013 /* 2018 2014 * .. and append 'j' levels of NUMA goodness. 2019 2015 */ 2020 2016 for (j = 1; j < nr_levels; i++, j++) { 2021 - tl[i] = (struct sched_domain_topology_level){ 2022 - .mask = sd_numa_mask, 2023 - .sd_flags = cpu_numa_flags, 2024 - .flags = SDTL_OVERLAP, 2025 - .numa_level = j, 2026 - SD_INIT_NAME(NUMA) 2027 - }; 2017 + tl[i] = SDTL_INIT(sd_numa_mask, cpu_numa_flags, NUMA); 2018 + tl[i].numa_level = j; 2019 + tl[i].flags = SDTL_OVERLAP; 2028 2020 } 2029 2021 2030 2022 sched_domain_topology_saved = sched_domain_topology;