In C, Migrate memory to a NUMA node

487 views Asked by At

I am developing a NUMA application and I need to migrate big arrays from a node (the node where they are actually created) to another node.

I can't use the numa_alloc_onnode() function because I need to have shared memory between the process who allocates memory and its child.

The situation is the following:

I have this array (which dimension is equal to the number of NUMA nodes) of (BIG) node* array, where node* is a typedef of a struct:

node** overall_trees;

i-th node* array have to be in the i-th NUMA node.

What I have done is:

overall_trees[i] = mmap(NULL,(1+number_of_nodes)*sizeof(node), PROT_READ | PROT_WRITE, MAP_SHARED | MAP_ANONYMOUS, -1, 0);
numa_move_pages(0, (int) (1+number_of_nodes)*sizeof(node) / PAGE_SIZE, &overall_trees[i],  &i, &status, MPOL_MF_MOVE);

but numa_move_pages() returns -1.

Actually this is the first time in which I am dealing with NUMA allocation and maybe what I am trying to do is totally wrong. If a completely different solution is possible, feel free to expose it.

Thank you

0

There are 0 answers