[PATCH v2 07/17] sched/fair: load balance only among preferred CPUs

From: Shrikanth Hegde

Date: Tue Apr 07 2026 - 15:22:28 EST


Consider only preferred CPUs for load balance.

With this, load balance will end up choosing a preferred CPUs for pull.
This makes it not fight against the push task mechanism which happens
at tick. Also, this stops active balance to happen on non-preferred CPU
pulling the load.

This means there is no load balancing if the task is pinned only to
non-preferred CPUs. They will continue to run where they were previously
running before the CPUs was marked as non-preferred.

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

diff --git a/kernel/sched/fair.c b/kernel/sched/fair.c
index 22010afb4c1d..e4571bd71a44 100644
--- a/kernel/sched/fair.c
+++ b/kernel/sched/fair.c
@@ -12058,6 +12058,11 @@ static int sched_balance_rq(int this_cpu, struct rq *this_rq,

cpumask_and(cpus, sched_domain_span(sd), cpu_active_mask);

+#ifdef CONFIG_PARAVIRT
+ /* Spread load among preferred CPUs */
+ cpumask_and(cpus, cpus, cpu_preferred_mask);
+#endif
+
schedstat_inc(sd->lb_count[idle]);

redo:
--
2.47.3