linux-numa.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] libnuma: disable caching of node cpusmasks
@ 2015-06-12 15:16 Petr Holasek
  2015-06-12 15:30 ` Andi Kleen
  0 siblings, 1 reply; 5+ messages in thread
From: Petr Holasek @ 2015-06-12 15:16 UTC (permalink / raw)
  To: linux-numa; +Cc: Filipe Brandenburger, Cliff Wickman, Petr Holasek

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@redhat.com>
---
 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

^ permalink raw reply related	[flat|nested] 5+ messages in thread

end of thread, other threads:[~2015-06-18 13:48 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2015-06-12 15:16 [PATCH] libnuma: disable caching of node cpusmasks Petr Holasek
2015-06-12 15:30 ` Andi Kleen
2015-06-16 14:40   ` Petr Holasek
2015-06-16 14:48     ` Andi Kleen
2015-06-18 13:48       ` [PATCH] libnuma: don't cache node cpumasks older than 1 second Petr Holasek

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).