sched/fair: use cpumask_weight_and() in sched_balance_find_dst_group()
PATCH 1/1 sched/fair: use cpumask_weight_and() in sched_balance_find_dst_group()
From: Yury Norov (NVIDIA) <[email protected]>
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.
--- kernel/sched/fair.c | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-)
kernel/sched/fair.c +3 -4
@@ -10821,10 +10821,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 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);
Signature · 1 line
2.43.0
Hello Yury,
Quoted 6 lines · Yury Norov
From: Yury Norov (NVIDIA) <[email protected]>
In the
group_has_sparecase, 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.
Neat! I didn't realize this existed back when I added that cpumask_and()
+ cpumask_weight() combo. Please feel free to include:
Quoted 24 lines
Signed-off-by Yury Norov (NVIDIA) <[email protected]>--- kernel/sched/fair.c | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-)kernel/sched/fair.c +3
-4@@ -10821,10 +10821,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 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);
Signature · 2 lines
Thanks and Regards, Prateek
Quoted 9 lines · Yury Norov
From: Yury Norov (NVIDIA) <[email protected]>
In the
group_has_sparecase, 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) <[email protected]>
Quoted 25 lines
--- kernel/sched/fair.c | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-)kernel/sched/fair.c +3
-5@@ -10821,10 +10821,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 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
Quoted 6 lines · Yury Norov
In the
group_has_sparecase, 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.
LGTM
--
Thanks,
Fernand
Amazon Development Centre (South Africa) (Proprietary) Limited 29 Gogosoa Street, Observatory, Cape Town, Western Cape, 7925, South Africa Registration Number: 2004 / 034463 / 07