Re: [PATCH RESEND] x86/smpboot: avoid SMT domain attach/destroy if SMT is not enabled

From: Li Chen
Date: Tue Jun 24 2025 - 05:00:42 EST


Hi Thomas,

---- On Fri, 20 Jun 2025 21:54:27 +0800 Thomas Gleixner <tglx@xxxxxxxxxxxxx> wrote ---
> 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
>

Thanks for your review, I have fixed the wording issues here: https://lore.kernel.org/all/20250624085559.69436-1-me@linux.beauty/T/#t

Regards,
Li