* [PATCH 1/2] sched/topology: introduce node_has_cpus() macro
@ 2023-02-22 2:50 Yury Norov
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 ` [PATCH 1/2] sched/topology: introduce node_has_cpus() macro Valentin Schneider
0 siblings, 2 replies; 4+ messages in thread
From: Yury Norov @ 2023-02-22 2:50 UTC (permalink / raw)
To: linuxppc-dev, linux-kernel
Cc: Valentin Schneider, Yury Norov, Arnd Bergmann, Barry Song,
Nicholas Piggin, Jakub Kicinski, Dietmar Eggemann, Jeremy Kerr
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
^ permalink raw reply related [flat|nested] 4+ messages in thread
* [PATCH 2/2] powerpc: use node_has_cpus() instead of nr_cpus_node()
2023-02-22 2:50 [PATCH 1/2] sched/topology: introduce node_has_cpus() macro Yury Norov
@ 2023-02-22 2:50 ` 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
1 sibling, 1 reply; 4+ messages in thread
From: Yury Norov @ 2023-02-22 2:50 UTC (permalink / raw)
To: linuxppc-dev, linux-kernel
Cc: Valentin Schneider, Yury Norov, Arnd Bergmann, Barry Song,
Nicholas Piggin, Jakub Kicinski, Dietmar Eggemann, Jeremy Kerr
Use node_has_cpus() as more efficient alternative to nr_cpus_node()
where possible.
Signed-off-by: Yury Norov <yury.norov@gmail.com>
---
arch/powerpc/platforms/cell/spu_priv1_mmio.c | 2 +-
arch/powerpc/platforms/cell/spufs/sched.c | 2 +-
2 files changed, 2 insertions(+), 2 deletions(-)
diff --git a/arch/powerpc/platforms/cell/spu_priv1_mmio.c b/arch/powerpc/platforms/cell/spu_priv1_mmio.c
index d150e3987304..55b5024b256b 100644
--- a/arch/powerpc/platforms/cell/spu_priv1_mmio.c
+++ b/arch/powerpc/platforms/cell/spu_priv1_mmio.c
@@ -64,7 +64,7 @@ static void cpu_affinity_set(struct spu *spu, int cpu)
u64 target;
u64 route;
- if (nr_cpus_node(spu->node)) {
+ if (node_has_cpus(spu->node)) {
const struct cpumask *spumask = cpumask_of_node(spu->node),
*cpumask = cpumask_of_node(cpu_to_node(cpu));
diff --git a/arch/powerpc/platforms/cell/spufs/sched.c b/arch/powerpc/platforms/cell/spufs/sched.c
index 99bd027a7f7c..9d29cc2c6bcb 100644
--- a/arch/powerpc/platforms/cell/spufs/sched.c
+++ b/arch/powerpc/platforms/cell/spufs/sched.c
@@ -154,7 +154,7 @@ void spu_update_sched_info(struct spu_context *ctx)
static int __node_allowed(struct spu_context *ctx, int node)
{
- if (nr_cpus_node(node)) {
+ if (node_has_cpus(node)) {
const struct cpumask *mask = cpumask_of_node(node);
if (cpumask_intersects(mask, &ctx->cpus_allowed))
--
2.34.1
^ permalink raw reply related [flat|nested] 4+ messages in thread
* Re: [PATCH 1/2] sched/topology: introduce node_has_cpus() macro
2023-02-22 2:50 [PATCH 1/2] sched/topology: introduce node_has_cpus() macro Yury Norov
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
1 sibling, 0 replies; 4+ messages in thread
From: Valentin Schneider @ 2023-03-15 16:48 UTC (permalink / raw)
To: Yury Norov, linuxppc-dev, linux-kernel
Cc: Barry Song, Yury Norov, Arnd Bergmann, Nicholas Piggin,
Jakub Kicinski, Dietmar Eggemann, Jeremy Kerr
On 21/02/23 18:50, Yury Norov wrote:
> 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>
Reviewed-by: Valentin Schneider <vschneid@redhat.com>
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [PATCH 2/2] powerpc: use node_has_cpus() instead of nr_cpus_node()
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
0 siblings, 0 replies; 4+ messages in thread
From: Valentin Schneider @ 2023-03-15 16:48 UTC (permalink / raw)
To: Yury Norov, linuxppc-dev, linux-kernel
Cc: Barry Song, Yury Norov, Arnd Bergmann, Nicholas Piggin,
Jakub Kicinski, Dietmar Eggemann, Jeremy Kerr
On 21/02/23 18:50, Yury Norov wrote:
> Use node_has_cpus() as more efficient alternative to nr_cpus_node()
> where possible.
>
> Signed-off-by: Yury Norov <yury.norov@gmail.com>
Reviewed-by: Valentin Schneider <vschneid@redhat.com>
^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~2023-03-15 16:50 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2023-02-22 2:50 [PATCH 1/2] sched/topology: introduce node_has_cpus() macro Yury Norov
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
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).