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

From: Peter Zijlstra
Date: Wed Jun 25 2025 - 04:32:53 EST


On Wed, Jun 25, 2025 at 11:15:22AM +0530, K Prateek Nayak wrote:

> diff --git a/arch/x86/kernel/smpboot.c b/arch/x86/kernel/smpboot.c
> index 3818b16c19e1..1793248d28cd 100644
> --- a/arch/x86/kernel/smpboot.c
> +++ b/arch/x86/kernel/smpboot.c
> @@ -494,6 +494,8 @@ static struct sched_domain_topology_level x86_topology[] = {
> static void __init build_sched_topology(void)
> {
> + struct sched_domain_topology_level *topology = x86_topology;
> +
> /*
> * When there is NUMA topology inside the package invalidate the
> * PKG domain since the NUMA domains will auto-magically create the
> @@ -504,7 +506,15 @@ static void __init build_sched_topology(void)
> memset(&x86_topology[pkgdom], 0, sizeof(x86_topology[pkgdom]));
> }
> - set_sched_topology(x86_topology);
> +
> + /*
> + * Drop the SMT domains if there is only one thread per-core
> + * since it'll get degenerated by the scheduler anyways.
> + */
> + if (cpu_smt_num_threads <= 1)
> + ++topology;
> +
> + set_sched_topology(topology);
> }
> void set_cpu_sibling_map(int cpu)

Yes, that is far saner.