From 55b39b0cf183b9c682717a55a2fba06da69bba6b Mon Sep 17 00:00:00 2001 From: "Yury Norov (NVIDIA)" Date: Sat, 6 Dec 2025 22:42:47 -0500 Subject: [PATCH] sched/fair: Use cpumask_weight_and() in sched_balance_find_dst_group() In the group_has_spare case, the function creates a temporary cpumask to just calculate weight of (p->cpus_ptr & sched_group_span(local)). We've got a dedicated helper for it. Signed-off-by: Yury Norov (NVIDIA) Signed-off-by: Peter Zijlstra (Intel) Reviewed-by: Vincent Guittot Reviewed-by: K Prateek Nayak Reviewed-by: Fernand Sieber Link: https://patch.msgid.link/20251207034247.402926-1-yury.norov@gmail.com --- kernel/sched/fair.c | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/kernel/sched/fair.c b/kernel/sched/fair.c index 842a0f20414f1..ebee20f75fa02 100644 --- a/kernel/sched/fair.c +++ b/kernel/sched/fair.c @@ -10974,10 +10974,9 @@ sched_balance_find_dst_group(struct sched_domain *sd, struct task_struct *p, int * take care of it. */ if (p->nr_cpus_allowed != NR_CPUS) { - struct cpumask *cpus = this_cpu_cpumask_var_ptr(select_rq_mask); - - cpumask_and(cpus, sched_group_span(local), p->cpus_ptr); - imb_numa_nr = min(cpumask_weight(cpus), sd->imb_numa_nr); + unsigned int w = cpumask_weight_and(p->cpus_ptr, + sched_group_span(local)); + imb_numa_nr = min(w, sd->imb_numa_nr); } imbalance = abs(local_sgs.idle_cpus - idlest_sgs.idle_cpus); -- 2.47.3