According to the mbind man page
, one possible mode
is MPOL_LOCAL
, which places the memory region in the same node of the CPU that triggered the allocation:
#include <numaif.h>
#include <stdio.h>
#include <stdlib.h>
#include <stdint.h>
#define N 134217728
int main() {
uint64_t *a = (uint64_t*) malloc(N*sizeof(uint64_t));
mbind(a, N, MPOL_LOCAL, 0, 0, MPOL_MF_STRICT | MPOL_MF_MOVE);
printf("Hello world!\n");
return 0;
}
However, the symbol is simply not defined.
$ gcc-8 -lnuma example.c
example.c: In function ‘main’:
example.c:10:14: error: ‘MPOL_LOCAL’ undeclared (first use in this function); did you mean ‘MPOL_MAX’?
mbind(a, N, MPOL_LOCAL, 0, 0, MPOL_MF_STRICT | MPOL_MF_MOVE);
^~~~~~~~~~
MPOL_MAX
example.c:10:14: note: each undeclared identifier is reported only once for each function it appears in
Changing to e.g. MPOL_INTERLEAVE
makes it compile and display Hello world!
just fine.
What's going on here? At this stage I'm 100% puzzled.
I've tried with gcc
/g++
4.9.2, 5 and 8; in three different machines running the kernels 4.17.12+
(no idea where it came from), 4.18.10
(compiled myself) and 4.15.0
(included in latest Linux Mint). libnuma-dev
is up to date.