[PATCH 2/2] sched/fair: Honor asymmetric SMT priority in idle selection
K Prateek Nayak
kprateek.nayak at amd.com
Tue Sep 8 12:40:48 PDT 2026
Hello Andrea,
On 9/8/2026 1:53 PM, Andrea Righi wrote:
> @@ -9747,8 +9796,10 @@ select_task_rq_fair(struct task_struct *p, int prev_cpu, int wake_flags)
> }
>
> /* Slow path */
> - if (unlikely(sd))
> - return sched_balance_find_dst_cpu(sd, p, cpu, prev_cpu, sd_flag);
> + if (unlikely(sd)) {
> + new_cpu = sched_balance_find_dst_cpu(sd, p, cpu, prev_cpu, sd_flag);
> + return select_idle_smt_cpu(p, new_cpu);
nit. I personally feel this can be better integrated into the
sched_balance_find_dst_cpu(). Something like the following:
(Only build tested)
diff --git a/kernel/sched/fair.c b/kernel/sched/fair.c
index b8bd308c2d5b..1012dfb33f08 100644
--- a/kernel/sched/fair.c
+++ b/kernel/sched/fair.c
@@ -12353,6 +12353,17 @@ static inline void update_sg_wakeup_stats(struct sched_domain *sd,
}
+ /*
+ * If we are on a SD_SHARE_CPUCAPACITY | SD_ASYM_PACKING
+ * domain, use the group_asym_packing classification to
+ * decide placement based on rankings of idle siblings.
+ */
+ if (unlikely(sched_smt_asym_active() &&
+ (sd->flags & SD_SHARE_CPUCAPACITY) &&
+ (sd->flags & SD_ASYM_PACKING) &&
+ sgs->idle_cpus))
+ sgs->group_asym_packing = 1;
+
sgs->group_capacity = group->sgc->capacity;
sgs->group_weight = group->group_weight;
@@ -12393,9 +12404,15 @@ static bool update_pick_idlest(struct sched_group *idlest,
return false;
break;
+ case group_asym_packing:
+ /*
+ * Only possible for sched_smt_asym_active().
+ * Select the idle SMT that is more preferred.
+ */
+ return sched_asym_prefer(idlest->asym_prefer_cpu,
+ group->asym_prefer_cpu);
case group_llc_balance:
case group_imbalanced:
- case group_asym_packing:
case group_smt_balance:
/* Those types are not used in the slow wakeup path */
return false;
---
It leads to slightly more branches but they are super predictable when
iterating at a particular sched_domain level so the overhead should be
negligible.
I don't have any strong feelings either ways. Thoughts?
--
Thanks and Regards,
Prateek
More information about the linux-arm-kernel
mailing list