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

From: Shrikanth Hegde

Date: Wed May 13 2026 - 02:17:00 EST




On 5/13/26 11:37 AM, K Prateek Nayak wrote:
Hello Shrikanth,

Thank you for cleaning these bits up! Couple comments below:

On 5/12/2026 8:51 PM, Shrikanth Hegde wrote:
diff --git a/kernel/sched/fair.c b/kernel/sched/fair.c
index 353e31ecaadc..b6f9592b31fd 100644
--- a/kernel/sched/fair.c
+++ b/kernel/sched/fair.c
@@ -1586,6 +1586,9 @@ static inline bool is_core_idle(int cpu)
{
int sibling;
+ if (!IS_ENABLED(CONFIG_SCHED_SMT))
+ return true;

I think !sched_smt_active() can also return early here. That said ...


If we do below, the rest users already have the checks.
So we should be good.
I will add a comment saying this expects to be called under sched_smt_active.

+
for_each_cpu(sibling, cpu_smt_mask(cpu)) {
if (cpu == sibling)
continue;
@@ -12003,7 +12006,8 @@ static int should_we_balance(struct lb_env *env)

... I think the if() above can simply check for sched_smt_active()
before calling is_core_idle() like:

if (sched_smt_active() &&
!(env->sd->flags & SD_SHARE_CPUCAPACITY) &&
!is_core_idle(cpu)) {
...
}

That way, we ensure we don't call is_core_idle() and the cpumask_and()
unnecessarily on topologies that don't have SMT domain similar to how
sched_use_asym_prio() guards the call to is_core_idle().

Thoughts?

Ack. Let me edit the v3. I was about to send.


* 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;
}