Skip to content

Commit f79c9aa

Browse files
FirstLoveLifePeter Zijlstra
authored andcommitted
x86/smpboot: avoid SMT domain attach/destroy if SMT is not enabled
Currently, the SMT domain is added into sched_domain_topology by default. If cpu_attach_domain() finds that the CPU SMT domain’s cpumask_weight is just 1, it will destroy it. On a large machine, such as one with 512 cores, this results in 512 redundant domain attach/destroy operations. Avoid these unnecessary operations by simply checking cpu_smt_num_threads and skip SMT domain if the SMT domain is not enabled. Suggested-by: K Prateek Nayak <[email protected]> Signed-off-by: Li Chen <[email protected]> Signed-off-by: Peter Zijlstra (Intel) <[email protected]> Reviewed-by: K Prateek Nayak <[email protected]> Tested-by: K Prateek Nayak <[email protected]> Link: https://lore.kernel.org/r/[email protected]
1 parent fbc2010 commit f79c9aa

File tree

1 file changed

+11
-1
lines changed

1 file changed

+11
-1
lines changed

arch/x86/kernel/smpboot.c

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -492,6 +492,8 @@ static struct sched_domain_topology_level x86_topology[] = {
492492

493493
static void __init build_sched_topology(void)
494494
{
495+
struct sched_domain_topology_level *topology = x86_topology;
496+
495497
/*
496498
* When there is NUMA topology inside the package invalidate the
497499
* PKG domain since the NUMA domains will auto-magically create the
@@ -502,7 +504,15 @@ static void __init build_sched_topology(void)
502504

503505
memset(&x86_topology[pkgdom], 0, sizeof(x86_topology[pkgdom]));
504506
}
505-
set_sched_topology(x86_topology);
507+
508+
/*
509+
* Drop the SMT domains if there is only one thread per-core
510+
* since it'll get degenerated by the scheduler anyways.
511+
*/
512+
if (cpu_smt_num_threads <= 1)
513+
++topology;
514+
515+
set_sched_topology(topology);
506516
}
507517

508518
void set_cpu_sibling_map(int cpu)

0 commit comments

Comments
 (0)