GET_MEMPOLICYSection: Linux Programmer's Manual (2)
Index Return to Main Contents
NAMEget_mempolicy - Retrieve NUMA memory policy for a process
int get_mempolicy(int *policy, unsigned long *nodemask, unsigned long maxnode, unsigned long addr, unsigned long flags);
DESCRIPTIONget_mempolicy() retrieves the NUMA policy of the calling process or of a memory address, depending on the setting of flags.
A NUMA machine has different memory controllers with different distances to specific CPUs. The memory policy defines in which node memory is allocated for the process.
If flags is specified as 0, then information about the calling process's default policy (as set by set_mempolicy(2)) is returned.
If flags specifies MPOL_F_ADDR, then information is returned about the policy governing the memory address given in addr. This policy may be different from the process's default policy if set_mempolicy(2) has been used to establish a policy for the page containing addr.
If policy is not NULL, then it is used to return the policy. If nodemask is not NULL, then it is used to return the nodemask associated with the policy. maxnode is the maximum bit number plus one that can be stored into nodemask. The bit number is always rounded to a multiple of unsigned long.
For an overview of the possible policies see set_mempolicy(2).
RETURN VALUEOn success, get_mempolicy() returns 0; on error, -1 is returned and errno is set to indicate the error.
CONFORMING TOThis system call is Linux specific.
NOTESThis manual page is incomplete: it does not document the details the MPOL_F_NODE flag, which modifies the operation of get_mempolicy(). This is deliberate: this flag is not intended for application use, and its operation may change or it may be removed altogether in future kernel versions. Do not use it.
Versions and Library SupportSee mbind(2).
SEE ALSOmbind(2), set_mempolicy(2), numactl(8), numa(3)