[PATCH v5 1/4] smpboot: introduce SDTL_INIT() helper to tidy sched topology setup

Peter Zijlstra peterz at infradead.org
Fri Jul 11 22:25:28 AEST 2025


On Thu, Jul 10, 2025 at 06:57:07PM +0800, Li Chen wrote:
> From: Li Chen <chenl311 at chinatelecom.cn>
> 
> 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.
> 
> Signed-off-by: Li Chen <chenl311 at chinatelecom.cn>
> Suggested-by: Thomas Gleixner <tglx at linutronix.de>
> Tested-by: K Prateek Nayak <kprateek.nayak at amd.com>
> ---
>  arch/powerpc/kernel/smp.c      | 34 +++++++++++++---------------------
>  arch/s390/kernel/topology.c    | 10 +++++-----
>  arch/x86/kernel/smpboot.c      | 21 ++++++---------------
>  include/linux/sched/topology.h |  4 ++--
>  kernel/sched/topology.c        | 24 ++++++++----------------
>  5 files changed, 34 insertions(+), 59 deletions(-)
> 
> diff --git a/arch/powerpc/kernel/smp.c b/arch/powerpc/kernel/smp.c
> index 5ac7084eebc0b..0b7ab7d2eb142 100644
> --- a/arch/powerpc/kernel/smp.c
> +++ b/arch/powerpc/kernel/smp.c
> @@ -1700,28 +1700,20 @@ static void __init build_sched_topology(void)
>  #ifdef CONFIG_SCHED_SMT
>  	if (has_big_cores) {
>  		pr_info("Big cores detected but using small core scheduling\n");
> -		powerpc_topology[i++] = (struct sched_domain_topology_level){
> -			smallcore_smt_mask, powerpc_smt_flags, SD_INIT_NAME(SMT)
> -		};
> -	} else {
> -		powerpc_topology[i++] = (struct sched_domain_topology_level){
> -			cpu_smt_mask, powerpc_smt_flags, SD_INIT_NAME(SMT)
> -		};
> -	}
> +		powerpc_topology[i++] =
> +			SDTL_INIT(smallcore_smt_mask, powerpc_smt_flags, SMT);
> +	} else
> +		powerpc_topology[i++] = SDTL_INIT(cpu_smt_mask, powerpc_smt_flags, SMT);
>  #endif
> -	if (shared_caches) {
> -		powerpc_topology[i++] = (struct sched_domain_topology_level){
> -			shared_cache_mask, powerpc_shared_cache_flags, SD_INIT_NAME(CACHE)
> -		};
> -	}
> -	if (has_coregroup_support()) {
> -		powerpc_topology[i++] = (struct sched_domain_topology_level){
> -			cpu_mc_mask, powerpc_shared_proc_flags, SD_INIT_NAME(MC)
> -		};
> -	}
> -	powerpc_topology[i++] = (struct sched_domain_topology_level){
> -		cpu_cpu_mask, powerpc_shared_proc_flags, SD_INIT_NAME(PKG)
> -	};
> +	if (shared_caches)
> +		powerpc_topology[i++] =
> +			SDTL_INIT(shared_cache_mask, powerpc_shared_cache_flags, CACHE);
> +
> +	if (has_coregroup_support())
> +		powerpc_topology[i++] =
> +			SDTL_INIT(cpu_mc_mask, powerpc_shared_proc_flags, MC);
> +
> +	powerpc_topology[i++] = SDTL_INIT(cpu_cpu_mask, powerpc_shared_proc_flags, PKG);

You wrecked coding-style here and lost a bunch of curlies. I've fixed
that up for you.


More information about the Linuxppc-dev mailing list