[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-Id: <20220510154750.212913-19-yury.norov@gmail.com>
Date: Tue, 10 May 2022 08:47:46 -0700
From: Yury Norov <yury.norov@...il.com>
To: Andy Shevchenko <andriy.shevchenko@...ux.intel.com>,
David Laight <David.Laight@...LAB.COM>,
Greg Kroah-Hartman <gregkh@...uxfoundation.org>,
Joe Perches <joe@...ches.com>,
Julia Lawall <Julia.Lawall@...ia.fr>,
Michał Mirosław <mirq-linux@...e.qmqm.pl>,
Nicholas Piggin <npiggin@...il.com>,
Nicolas Palix <nicolas.palix@...g.fr>,
Peter Zijlstra <peterz@...radead.org>,
Rasmus Villemoes <linux@...musvillemoes.dk>,
Matti Vaittinen <Matti.Vaittinen@...rohmeurope.com>,
linux-kernel@...r.kernel.org
Cc: Yury Norov <yury.norov@...il.com>, Ben Segall <bsegall@...gle.com>,
Daniel Bristot de Oliveira <bristot@...hat.com>,
Dietmar Eggemann <dietmar.eggemann@....com>,
Ingo Molnar <mingo@...hat.com>,
Juri Lelli <juri.lelli@...hat.com>,
Mel Gorman <mgorman@...e.de>,
Steven Rostedt <rostedt@...dmis.org>,
Valentin Schneider <vschneid@...hat.com>,
Vincent Guittot <vincent.guittot@...aro.org>
Subject: [PATCH 18/22] sched/core: remove unneeded cpumask_weight() in sched_core_cpu_{starting,deactivate}
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@...gle.com>
CC: Daniel Bristot de Oliveira <bristot@...hat.com>
CC: Dietmar Eggemann <dietmar.eggemann@....com>
CC: Ingo Molnar <mingo@...hat.com>
CC: Juri Lelli <juri.lelli@...hat.com>
CC: Mel Gorman <mgorman@...e.de>
CC: Peter Zijlstra <peterz@...radead.org>
CC: Steven Rostedt <rostedt@...dmis.org>
CC: Valentin Schneider <vschneid@...hat.com>
CC: Vincent Guittot <vincent.guittot@...aro.org>
CC: linux-kernel@...r.kernel.org
Signed-off-by: Yury Norov <yury.norov@...il.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
Powered by blists - more mailing lists