Author: Tim Pepper <lnxninja@xxxxxxxxxxxxxxxxxx> Date: Mon Sep 20 13:57:31 2010 -0700 Use numa_max_node() not numa_num_configured_nodes() where appropriate Many users of numa_num_configured_nodes() actually should be using numa_max_node(). The users touched in this patch are call sites which want a highest node number, not a count of nodes with memory. Signed-off-by: Tim Pepper <lnxninja@xxxxxxxxxxxxxxxxxx> --- distance.c | 2 +- libnuma.c | 8 ++++---- numactl.c | 2 +- 3 files changed, 6 insertions(+), 6 deletions(-) diff --git a/distance.c b/distance.c index 4fc69a4..2aad2bb 100755 --- a/distance.c +++ b/distance.c @@ -59,7 +59,7 @@ static int read_distance_table(void) if (!dfh) { if (errno == ENOENT && nd > 0) err = 0; - if (!err && nd<numa_num_configured_nodes()) + if (!err && nd<=numa_max_node()) continue; else break; diff --git a/libnuma.c b/libnuma.c index 5d9a576..39a1bc0 100644 --- a/libnuma.c +++ b/libnuma.c @@ -1257,7 +1257,7 @@ int numa_node_to_cpus_v2(int node, struct bitmask *buffer) { int err = 0, bufferlen; - int nnodes = numa_num_configured_nodes(); + int nnodes = numa_max_node(); char fn[64], *line = NULL; FILE *f; size_t len = 0; @@ -1267,7 +1267,7 @@ numa_node_to_cpus_v2(int node, struct bitmask *buffer) init_node_cpu_mask_v2(); bufferlen = numa_bitmask_nbytes(buffer); - if (node > nnodes-1) { + if (node > nnodes) { errno = ERANGE; return -1; } @@ -1336,8 +1336,8 @@ int numa_node_of_cpu(int cpu) return -1; } bmp = numa_bitmask_alloc(ncpus); - nnodes = numa_num_configured_nodes(); - for (node = 0; node < nnodes; node++){ + nnodes = numa_max_node(); + for (node = 0; node <= nnodes; node++){ numa_node_to_cpus_v2_int(node, bmp); if (numa_bitmask_isbitset(bmp, cpu)){ ret = node; diff --git a/numactl.c b/numactl.c index 170bd86..ce3a482 100755 --- a/numactl.c +++ b/numactl.c @@ -216,7 +216,7 @@ void print_node_cpus(int node) void hardware(void) { int i; - int maxnode = numa_num_configured_nodes()-1; + int maxnode = numa_max_node(); printf("available: %d nodes (0-%d)\n", 1+maxnode, maxnode); for (i = 0; i <= maxnode; i++) { -- To unsubscribe from this list: send the line "unsubscribe linux-numa" in the body of a message to majordomo@xxxxxxxxxxxxxxx More majordomo info at http://vger.kernel.org/majordomo-info.html