mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
* [PATCH RESEND] sched/fair: use cpumask_weight_and() in sched_balance_find_dst_group()
@ 2025-12-07  3:42 Yury Norov (NVIDIA)
  2026-01-12  8:03 ` [tip: sched/core] sched/fair: Use " tip-bot2 for Yury Norov (NVIDIA)
  0 siblings, 1 reply; 2+ messages in thread
From: Yury Norov (NVIDIA) @ 2025-12-07  3:42 UTC (permalink / raw)
  To: Peter Zijlstra, Ingo Molnar, Juri Lelli, Vincent Guittot,
	Dietmar Eggemann, Steven Rostedt, Ben Segall, Mel Gorman,
	Valentin Schneider, linux-kernel
  Cc: Yury Norov (NVIDIA), K Prateek Nayak, Fernand Sieber

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.

Reviewed-by: Vincent Guittot <vincent.guittot@linaro.org>
Reviewed-by: K Prateek Nayak <kprateek.nayak@amd.com>
Reviewed-by: Fernand Sieber <sieberf@amazon.com>
Signed-off-by: Yury Norov (NVIDIA) <yury.norov@gmail.com>
---
Rebased and re-tested on top of master. Original patch:
https://lore.kernel.org/all/20250911034454.494852-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 3ead55e4b8a5..e04f94233cda 100644
--- a/kernel/sched/fair.c
+++ b/kernel/sched/fair.c
@@ -10972,10 +10972,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.43.0


^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2026-01-12  8:03 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2025-12-07  3:42 [PATCH RESEND] sched/fair: use cpumask_weight_and() in sched_balance_find_dst_group() Yury Norov (NVIDIA)
2026-01-12  8:03 ` [tip: sched/core] sched/fair: Use " tip-bot2 for Yury Norov (NVIDIA)

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

all inboxes | Powered by JetHome®