|
|
20c42d |
From 32075635db57c3d5efe12f8fb569af857e01ccad Mon Sep 17 00:00:00 2001
|
|
|
20c42d |
From: Petr Holasek <pholasek@redhat.com>
|
|
|
20c42d |
Date: Wed, 14 Jan 2015 09:53:47 +0100
|
|
|
20c42d |
Subject: [PATCH] libnuma: add check for return value of numa_node_to_cpus
|
|
|
20c42d |
|
|
|
20c42d |
When numa_node_to_cpu() has been called on machine with non-contiguous
|
|
|
20c42d |
nodes, it returned the first node which wasn't present on machine.
|
|
|
20c42d |
Now, return code is checked and code skips over non-existing nodes to
|
|
|
20c42d |
the right one.
|
|
|
20c42d |
|
|
|
20c42d |
Also, caching of numa_node_to_cpus_v2() result while non-zero error had
|
|
|
20c42d |
been returned was disabled.
|
|
|
20c42d |
|
|
|
20c42d |
Signed-off-by: Petr Holasek <pholasek@redhat.com>
|
|
|
20c42d |
|
|
|
20c42d |
Tested by Cliff Wickman (on attica.sgi.com)
|
|
|
20c42d |
---
|
|
|
20c42d |
libnuma.c | 13 ++++++++++---
|
|
|
20c42d |
1 file changed, 10 insertions(+), 3 deletions(-)
|
|
|
20c42d |
|
|
|
20c42d |
diff -up numactl-2.0.9/libnuma.c.orig numactl-2.0.9/libnuma.c
|
|
|
20c42d |
--- numactl-2.0.9/libnuma.c.orig 2013-10-08 23:34:57.000000000 +0200
|
|
|
20c42d |
+++ numactl-2.0.9/libnuma.c 2015-07-01 15:14:44.937178134 +0200
|
|
|
20c42d |
@@ -1380,8 +1380,12 @@ numa_node_to_cpus_v2(int node, struct bi
|
|
|
20c42d |
if (mask != buffer)
|
|
|
20c42d |
numa_bitmask_free(mask);
|
|
|
20c42d |
} else {
|
|
|
20c42d |
- node_cpu_mask_v2[node] = mask;
|
|
|
20c42d |
- }
|
|
|
20c42d |
+ /* we don't want to cache faulty result */
|
|
|
20c42d |
+ if (!err)
|
|
|
20c42d |
+ node_cpu_mask_v2[node] = mask;
|
|
|
20c42d |
+ else
|
|
|
20c42d |
+ numa_bitmask_free(mask);
|
|
|
20c42d |
+ }
|
|
|
20c42d |
return err;
|
|
|
20c42d |
}
|
|
|
20c42d |
__asm__(".symver numa_node_to_cpus_v2,numa_node_to_cpus@@libnuma_1.2");
|
|
|
20c42d |
@@ -1403,7 +1407,10 @@ int numa_node_of_cpu(int cpu)
|
|
|
20c42d |
bmp = numa_bitmask_alloc(ncpus);
|
|
|
20c42d |
nnodes = numa_max_node();
|
|
|
20c42d |
for (node = 0; node <= nnodes; node++){
|
|
|
20c42d |
- numa_node_to_cpus_v2_int(node, bmp);
|
|
|
20c42d |
+ if (numa_node_to_cpus_v2_int(node, bmp) < 0) {
|
|
|
20c42d |
+ /* It's possible for the node to not exist */
|
|
|
20c42d |
+ continue;
|
|
|
20c42d |
+ }
|
|
|
20c42d |
if (numa_bitmask_isbitset(bmp, cpu)){
|
|
|
20c42d |
ret = node;
|
|
|
20c42d |
goto end;
|