Re: [PATCH v6 06/23] sched/fair: Load balance only among preferred CPUs

From: Shrikanth Hegde

Date: Wed Jul 01 2026 - 12:45:11 EST




On 7/1/26 9:49 PM, Yury Norov wrote:
On Wed, Jul 01, 2026 at 07:46:37PM +0530, Shrikanth Hegde wrote:
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 | 3 ++-
1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/kernel/sched/fair.c b/kernel/sched/fair.c
index ce05acf52d35..9b2931b559d6 100644
--- a/kernel/sched/fair.c
+++ b/kernel/sched/fair.c
@@ -13391,7 +13391,8 @@ static int sched_balance_rq(int this_cpu, struct rq *this_rq,
};
bool need_unlock = false;
- cpumask_and(cpus, sched_domain_span(sd), cpu_active_mask);
+ /* Spread load among preferred CPUs */

We don't have a "Spread load among active CPUs" comment. Don't think
it's more difficult to understand what happens if you replace one mask
with another.


Alright, I will drop it.

+ cpumask_and(cpus, sched_domain_span(sd), cpu_preferred_mask);
schedstat_inc(sd->lb_count[idle]);
--
2.47.3