Re: [PATCH v2 3/3] sched/fair: Add compile time check in fastpaths for CONFIG_SCHED_SMT=n
From: K Prateek Nayak
Date: Wed May 13 2026 - 02:10:56 EST
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 ...
> +
> 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?
> * 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;
> }
>
--
Thanks and Regards,
Prateek