linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Yury Norov <yury.norov@gmail.com>
To: "Yury Norov" <yury.norov@gmail.com>,
	"Andy Shevchenko" <andriy.shevchenko@linux.intel.com>,
	"Rasmus Villemoes" <linux@rasmusvillemoes.dk>,
	"Andrew Morton" <akpm@linux-foundation.org>,
	"Michał Mirosław" <mirq-linux@rere.qmqm.pl>,
	"Greg Kroah-Hartman" <gregkh@linuxfoundation.org>,
	"Peter Zijlstra" <peterz@infradead.org>,
	"David Laight" <David.Laight@aculab.com>,
	"Joe Perches" <joe@perches.com>,
	"Dennis Zhou" <dennis@kernel.org>,
	"Emil Renner Berthing" <kernel@esmil.dk>,
	"Nicholas Piggin" <npiggin@gmail.com>,
	"Matti Vaittinen" <matti.vaittinen@fi.rohmeurope.com>,
	"Alexey Klimov" <aklimov@redhat.com>,
	linux-kernel@vger.kernel.org,
	"Michael Ellerman" <mpe@ellerman.id.au>,
	"Benjamin Herrenschmidt" <benh@kernel.crashing.org>,
	"Paul Mackerras" <paulus@samba.org>,
	"Srikar Dronamraju" <srikar@linux.vnet.ibm.com>,
	"Gautham R. Shenoy" <ego@linux.vnet.ibm.com>,
	"Valentin Schneider" <valentin.schneider@arm.com>,
	"Parth Shah" <parth@linux.ibm.com>,
	"Cédric Le Goater" <clg@kaod.org>,
	"Hari Bathini" <hbathini@linux.ibm.com>,
	"Rob Herring" <robh@kernel.org>,
	"Laurent Dufour" <ldufour@linux.ibm.com>,
	"Petr Mladek" <pmladek@suse.com>,
	"John Ogness" <john.ogness@linutronix.de>,
	"Sudeep Holla" <sudeep.holla@arm.com>,
	"Christophe Leroy" <christophe.leroy@csgroup.eu>,
	"Naveen N. Rao" <naveen.n.rao@linux.vnet.ibm.com>,
	"Xiongwei Song" <sxwjean@gmail.com>,
	"Arnd Bergmann" <arnd@arndb.de>,
	linuxppc-dev@lists.ozlabs.org
Subject: [PATCH 39/54] arch/powerpc: replace cpumask_weight with cpumask_weight_{eq, ...} where appropriate
Date: Sun, 23 Jan 2022 10:39:10 -0800	[thread overview]
Message-ID: <20220123183925.1052919-40-yury.norov@gmail.com> (raw)
In-Reply-To: <20220123183925.1052919-1-yury.norov@gmail.com>

PowerPC code uses cpumask_weight() to compare the weight of cpumask
with a given number. We can do it more efficiently with
cpumask_weight_{eq, ...} because conditional cpumask_weight may stop
traversing the cpumask earlier, as soon as condition is met.

Signed-off-by: Yury Norov <yury.norov@gmail.com>
---
 arch/powerpc/kernel/smp.c      | 2 +-
 arch/powerpc/kernel/watchdog.c | 2 +-
 arch/powerpc/xmon/xmon.c       | 4 ++--
 3 files changed, 4 insertions(+), 4 deletions(-)

diff --git a/arch/powerpc/kernel/smp.c b/arch/powerpc/kernel/smp.c
index b7fd6a72aa76..8bff748df402 100644
--- a/arch/powerpc/kernel/smp.c
+++ b/arch/powerpc/kernel/smp.c
@@ -1656,7 +1656,7 @@ void start_secondary(void *unused)
 		if (has_big_cores)
 			sibling_mask = cpu_smallcore_mask;
 
-		if (cpumask_weight(mask) > cpumask_weight(sibling_mask(cpu)))
+		if (cpumask_weight_gt(mask, cpumask_weight(sibling_mask(cpu))))
 			shared_caches = true;
 	}
 
diff --git a/arch/powerpc/kernel/watchdog.c b/arch/powerpc/kernel/watchdog.c
index bfc27496fe7e..62937a077de7 100644
--- a/arch/powerpc/kernel/watchdog.c
+++ b/arch/powerpc/kernel/watchdog.c
@@ -483,7 +483,7 @@ static void start_watchdog(void *arg)
 
 	wd_smp_lock(&flags);
 	cpumask_set_cpu(cpu, &wd_cpus_enabled);
-	if (cpumask_weight(&wd_cpus_enabled) == 1) {
+	if (cpumask_weight_eq(&wd_cpus_enabled, 1)) {
 		cpumask_set_cpu(cpu, &wd_smp_cpus_pending);
 		wd_smp_last_reset_tb = get_tb();
 	}
diff --git a/arch/powerpc/xmon/xmon.c b/arch/powerpc/xmon/xmon.c
index fd72753e8ad5..b423812e94e0 100644
--- a/arch/powerpc/xmon/xmon.c
+++ b/arch/powerpc/xmon/xmon.c
@@ -469,7 +469,7 @@ static bool wait_for_other_cpus(int ncpus)
 
 	/* We wait for 2s, which is a metric "little while" */
 	for (timeout = 20000; timeout != 0; --timeout) {
-		if (cpumask_weight(&cpus_in_xmon) >= ncpus)
+		if (cpumask_weight_ge(&cpus_in_xmon, ncpus))
 			return true;
 		udelay(100);
 		barrier();
@@ -1338,7 +1338,7 @@ static int cpu_cmd(void)
 			case 'S':
 			case 't':
 				cpumask_copy(&xmon_batch_cpus, &cpus_in_xmon);
-				if (cpumask_weight(&xmon_batch_cpus) <= 1) {
+				if (cpumask_weight_le(&xmon_batch_cpus, 1)) {
 					printf("There are no other cpus in xmon\n");
 					break;
 				}
-- 
2.30.2


  parent reply	other threads:[~2022-01-23 18:43 UTC|newest]

Thread overview: 97+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-01-23 18:38 [PATCH v3 00/54] lib/bitmap: optimize bitmap_weight() usage Yury Norov
2022-01-23 18:38 ` [PATCH 01/54] net/dsa: don't use bitmap_weight() in b53_arl_read() Yury Norov
2022-01-24  3:11   ` Florian Fainelli
2022-01-23 18:38 ` [PATCH 02/54] net/ethernet: don't use bitmap_weight() in bcm_sysport_rule_set() Yury Norov
2022-01-24  3:11   ` Florian Fainelli
2022-01-23 18:38 ` [PATCH 03/54] thermal/intel: don't use bitmap_weight() in end_power_clamp() Yury Norov
2022-02-04 18:29   ` Rafael J. Wysocki
2022-01-23 18:38 ` [PATCH 04/54] net: mellanox: fix open-coded for_each_set_bit() Yury Norov
2022-01-26  9:01   ` Tariq Toukan
2022-01-23 18:38 ` [PATCH 05/54] nds32: perf: replace bitmap_weight with bitmap_empty where appropriate Yury Norov
2022-01-23 18:38 ` [PATCH 06/54] x86/kvm: " Yury Norov
2022-01-24  9:11   ` Vitaly Kuznetsov
2022-01-23 18:38 ` [PATCH 07/54] gpu: drm: " Yury Norov
2022-01-23 18:38 ` [PATCH 08/54] net: ethernet: replace bitmap_weight with bitmap_empty for intel Yury Norov
2022-01-23 18:38 ` [PATCH 09/54] net: ethernet: replace bitmap_weight with bitmap_empty for Marvell Yury Norov
2022-01-23 18:38 ` [PATCH 10/54] net: ethernet: replace bitmap_weight with bitmap_empty for qlogic Yury Norov
2022-01-24 12:28   ` Andy Shevchenko
2022-01-25 21:09     ` Yury Norov
2022-01-25 22:14       ` David Laight
2022-01-25 23:10         ` Yury Norov
2022-01-23 18:38 ` [PATCH 11/54] perf: replace bitmap_weight with bitmap_empty where appropriate Yury Norov
2022-01-23 18:38 ` [PATCH 12/54] tools/perf: " Yury Norov
2022-02-15 14:34   ` Arnaldo Carvalho de Melo
2022-01-23 18:38 ` [PATCH 13/54] arch/alpha: replace cpumask_weight with cpumask_empty " Yury Norov
2022-01-23 18:38 ` [PATCH 14/54] arch/ia64: " Yury Norov
2022-01-23 18:38 ` [PATCH 15/54] arch/x86: " Yury Norov
2022-01-27 17:20   ` Steve Wahl
2022-01-23 18:38 ` [PATCH 16/54] cpufreq: " Yury Norov
2022-01-24 10:41   ` Sudeep Holla
2022-02-09  6:15   ` Viresh Kumar
2022-01-23 18:38 ` [PATCH 17/54] gpu: drm: " Yury Norov
2022-01-25  9:28   ` Tvrtko Ursulin
2022-01-25 18:16     ` Yury Norov
2022-01-26  9:43       ` Tvrtko Ursulin
2022-01-23 18:38 ` [PATCH 18/54] drivers/infiniband: " Yury Norov
2022-01-23 19:13   ` Leon Romanovsky
2022-01-23 18:38 ` [PATCH 19/54] drivers/irqchip: " Yury Norov
2022-01-24  3:11   ` Florian Fainelli
2022-01-23 18:38 ` [PATCH 20/54] kernel/irq: " Yury Norov
2022-01-23 18:38 ` [PATCH 21/54] kernel: replace cpumask_weight with cpumask_empty in padata.c Yury Norov
2022-01-28  6:29   ` Herbert Xu
2022-01-23 18:38 ` [PATCH 22/54] rcu: replace cpumask_weight with cpumask_empty where appropriate Yury Norov
2022-01-24  0:07   ` Paul E. McKenney
2022-01-23 18:38 ` [PATCH 23/54] sched: " Yury Norov
2022-01-23 18:38 ` [PATCH 24/54] time: replace cpumask_weight with cpumask_empty in clocksource.c Yury Norov
2022-01-23 18:38 ` [PATCH 25/54] mm/vmstat: replace cpumask_weight with cpumask_empty where appropriate Yury Norov
2022-01-23 18:38 ` [PATCH 26/54] arch/x86: replace nodes_weight with nodes_empty " Yury Norov
2022-01-23 18:38 ` [PATCH 27/54] lib/bitmap: add bitmap_weight_{cmp, eq, gt, ge, lt, le} functions Yury Norov
2022-01-24 12:41   ` Andy Shevchenko
2022-01-24 12:43     ` Andy Shevchenko
2022-01-24 12:49       ` Peter Zijlstra
2022-01-26 15:56     ` Yury Norov
2022-01-28  6:59   ` Vaittinen, Matti
2022-01-23 18:38 ` [PATCH 28/54] arch/x86: replace bitmap_weight with bitmap_weight_{eq,gt,ge,lt,le} where appropriate Yury Norov
2022-01-23 18:39 ` [PATCH 29/54] drivers/iio: replace bitmap_weight() with bitmap_weight_{eq,gt} " Yury Norov
2022-01-24 12:46   ` Andy Shevchenko
2022-01-30 12:54     ` Jonathan Cameron
2022-01-23 18:39 ` [PATCH 30/54] drivers/memstick: replace bitmap_weight with bitmap_weight_eq " Yury Norov
2022-01-31 16:07   ` Ulf Hansson
2022-01-23 18:39 ` [PATCH 31/54] net: ethernet: replace bitmap_weight with bitmap_weight_eq for intel Yury Norov
2022-01-23 18:39 ` [PATCH 32/54] net: ethernet: replace bitmap_weight with bitmap_weight_{eq,gt} for OcteonTX2 Yury Norov
2022-01-23 18:39 ` [PATCH 33/54] net: ethernet: replace bitmap_weight with bitmap_weight_{eq,gt,ge,lt,le} for mellanox Yury Norov
2022-01-24 12:48   ` Andy Shevchenko
2022-02-09  6:46     ` Yury Norov
2022-01-23 18:39 ` [PATCH 34/54] perf: replace bitmap_weight with bitmap_weight_eq for ThunderX2 Yury Norov
2022-01-23 18:39 ` [PATCH 35/54] drivers/staging: replace bitmap_weight with bitmap_weight_le for tegra-video Yury Norov
2022-01-23 18:39 ` [PATCH 36/54] lib/cpumask: add cpumask_weight_{eq,gt,ge,lt,le} Yury Norov
2022-01-23 18:39 ` [PATCH 37/54] arch/ia64: replace cpumask_weight with cpumask_weight_eq in mm/tlb.c Yury Norov
2022-01-23 18:39 ` [PATCH 38/54] arch/mips: replace cpumask_weight with cpumask_weight_{eq, ...} where appropriate Yury Norov
2022-01-25 19:05   ` Thomas Bogendoerfer
2022-01-23 18:39 ` Yury Norov [this message]
2022-01-23 18:39 ` [PATCH 40/54] arch/s390: replace cpumask_weight with cpumask_weight_eq " Yury Norov
2022-01-23 18:39 ` [PATCH 41/54] arch/x86: " Yury Norov
2022-01-24  8:05   ` Peter Zijlstra
2022-01-24  9:16   ` Vitaly Kuznetsov
2022-01-23 18:39 ` [PATCH 42/54] firmware: pcsi: replace cpumask_weight with cpumask_weight_eq Yury Norov
2022-01-23 18:39 ` [PATCH 43/54] drivers/hv: " Yury Norov
2022-01-23 22:00   ` Wei Liu
2022-01-23 22:02   ` Haiyang Zhang
2022-01-24  9:20   ` Vitaly Kuznetsov
2022-01-27 15:02     ` Michael Kelley (LINUX)
2022-01-28  9:31       ` Vitaly Kuznetsov
2022-01-23 18:39 ` [PATCH 44/54] infiniband: replace cpumask_weight with cpumask_weight_{eq, ...} where appropriate Yury Norov
2022-01-23 18:39 ` [PATCH 45/54] scsi: replace cpumask_weight with cpumask_weight_gt Yury Norov
2022-01-23 18:39 ` [PATCH 46/54] soc: replace cpumask_weight with cpumask_weight_lt Yury Norov
2022-01-23 18:39 ` [PATCH 47/54] sched: replace cpumask_weight with cpumask_weight_eq where appropriate Yury Norov
2022-01-24  8:05   ` Peter Zijlstra
2022-01-23 18:39 ` [PATCH 48/54] kernel/time: " Yury Norov
2022-01-24  8:06   ` Peter Zijlstra
2022-01-23 18:39 ` [PATCH 49/54] lib/nodemask: add nodemask_weight_{eq,gt,ge,lt,le} Yury Norov
2022-01-23 18:39 ` [PATCH 50/54] acpi: replace nodes__weight with nodes_weight_ge for numa Yury Norov
2022-01-23 18:39 ` [PATCH 51/54] mm: replace nodes_weight with nodes_weight_eq in mempolicy Yury Norov
2022-01-23 18:39 ` [PATCH 52/54] lib/nodemask: add num_node_state_eq() Yury Norov
2022-01-23 18:39 ` [PATCH 53/54] tools/bitmap: sync bitmap_weight Yury Norov
2022-01-23 18:39 ` [PATCH 54/54] MAINTAINERS: add cpumask and nodemask files to BITMAP_API Yury Norov
2022-01-26  7:30 ` [PATCH v3 00/54] lib/bitmap: optimize bitmap_weight() usage Vaittinen, Matti
2022-01-27 17:44   ` Yury Norov

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20220123183925.1052919-40-yury.norov@gmail.com \
    --to=yury.norov@gmail.com \
    --cc=David.Laight@aculab.com \
    --cc=aklimov@redhat.com \
    --cc=akpm@linux-foundation.org \
    --cc=andriy.shevchenko@linux.intel.com \
    --cc=arnd@arndb.de \
    --cc=benh@kernel.crashing.org \
    --cc=christophe.leroy@csgroup.eu \
    --cc=clg@kaod.org \
    --cc=dennis@kernel.org \
    --cc=ego@linux.vnet.ibm.com \
    --cc=gregkh@linuxfoundation.org \
    --cc=hbathini@linux.ibm.com \
    --cc=joe@perches.com \
    --cc=john.ogness@linutronix.de \
    --cc=kernel@esmil.dk \
    --cc=ldufour@linux.ibm.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux@rasmusvillemoes.dk \
    --cc=linuxppc-dev@lists.ozlabs.org \
    --cc=matti.vaittinen@fi.rohmeurope.com \
    --cc=mirq-linux@rere.qmqm.pl \
    --cc=mpe@ellerman.id.au \
    --cc=naveen.n.rao@linux.vnet.ibm.com \
    --cc=npiggin@gmail.com \
    --cc=parth@linux.ibm.com \
    --cc=paulus@samba.org \
    --cc=peterz@infradead.org \
    --cc=pmladek@suse.com \
    --cc=robh@kernel.org \
    --cc=srikar@linux.vnet.ibm.com \
    --cc=sudeep.holla@arm.com \
    --cc=sxwjean@gmail.com \
    --cc=valentin.schneider@arm.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).