From: Petr Holasek <pholasek@redhat.com>
To: linux-numa@vger.kernel.org
Cc: Filipe Brandenburger <filbranden@google.com>,
Cliff Wickman <cpw@sgi.com>, Petr Holasek <pholasek@redhat.com>
Subject: [PATCH] libnuma: disable caching of node cpusmasks
Date: Fri, 12 Jun 2015 17:16:12 +0200 [thread overview]
Message-ID: <1434122172-26560-1-git-send-email-pholasek@redhat.com> (raw)
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
next reply other threads:[~2015-06-12 15:16 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2015-06-12 15:16 Petr Holasek [this message]
2015-06-12 15:30 ` [PATCH] libnuma: disable caching of node cpusmasks 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
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=1434122172-26560-1-git-send-email-pholasek@redhat.com \
--to=pholasek@redhat.com \
--cc=cpw@sgi.com \
--cc=filbranden@google.com \
--cc=linux-numa@vger.kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
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 read-only IMAP folder(s) and NNTP newsgroup(s).