Fix CPUless nodes numactl --hardware output A typical setup on IA64 in some kind of interleaved is to expose all memory in one node while other nodes hold the CPUs and have no memory. The introduction of nodes_allowed_list in version 2.0.3 which checks for nodes without memory and the usage in numactl.c (--hardware) to only show nodes with memory is wrong. Also the libnuma variable numa_all_nodes_ptr is named suspicious. It's not all nodes, but all nodes with memory. But this naming is in there even before 2.0.2. But numactl --hardware must not check for it as the memoryless nodes also have to be printed. This patch reverts this change. Broken output (2 nodes hold CPUs and have no memory, one node has no CPUs, but the memory): available: 1 nodes (2) node 2 size: 32623 MB node 2 free: 20848 MB node distances: node 0 1 2 0: 0 0 10 1: 20 20 20 2: 10 20 20 Output with 2.0.2 or 2.0.3 with this patch: available: 3 nodes (0-2) node 0 cpus: 0 1 2 3 4 5 6 7 node 0 size: 0 MB node 0 free: 0 MB node 1 cpus: 8 9 10 11 12 13 14 15 node 1 size: 0 MB node 1 free: 0 MB node 2 cpus: node 2 size: 32623 MB node 2 free: 20842 MB node distances: node 0 1 2 0: 0 0 10 1: 20 20 20 2: 10 20 20 Signed-off-by: Thomas Renninger <trenn@xxxxxxx> --- libnuma.c | 8 -------- numactl.c | 17 ++++------------- 2 files changed, 4 insertions(+), 21 deletions(-) Index: numactl-2.0.3/numactl.c =================================================================== --- numactl-2.0.3.orig/numactl.c +++ numactl-2.0.3/numactl.c @@ -206,33 +206,24 @@ void print_node_cpus(int node) cpus = numa_bitmask_alloc(conf_cpus); err = numa_node_to_cpus(node, cpus); - if (err >= 0) + if (err >= 0) { for (i = 0; i < conf_cpus; i++) if (numa_bitmask_isbitset(cpus, i)) printf(" %d", i); + } putchar('\n'); } void hardware(void) { - int i, numconfigurednodes=0; + int i; int maxnode = numa_num_configured_nodes()-1; - for (i = 0; i<=maxnode; i++) - if (numa_bitmask_isbitset(numa_all_nodes_ptr, i)) - numconfigurednodes++; - if (nodes_allowed_list) - printf("available: %d nodes (%s)\n", - numconfigurednodes, nodes_allowed_list); - else - printf("available: %d nodes (0-%d)\n", maxnode+1, maxnode); - + printf("available: %d nodes (0-%d)\n", 1+maxnode, maxnode); for (i = 0; i <= maxnode; i++) { char buf[64]; long long fr; unsigned long long sz = numa_node_size64(i, &fr); - if (!numa_bitmask_isbitset(numa_all_nodes_ptr, i)) - continue; printf("node %d cpus:", i); print_node_cpus(i); Index: numactl-2.0.3/libnuma.c =================================================================== --- numactl-2.0.3.orig/libnuma.c +++ numactl-2.0.3/libnuma.c @@ -54,8 +54,6 @@ struct bitmask *numa_all_cpus_ptr = NULL static unsigned long *node_cpu_mask_v1[NUMA_NUM_NODES]; struct bitmask **node_cpu_mask_v2; -char *nodes_allowed_list = NULL; - WEAK void numa_error(char *where); #ifdef __thread @@ -460,12 +458,6 @@ set_thread_constraints(void) maxprocnode = read_mask(mask, numa_all_nodes_ptr); } - if (strncmp(buffer,"Mems_allowed_list:",18) == 0) { - nodes_allowed_list = malloc(strlen(buffer)-18); - strncpy(nodes_allowed_list, buffer + 19, - strlen(buffer) - 19); - nodes_allowed_list[strlen(nodes_allowed_list)-1] = '\0'; - } } fclose(f); free(buffer); -- 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