sched/topology: introduce node_has_cpus() macro
Subsystems (3)
PATCH 1/2 sched/topology: introduce node_has_cpus() macro
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.
--- include/linux/topology.h | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-)
include/linux/topology.h +3 -1
@@ -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 );
Signature · 1 line
2.34.1
PATCH 2/2 powerpc: use node_has_cpus() instead of nr_cpus_node()
Use node_has_cpus() as more efficient alternative to nr_cpus_node() where possible.
--- arch/powerpc/platforms/cell/spu_priv1_mmio.c | 2 +- arch/powerpc/platforms/cell/spufs/sched.c | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-)
arch/powerpc/platforms/cell/spu_priv1_mmio.c +1 -1
@@ -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));
arch/powerpc/platforms/cell/spufs/sched.c +1 -1
@@ -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))
Signature · 1 line
2.34.1
Re: [PATCH 2/2] powerpc: use node_has_cpus() instead of nr_cpus_node()
Quoted 4 lines · Yury Norov
Use
node_has_cpus()as more efficient alternative tonr_cpus_node()where possible.Signed-off-by Yury Norov <[email protected]>
Quoted 8 lines · Yury Norov
Currently, to check if NUMA node has CPUs, one has to use the
nr_cpus_node()macro, which ends up withcpumask_weight. We can do it better withcpumask_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 <[email protected]>