Re: [PATCH v5 07/24] sched/fair: Select preferred CPU at wakeup when possible
From: Shrikanth Hegde
Date: Fri Jun 26 2026 - 09:18:06 EST
Hi Peter, Thank you very much for going through the patches.
On 6/26/26 3:29 PM, Peter Zijlstra wrote:
On Thu, Jun 25, 2026 at 06:16:31PM +0530, Shrikanth Hegde wrote:
Update available_idle_cpu to consider preferred CPUs. This takes care of
lot of decisions at wakeup to use only preferred CPUs. There is no need to
put those explicit checks everywhere.
Signed-off-by: Shrikanth Hegde <sshegde@xxxxxxxxxxxxx>
---
kernel/sched/sched.h | 3 +++
1 file changed, 3 insertions(+)
diff --git a/kernel/sched/sched.h b/kernel/sched/sched.h
index 5d009c2529b2..148fe6145f1a 100644
--- a/kernel/sched/sched.h
+++ b/kernel/sched/sched.h
@@ -1434,6 +1434,9 @@ static inline bool available_idle_cpu(int cpu)
if (!idle_rq(cpu_rq(cpu)))
return 0;
+ if (!cpu_preferred(cpu))
+ return 0;
+
if (vcpu_is_preempted(cpu))
return 0;
This one might hurt, it is a whole extra cacheline in otherwise already
sensitive (wakeup) paths.
Yes, this could be costly. If wakeup returns a non-preferred CPU,
is_cpu_allowed would catch it.
So, i think we can avoid repeated computation of it in available_idle_cpu.
Let me see if removing it still achieves the functionality of moving out
fast enough and numbers are close enough to with it.