From: Yury Norov <yury.norov@gmail.com>
To: linuxppc-dev@lists.ozlabs.org, linux-kernel@vger.kernel.org
Cc: Valentin Schneider <vschneid@redhat.com>,
Yury Norov <yury.norov@gmail.com>, Arnd Bergmann <arnd@arndb.de>,
Barry Song <baohua@kernel.org>,
Nicholas Piggin <npiggin@gmail.com>,
Jakub Kicinski <kuba@kernel.org>,
Dietmar Eggemann <dietmar.eggemann@arm.com>,
Jeremy Kerr <jk@ozlabs.org>
Subject: [PATCH 1/2] sched/topology: introduce node_has_cpus() macro
Date: Tue, 21 Feb 2023 18:50:28 -0800 [thread overview]
Message-ID: <20230222025029.453834-1-yury.norov@gmail.com> (raw)
Currently, to check if NUMA node has CPUs, one has to use the
nr_cpus_node() macro, which ends up with cpumask_weight. We can do it
better with cpumask_empty(), because the latter can potentially return
earlier - as soon as 1st set bit found.
This patch adds a node_has_cpus() macro to implement that.
Signed-off-by: Yury Norov <yury.norov@gmail.com>
---
include/linux/topology.h | 4 +++-
1 file changed, 3 insertions(+), 1 deletion(-)
diff --git a/include/linux/topology.h b/include/linux/topology.h
index fea32377f7c7..7e0d8f8f5a39 100644
--- a/include/linux/topology.h
+++ b/include/linux/topology.h
@@ -39,9 +39,11 @@
#define nr_cpus_node(node) cpumask_weight(cpumask_of_node(node))
#endif
+#define node_has_cpus(node) (!cpumask_empty(cpumask_of_node(node)))
+
#define for_each_node_with_cpus(node) \
for_each_online_node(node) \
- if (nr_cpus_node(node))
+ if (node_has_cpus(node))
int arch_update_cpu_topology(void);
--
2.34.1
next reply other threads:[~2023-02-22 2:51 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2023-02-22 2:50 Yury Norov [this message]
2023-02-22 2:50 ` [PATCH 2/2] powerpc: use node_has_cpus() instead of nr_cpus_node() Yury Norov
2023-03-15 16:48 ` Valentin Schneider
2023-03-15 16:48 ` [PATCH 1/2] sched/topology: introduce node_has_cpus() macro Valentin Schneider
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=20230222025029.453834-1-yury.norov@gmail.com \
--to=yury.norov@gmail.com \
--cc=arnd@arndb.de \
--cc=baohua@kernel.org \
--cc=dietmar.eggemann@arm.com \
--cc=jk@ozlabs.org \
--cc=kuba@kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linuxppc-dev@lists.ozlabs.org \
--cc=npiggin@gmail.com \
--cc=vschneid@redhat.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).