Skip to content

Commit

Permalink
numademo: fix error on 32bit system
Browse files Browse the repository at this point in the history
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 <hongzhi.song@windriver.com>
Signed-off-by: Andi Kleen <ak@linux.intel.com>
  • Loading branch information
Hongzhi.Song authored and Andi Kleen committed Sep 20, 2019
1 parent 034ad86 commit a7c4bc7
Show file tree
Hide file tree
Showing 3 changed files with 4 additions and 4 deletions.
4 changes: 2 additions & 2 deletions libnuma.c
Expand Up @@ -793,10 +793,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;
Expand Down
2 changes: 1 addition & 1 deletion numa.h
Expand Up @@ -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);

Expand Down
2 changes: 1 addition & 1 deletion numademo.c
Expand Up @@ -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));
Expand Down

0 comments on commit a7c4bc7

Please sign in to comment.