Commit c5511d03 authored by Peter Zijlstra (Intel)'s avatar Peter Zijlstra (Intel) Committed by Thomas Gleixner
Browse files

sched/smt: Make sched_smt_present track topology

Currently the 'sched_smt_present' static key is enabled when at CPU bringup
SMT topology is observed, but it is never disabled. However there is demand
to also disable the key when the topology changes such that there is no SMT
present anymore.

Implement this by making the key count the number of cores that have SMT

In particular, the SMT topology bits are set before interrrupts are enabled
and similarly, are cleared after interrupts are disabled for the last time
and the CPU dies.
Signed-off-by: default avatarPeter Zijlstra (Intel) <>
Signed-off-by: default avatarThomas Gleixner <>
Reviewed-by: default avatarIngo Molnar <>
Cc: Andy Lutomirski <>
Cc: Linus Torvalds <>
Cc: Jiri Kosina <>
Cc: Tom Lendacky <>
Cc: Josh Poimboeuf <>
Cc: Andrea Arcangeli <>
Cc: David Woodhouse <>
Cc: Tim Chen <>
Cc: Andi Kleen <>
Cc: Dave Hansen <>
Cc: Casey Schaufler <>
Cc: Asit Mallick <>
Cc: Arjan van de Ven <>
Cc: Jon Masters <>
Cc: Waiman Long <>
Cc: Greg KH <>
Cc: Dave Stewart <>
Cc: Kees Cook <>
parent 01daf568
......@@ -5738,15 +5738,10 @@ int sched_cpu_activate(unsigned int cpu)
* The sched_smt_present static key needs to be evaluated on every
* hotplug event because at boot time SMT might be disabled when
* the number of booted CPUs is limited.
* If then later a sibling gets hotplugged, then the key would stay
* off and SMT scheduling would never be functional.
* When going up, increment the number of cores with SMT present.
if (cpumask_weight(cpu_smt_mask(cpu)) > 1)
if (cpumask_weight(cpu_smt_mask(cpu)) == 2)
set_cpu_active(cpu, true);
......@@ -5790,6 +5785,14 @@ int sched_cpu_deactivate(unsigned int cpu)
synchronize_rcu_mult(call_rcu, call_rcu_sched);
* When going down, decrement the number of cores with SMT present.
if (cpumask_weight(cpu_smt_mask(cpu)) == 2)
if (!sched_smp_initialized)
return 0;
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment