[PATCH 19/22] sched/core: replace cpumask_weight() with cpumask_weight_eq() where appropriate

From: Yury Norov
Date: Tue May 10 2022 - 11:58:42 EST


cpumask_weight_eq() is better than cpumask_weight() because it may
return earlier depending on condition.

CC: Ben Segall <bsegall@xxxxxxxxxx>
CC: Daniel Bristot de Oliveira <bristot@xxxxxxxxxx>
CC: Dietmar Eggemann <dietmar.eggemann@xxxxxxx>
CC: Ingo Molnar <mingo@xxxxxxxxxx>
CC: Juri Lelli <juri.lelli@xxxxxxxxxx>
CC: Mel Gorman <mgorman@xxxxxxx>
CC: Peter Zijlstra <peterz@xxxxxxxxxxxxx>
CC: Steven Rostedt <rostedt@xxxxxxxxxxx>
CC: Valentin Schneider <vschneid@xxxxxxxxxx>
CC: Vincent Guittot <vincent.guittot@xxxxxxxxxx>
CC: linux-kernel@xxxxxxxxxxxxxxx
Signed-off-by: Yury Norov <yury.norov@xxxxxxxxx>
---
kernel/sched/core.c | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/kernel/sched/core.c b/kernel/sched/core.c
index 07b8f35cbe36..6bbd5e880984 100644
--- a/kernel/sched/core.c
+++ b/kernel/sched/core.c
@@ -9234,7 +9234,7 @@ int sched_cpu_activate(unsigned int cpu)
/*
* When going up, increment the number of cores with SMT present.
*/
- if (cpumask_weight(cpu_smt_mask(cpu)) == 2)
+ if (cpumask_weight_eq(cpu_smt_mask(cpu), 2))
static_branch_inc_cpuslocked(&sched_smt_present);
#endif
set_cpu_active(cpu, true);
@@ -9310,7 +9310,7 @@ int sched_cpu_deactivate(unsigned int cpu)
/*
* When going down, decrement the number of cores with SMT present.
*/
- if (cpumask_weight(cpu_smt_mask(cpu)) == 2)
+ if (cpumask_weight_eq(cpu_smt_mask(cpu), 2))
static_branch_dec_cpuslocked(&sched_smt_present);

sched_core_cpu_deactivate(cpu);
--
2.32.0