Re: [PATCH v3 08/20] sched/fair: load balance only among preferred CPUs

From: Shrikanth Hegde

Date: Thu Jun 04 2026 - 01:48:14 EST


Hi Prateek.
Thanks for reviewing the patchset and tags.

On 6/4/26 10:50 AM, K Prateek Nayak wrote:
Hello Shrikanth,

On 5/14/2026 8:51 PM, Shrikanth Hegde wrote:
diff --git a/kernel/sched/fair.c b/kernel/sched/fair.c
index a704285ac55a..0a851d4b0d7e 100644
--- a/kernel/sched/fair.c
+++ b/kernel/sched/fair.c
@@ -12087,6 +12087,9 @@ static int sched_balance_rq(int this_cpu, struct rq *this_rq,
cpumask_and(cpus, sched_domain_span(sd), cpu_active_mask);
+ /* Spread load among preferred CPUs */
+ cpumask_and(cpus, cpus, cpu_preferred_mask);

nit.

Instead of the onine_mask, can we keep the cpu_preferred_mask closer in sync
with the active_mask?

I tried to make it active_mask. When there is high steal time,
a CPU marked as not-active isn't available for workload which pins
them. That would break user affinities.


That way, if we can ensure that a preferred CPU is always a subset of the
active_mask, we can save on a couple of cpumask_and() operations by just
looking at preferred_mask instead of both the active_mask and the
preferred_mask.


active mask used heavily today. I didn't want to merge the two.

Are there any complications in that approach to track it via
sched_cpu_activate() / sched_cpu_deactivate()?

Sorry i didn;t get this part. You mean track preferred mask with it?

We end up calling sched domain rebuild too if we go via sched_cpu_activate
build_sched_domains+8
partition_sched_domains_locked+1316
partition_sched_domains+80
rebuild_sched_domains_locked+332
cpuset_handle_hotplug+1456
sched_cpu_deactivate+608
cpuhp_invoke_callback+504
cpuhp_thread_fun+324
smpboot_thread_fn+556




What is active_mask guaranteed to provide today? Are there any ABI for it
or we are free to change it?