Re: [PATCH RESEND] x86/smpboot: avoid SMT domain attach/destroy if SMT is not enabled
From: Thomas Gleixner
Date: Fri Jun 20 2025 - 09:58:31 EST
On Tue, Apr 22 2025 at 16:47, Li Chen wrote:
> Currently, the SMT domain is added into sched_domain_topology
> by default if CONFIG_SCHED_SMT is enabled.
>
> If cpu_attach_domain finds that the CPU SMT domain’s cpumask_weight
> is just 1, it will destroy_sched_domain it.
If cpu_attach_domain() ..., it will destroy it.
> On a large machine, such as one with 512 cores, this results in
> 512 redundant domain attach/destroy operations.
>
> We can avoid these unnecessary operations by simply checking
s/We can avoid/Avoid/
> cpu_smt_num_threads and not inserting SMT domain into x86_topology if SMT
the SMT domain
> is not enabled.
>
> #ifdef CONFIG_SCHED_SMT
> - x86_topology[i++] = (struct sched_domain_topology_level){
> - cpu_smt_mask, cpu_smt_flags, SD_INIT_NAME(SMT)
> - };
> + if (cpu_smt_num_threads > 1) {
> + x86_topology[i++] = (struct sched_domain_topology_level){
> + cpu_smt_mask, cpu_smt_flags, SD_INIT_NAME(SMT)
> + };
> + }
Looks about right, though I really detest this coding style. I'm not
blaming you, as you just followed the already existing bad taste...
Thanks,
tglx