There are few ways to implement given that I assume that you are unable to change the program.
Implement what NUMA policy would achieve by in userspace. It is possible to move pages for a process between different NUMA nodes. See migratepages. I'd imagine you'd have to run this once in a while.
Otherwise, you can attach via gdb and set the policy. Note, I am not 100% certain if this will affect pages already allocated. You might have to run migratepages before this step.
Create a function that sets your preferred numa policy:
inject.c
#include "inject.h"
void inject(){
printf("Changing memory policy\n");
unsigned long nodemask = 1L << 1;
set_mempolicy(MPOL_PREFERRED, &nodemask, 3);
}
inject.h
#include <stdio.h>
#include <numaif.h>
extern void inject();
libinject.so
gcc -c -Wall -Werror -lnuma -fPIC inject.c
gcc -shared -o libinject.so inject.o -lnuma
** Attach to pid and call the function you have defined **
gdb -p pid
(gdb) call __libc_dlopen_mode("/path_to/libinject.so", 0x0002)
(gdb) call inject()
I have verified that I am able to change numa policy via /proc/pid/numa_maps ( changed from default to prefer:1 ) but I am not too familiar with numa to say that change is effective.
Please note that this is invasive process and hopefully there is a simpler alternative.