2019-09-20 14:35:24

by Hongzhi, Song

[permalink] [raw]
Subject: [PATCH] numademo: fix error on 32bit system

Error Info on 32bit:
root@intel-x86:~# numademo -t -e 1M
Configured Nodes does not match available memory nodes

That's because sizeof(long)=4Word, but sizeof(long long)=8Word
on 32bit. So (long long) assigning to (long) maybe cause overflow.

long numa_node_size(int node, long *freep)
{
...
long sz = numa_node_size64_int(node, &f2);
return sz;
...
}
long long numa_node_size64(int node, long long *freep)
{
...
}

Signed-off-by: Hongzhi.Song <[email protected]>
---
libnuma.c | 4 ++--
numa.h | 2 +-
numademo.c | 2 +-
3 files changed, 4 insertions(+), 4 deletions(-)

diff --git a/libnuma.c b/libnuma.c
index cac8851..8b5c6aa 100644
--- a/libnuma.c
+++ b/libnuma.c
@@ -791,10 +791,10 @@ long long numa_node_size64(int node, long long *freep)

make_internal_alias(numa_node_size64);

-long numa_node_size(int node, long *freep)
+long long numa_node_size(int node, long long *freep)
{
long long f2;
- long sz = numa_node_size64_int(node, &f2);
+ long long sz = numa_node_size64_int(node, &f2);
if (freep)
*freep = f2;
return sz;
diff --git a/numa.h b/numa.h
index 3a8c543..268fb1d 100644
--- a/numa.h
+++ b/numa.h
@@ -143,7 +143,7 @@ int numa_preferred(void);

/* Return node size and free memory */
long long numa_node_size64(int node, long long *freep);
-long numa_node_size(int node, long *freep);
+long long numa_node_size(int node, long long *freep);

int numa_pagesize(void);

diff --git a/numademo.c b/numademo.c
index a720db0..8c56da8 100644
--- a/numademo.c
+++ b/numademo.c
@@ -301,7 +301,7 @@ int max_node, numnodes;
int get_node_list(void)
{
int a, got_nodes = 0;
- long free_node_sizes;
+ long long free_node_sizes;

numnodes = numa_num_configured_nodes();
node_to_use = (int *)malloc(numnodes * sizeof(int));
--
2.23.0


2019-09-22 19:10:50

by Andi Kleen

[permalink] [raw]
Subject: Re: [PATCH] numademo: fix error on 32bit system

On Thu, Sep 19, 2019 at 07:34:33PM -0700, Hongzhi.Song wrote:
> Error Info on 32bit:
> root@intel-x86:~# numademo -t -e 1M
> Configured Nodes does not match available memory nodes

Added thanks.

-Andi

2019-09-22 19:22:39

by Filipe Brandenburger

[permalink] [raw]
Subject: Re: [PATCH] numademo: fix error on 32bit system

This commit broke the build under -Werror=incompatible-pointer-types.

https://travis-ci.org/numactl/numactl/jobs/587708062

Can you two take a look and see if you can figure out a fix for it?
(Sorry, in a conference so didn't have time to dig deeper into it.)

I'll suggest in the future using Pull Requests on GitHub, since then
we have the result from Travis-CI on the PR before deciding to merge
it...

Cheers!
Filipe

On Sat, Sep 21, 2019 at 2:00 AM Andi Kleen <[email protected]> wrote:
>
> On Thu, Sep 19, 2019 at 07:34:33PM -0700, Hongzhi.Song wrote:
> > Error Info on 32bit:
> > root@intel-x86:~# numademo -t -e 1M
> > Configured Nodes does not match available memory nodes
>
> Added thanks.
>
> -Andi

2019-09-24 16:43:01

by Hongzhi, Song

[permalink] [raw]
Subject: Re: [PATCH] numademo: fix error on 32bit system


On 9/22/19 7:04 AM, Filipe Brandenburger wrote:
> This commit broke the build under -Werror=incompatible-pointer-types.


I am working on it.


>
> https://travis-ci.org/numactl/numactl/jobs/587708062
>
> Can you two take a look and see if you can figure out a fix for it?
> (Sorry, in a conference so didn't have time to dig deeper into it.)
>
> I'll suggest in the future using Pull Requests on GitHub, since then
> we have the result from Travis-CI on the PR before deciding to merge
> it...


ok, thanks.

--Hongzhi


>
> Cheers!
> Filipe
>
> On Sat, Sep 21, 2019 at 2:00 AM Andi Kleen <[email protected]> wrote:
>> On Thu, Sep 19, 2019 at 07:34:33PM -0700, Hongzhi.Song wrote:
>>> Error Info on 32bit:
>>> root@intel-x86:~# numademo -t -e 1M
>>> Configured Nodes does not match available memory nodes
>> Added thanks.
>>
>> -Andi