* [PATCH] libnuma: add check for return value of numa_node_to_cpus
@ 2015-01-14 8:53 Petr Holasek
2015-01-19 16:44 ` Cliff Wickman
0 siblings, 1 reply; 2+ messages in thread
From: Petr Holasek @ 2015-01-14 8:53 UTC (permalink / raw)
To: linux-numa; +Cc: Cliff Wickman, Petr Holasek
When numa_node_to_cpu() has been called on machine with non-contiguous
nodes, it returned the first node which wasn't present on machine.
Now, return code is checked and code skips over non-existing nodes to
the right one.
Also, caching of numa_node_to_cpus_v2() result while non-zero error had
been returned was disabled.
Signed-off-by: Petr Holasek <pholasek@redhat.com>
---
libnuma.c | 13 ++++++++++---
1 file changed, 10 insertions(+), 3 deletions(-)
diff --git a/libnuma.c b/libnuma.c
index 91425ae..8d7bf13 100644
--- a/libnuma.c
+++ b/libnuma.c
@@ -1382,8 +1382,12 @@ numa_node_to_cpus_v2(int node, struct bitmask *buffer)
if (mask != buffer)
numa_bitmask_free(mask);
} else {
- node_cpu_mask_v2[node] = mask;
- }
+ /* we don't want to cache faulty result */
+ if (!err)
+ node_cpu_mask_v2[node] = mask;
+ else
+ numa_bitmask_free(mask);
+ }
return err;
}
__asm__(".symver numa_node_to_cpus_v2,numa_node_to_cpus@@libnuma_1.2");
@@ -1405,7 +1409,10 @@ int numa_node_of_cpu(int cpu)
bmp = numa_bitmask_alloc(ncpus);
nnodes = numa_max_node();
for (node = 0; node <= nnodes; node++){
- numa_node_to_cpus_v2_int(node, bmp);
+ if (numa_node_to_cpus_v2_int(node, bmp) < 0) {
+ /* It's possible for the node to not exist */
+ continue;
+ }
if (numa_bitmask_isbitset(bmp, cpu)){
ret = node;
goto end;
--
2.1.0
^ permalink raw reply related [flat|nested] 2+ messages in thread
* Re: [PATCH] libnuma: add check for return value of numa_node_to_cpus
2015-01-14 8:53 [PATCH] libnuma: add check for return value of numa_node_to_cpus Petr Holasek
@ 2015-01-19 16:44 ` Cliff Wickman
0 siblings, 0 replies; 2+ messages in thread
From: Cliff Wickman @ 2015-01-19 16:44 UTC (permalink / raw)
To: Petr Holasek; +Cc: linux-numa
Hi Petr,
Thanks for the patch.
Sorry for the delay. I'm getting used to a new work flow for
numactl/libnuma source. (it is also now at https://github.com/numactl/numactl)
I started a new release candidate series for 2.0.11:
ftp://oss.sgi.com/www/projects/libnuma/download/
your patch is in numactl-2.0.11-rc1.tar.gz
Your patch is important for machines with non-contiguos node numbers, and
I don't seem to have a system to test that. So I'm depending on all interested
parties to test it.
-Cliff
On Wed, Jan 14, 2015 at 09:53:47AM +0100, Petr Holasek wrote:
> When numa_node_to_cpu() has been called on machine with non-contiguous
> nodes, it returned the first node which wasn't present on machine.
> Now, return code is checked and code skips over non-existing nodes to
> the right one.
>
> Also, caching of numa_node_to_cpus_v2() result while non-zero error had
> been returned was disabled.
>
> Signed-off-by: Petr Holasek <pholasek@redhat.com>
> ---
> libnuma.c | 13 ++++++++++---
> 1 file changed, 10 insertions(+), 3 deletions(-)
>
> diff --git a/libnuma.c b/libnuma.c
> index 91425ae..8d7bf13 100644
> --- a/libnuma.c
> +++ b/libnuma.c
> @@ -1382,8 +1382,12 @@ numa_node_to_cpus_v2(int node, struct bitmask *buffer)
> if (mask != buffer)
> numa_bitmask_free(mask);
> } else {
> - node_cpu_mask_v2[node] = mask;
> - }
> + /* we don't want to cache faulty result */
> + if (!err)
> + node_cpu_mask_v2[node] = mask;
> + else
> + numa_bitmask_free(mask);
> + }
> return err;
> }
> __asm__(".symver numa_node_to_cpus_v2,numa_node_to_cpus@@libnuma_1.2");
> @@ -1405,7 +1409,10 @@ int numa_node_of_cpu(int cpu)
> bmp = numa_bitmask_alloc(ncpus);
> nnodes = numa_max_node();
> for (node = 0; node <= nnodes; node++){
> - numa_node_to_cpus_v2_int(node, bmp);
> + if (numa_node_to_cpus_v2_int(node, bmp) < 0) {
> + /* It's possible for the node to not exist */
> + continue;
> + }
> if (numa_bitmask_isbitset(bmp, cpu)){
> ret = node;
> goto end;
> --
> 2.1.0
--
Cliff Wickman
SGI
cpw@sgi.com
(651)683-7524 vnet 207524
(651)482-9347 home
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2015-01-19 16:44 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2015-01-14 8:53 [PATCH] libnuma: add check for return value of numa_node_to_cpus Petr Holasek
2015-01-19 16:44 ` Cliff Wickman
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.