[PATCH 3/3] sched/fair: Add compile time check in fastpaths for CONFIG_SCHED_SMT=n

From: Shrikanth Hegde

Date: Wed May 06 2026 - 07:01:59 EST


For fastpaths such as wakeup, load balance even a minimal code additons
can pop up. Add IS_ENABLED checks there to ensure there is no overhead.

Other places are either have sched_smt_active() check or they are not in
fast paths.

Signed-off-by: Shrikanth Hegde <sshegde@xxxxxxxxxxxxx>
---
kernel/sched/fair.c | 6 +++++-
1 file changed, 5 insertions(+), 1 deletion(-)

diff --git a/kernel/sched/fair.c b/kernel/sched/fair.c
index d19c416d1b84..cdd7f9633f98 100644
--- a/kernel/sched/fair.c
+++ b/kernel/sched/fair.c
@@ -1557,6 +1557,9 @@ static inline bool is_core_idle(int cpu)
{
int sibling;

+ if (!IS_ENABLED(CONFIG_SCHED_SMT))
+ return true;
+
for_each_cpu(sibling, cpu_smt_mask(cpu)) {
if (cpu == sibling)
continue;
@@ -11973,7 +11976,8 @@ static int should_we_balance(struct lb_env *env)
* idle has been found, then its not needed to check other
* SMT siblings for idleness:
*/
- cpumask_andnot(swb_cpus, swb_cpus, cpu_smt_mask(cpu));
+ if (IS_ENABLED(CONFIG_SCHED_SMT))
+ cpumask_andnot(swb_cpus, swb_cpus, cpu_smt_mask(cpu));
continue;
}

--
2.51.0