Caching of node cpumasks confuses long-time running tasks like libvirtd. If there was an offlined/onlined cpu between two numa_node_to_cpus() calls, libnuma still returns the same cpumask as before. Signed-off-by: Petr Holasek <pholasek@xxxxxxxxxx> --- libnuma.c | 36 ++---------------------------------- 1 file changed, 2 insertions(+), 34 deletions(-) diff --git a/libnuma.c b/libnuma.c index 3717d5b..7bd5f76 100644 --- a/libnuma.c +++ b/libnuma.c @@ -58,7 +58,6 @@ struct bitmask *numa_possible_cpus_ptr = NULL; struct bitmask *numa_nodes_ptr = NULL; static struct bitmask *numa_memnode_ptr = NULL; static unsigned long *node_cpu_mask_v1[NUMA_NUM_NODES]; -static struct bitmask **node_cpu_mask_v2; WEAK void numa_error(char *where); @@ -1233,13 +1232,6 @@ numa_parse_bitmap_v2(char *line, struct bitmask *mask) } __asm__(".symver numa_parse_bitmap_v2,numa_parse_bitmap@@libnuma_1.2"); -void -static init_node_cpu_mask_v2(void) -{ - int nnodes = numa_max_possible_node_v2_int() + 1; - node_cpu_mask_v2 = calloc (nnodes, sizeof(struct bitmask *)); -} - /* This would be better with some locking, but I don't want to make libnuma dependent on pthreads right now. The races are relatively harmless. */ int @@ -1329,25 +1321,12 @@ numa_node_to_cpus_v2(int node, struct bitmask *buffer) size_t len = 0; struct bitmask *mask; - if (!node_cpu_mask_v2) - init_node_cpu_mask_v2(); - if (node > nnodes) { errno = ERANGE; return -1; } numa_bitmask_clearall(buffer); - if (node_cpu_mask_v2[node]) { - /* have already constructed a mask for this node */ - if (buffer->size < node_cpu_mask_v2[node]->size) { - numa_error("map size mismatch; abort\n"); - return -1; - } - copy_bitmask_to_bitmask(node_cpu_mask_v2[node], buffer); - return 0; - } - /* need a new mask for this node */ mask = numa_allocate_cpumask(); @@ -1375,19 +1354,8 @@ numa_node_to_cpus_v2(int node, struct bitmask *buffer) free(line); copy_bitmask_to_bitmask(mask, buffer); - /* slightly racy, see above */ - /* save the mask we created */ - if (node_cpu_mask_v2[node]) { - /* how could this be? */ - if (mask != buffer) - numa_bitmask_free(mask); - } else { - /* we don't want to cache faulty result */ - if (!err) - node_cpu_mask_v2[node] = mask; - else - numa_bitmask_free(mask); - } + numa_bitmask_free(mask); + return err; } __asm__(".symver numa_node_to_cpus_v2,numa_node_to_cpus@@libnuma_1.2"); -- 2.4.3 -- 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