]> git.ipfire.org Git - thirdparty/kernel/linux.git/commit
sched: Simplify ifdeffery around cpu_smt_mask
authorShrikanth Hegde <sshegde@linux.ibm.com>
Fri, 15 May 2026 17:24:54 +0000 (22:54 +0530)
committerPeter Zijlstra <peterz@infradead.org>
Tue, 19 May 2026 10:17:37 +0000 (12:17 +0200)
commit5bc6ab2d42e545f816def21cfcdb4ba35cc74bf6
tree15459f1111962b6195b51472236c584a2737b58e
parent815c5cb76a3e5dad4fc3911b9073591dc3a29282
sched: Simplify ifdeffery around cpu_smt_mask

Now, that cpu_smt_mask is defined as cpumask_of(cpu) for
CONFIG_SCHED_SMT=n, it is possible to get rid of the ifdeffery.

Effectively,
 - This makes sched_smt_present is defined always

 - cpumask_weight(cpumask_of(cpu)) == 1. So sched_smt_present_inc/dec
   will never enable the sched_smt_present. Which is expected.

 - Paths that were compile-time eliminated become runtime guarded
   using static keys.

 - Defines set_idle_cores, test_idle_cores, etc which could likely benefit
   the CONFIG_SCHED_SMT=n systems to use the same optimizations within the
   LLC at wakeups.

 - This will expose sched_smt_present symbol for CONFIG_SCHED_SMT=n.
   Likely not a concern.

 - There is a bloat of code CONFIG_SCHED_SMT=n. (NR_CPUS=2048)
   add/remove: 24/18 grow/shrink: 26/28 up/down: 6396/-3188 (3208)
   Total: Before=30629880, After=30633088, chg +0.01%

 - No code bloat for CONFIG_SCHED_SMT=y, which is expected.

 - Add comments around stop_core_cpuslocked on why ifdefs are not
   removed.

 - This leaves the remaining uses of CONFIG_SCHED_SMT mainly for
   topology building bits which has a policy based decision.

Signed-off-by: Shrikanth Hegde <sshegde@linux.ibm.com>
Signed-off-by: Peter Zijlstra (Intel) <peterz@infradead.org>
Reviewed-by: Phil Auld <pauld@redhat.com>
Reviewed-by: Valentin Schneider <vschneid@redhat.com>
Acked-by: Tejun Heo <tj@kernel.org>
Tested-by: K Prateek Nayak <kprateek.nayak@amd.com>
Link: https://patch.msgid.link/20260515172456.542799-3-sshegde@linux.ibm.com
include/linux/sched/smt.h
kernel/sched/core.c
kernel/sched/ext_idle.c
kernel/sched/fair.c
kernel/sched/sched.h
kernel/sched/topology.c
kernel/stop_machine.c
kernel/workqueue.c