Messages in this thread Patch in this message | | | From | Yury Norov <> | Subject | [PATCH 18/22] sched/core: remove unneeded cpumask_weight() in sched_core_cpu_{starting,deactivate} | Date | Tue, 10 May 2022 08:47:46 -0700 |
| |
The following cpumask_any_but() implicitly calculates if number of smt cpus is equal to 1, therefore we can drop the code that does it explicitly.
CC: Ben Segall <bsegall@google.com> CC: Daniel Bristot de Oliveira <bristot@redhat.com> CC: Dietmar Eggemann <dietmar.eggemann@arm.com> CC: Ingo Molnar <mingo@redhat.com> CC: Juri Lelli <juri.lelli@redhat.com> CC: Mel Gorman <mgorman@suse.de> CC: Peter Zijlstra <peterz@infradead.org> CC: Steven Rostedt <rostedt@goodmis.org> CC: Valentin Schneider <vschneid@redhat.com> CC: Vincent Guittot <vincent.guittot@linaro.org> CC: linux-kernel@vger.kernel.org Signed-off-by: Yury Norov <yury.norov@gmail.com> --- This is RFC because it drops WARN_ON_ONCE(rq->core != rq). If this warinig is important, I'll rework the patch.
kernel/sched/core.c | 14 ++++---------- 1 file changed, 4 insertions(+), 10 deletions(-)
diff --git a/kernel/sched/core.c b/kernel/sched/core.c index 9700001948d0..07b8f35cbe36 100644 --- a/kernel/sched/core.c +++ b/kernel/sched/core.c @@ -6133,12 +6133,10 @@ static void sched_core_cpu_starting(unsigned int cpu) WARN_ON_ONCE(rq->core != rq); - /* if we're the first, we'll be our own leader */ - if (cpumask_weight(smt_mask) == 1) - goto unlock; - /* find the leader */ t = cpumask_any_but(smt_mask, cpu); + + /* if we're the first, we'll be our own leader */ if (t >= nr_cpu_ids) goto unlock; @@ -6171,18 +6169,14 @@ static void sched_core_cpu_deactivate(unsigned int cpu) sched_core_lock(cpu, &flags); - /* if we're the last man standing, nothing to do */ - if (cpumask_weight(smt_mask) == 1) { - WARN_ON_ONCE(rq->core != rq); - goto unlock; - } - /* if we're not the leader, nothing to do */ if (rq->core != rq) goto unlock; /* find a new leader */ t = cpumask_any_but(smt_mask, cpu); + + /* if we're the last man standing, nothing to do */ if (t >= nr_cpu_ids) goto unlock; -- 2.32.0
| |