Similar to this post, I would like to create a named shared memory segment (created via shm_open()
+ mmap()
on CentOS 7) on a specific NUMA node (not necessarily local). The post suggested that it be achieved by using numa_move_pages()
.
I have few more questions:
if another process (running on a core local to a different NUMA ) later starts and
mmap()
s to the same named shared memory segment, will OS decide to move the named shared memory segment to a NUMA local to this process? If yes, how can I prevent it?Is there any other situation that a named shared memory segment will be moved to another NUMA after I specify through
numa_move_pages()
?Given a named shared memory segment in
/shm/dev
, how can I check which NUMA node it belongs to?
I looked into numactl
, and its --membind
option is closed to what I want, but I am not sure what the effect if two different processes use --membind
to 2 different nodes. Who wins? I guess I can test it out if #3 is answered.
Thanks!
I wan only answer point 1 and 3.
Point 1:
As far as I remember from my teachers and what the this link says: a page on a NUMA machine can be moved closest to the most calling CPU. In other words: if your page is allocated on bank 0 but the CPU that is directly connected to bank 1 is using it much more often, then you page is moved to the bank 1.
Point 3:
Given a named shared memory I don't know how you get the calling numa node, but given a pointer that is in this shared memory you can get its memory policy by calling:
get_mempolicy()
from the man page of
get_mempolicy()
here