get_mempolicy(2) System Calls Manual get_mempolicy(2) get_mempolicy - NUMA NUMA (Non-Uniform Memory Access) policy library (libnuma, -lnuma) #include long get_mempolicy(unsigned long maxnode; int *mode, unsigned long nodemask[(maxnode + ULONG_WIDTH - 1) / ULONG_WIDTH], unsigned long maxnode, void *addr, unsigned long flags); get_mempolicy() NUMA ( flags). NUMA . , . flags 0, , mode nodemask, ( set_mempolicy(2)). get_mempolicy() set_mempolicy(2). flags 0, addr NULL. flags MPOL_F_MEMS_ALLOWED (, Linux 2.6.24), mode ( ), mbind(2) set_mempolicy(2) ( ), nodemask. MPOL_F_MEMS_ALLOWED MPOL_F_ADDR MPOL_F_NODE. flags MPOL_F_ADDR, , addr. , mbind(2) , numa(3), , addr. If the mode argument is not NULL, then get_mempolicy() will store the policy mode and any optional mode flags of the requested NUMA policy in the location pointed to by this argument. If nodemask is not NULL, then the nodemask associated with the policy will be stored in the location pointed to by this argument. maxnode specifies the number of node IDs that can be stored into nodemask--that is, the maximum node ID plus one. The value specified by maxnode is always rounded to a multiple of sizeof(unsigned long)*8. flags MPOL_F_NODE MPOL_F_ADDR, get_mempolicy() , addr , mode. , get_mempolicy() , () , , . If flags specifies MPOL_F_NODE, but not MPOL_F_ADDR, and the thread's current policy is MPOL_INTERLEAVE or MPOL_WEIGHTED_INTERLEAVE, then get_mempolicy() will return in the location pointed to by a non-NULL mode argument, the node ID of the next node that will be used for interleaving of internal kernel pages allocated on behalf of the thread. These allocations include pages for memory-mapped files in process memory ranges mapped using the mmap(2) call with the MAP_PRIVATE flag for read accesses, and in memory ranges mapped with the MAP_SHARED flag for all accesses. . set_mempolicy(2). get_mempolicy() 0; -- -1, errno . EFAULT , nodemask maxnode, . EINVAL The value specified by maxnode is less than the number of node IDs supported by the system. Or flags specified values other than MPOL_F_NODE or MPOL_F_ADDR; or flags specified MPOL_F_ADDR and addr is NULL, or flags did not specify MPOL_F_ADDR and addr is not NULL. Or, flags specified MPOL_F_NODE but not MPOL_F_ADDR and the current thread policy is neither MPOL_INTERLEAVE nor MPOL_WEIGHTED_INTERLEAVE. Or, flags specified MPOL_F_MEMS_ALLOWED with either MPOL_F_ADDR or MPOL_F_NODE. (And there are other EINVAL cases.) Linux. Linux 2.6.7. numa(7). getcpu(2), mbind(2), mmap(2), set_mempolicy(2), numa(3), numa(7), numactl(8) () Azamat Hackimov , Dmitry Bolkhovskikh , Vladislav , Yuri Kozlov , Kirill Rekhov ; GNU (GNU General Public License - GPL, 3 ) , - . - , , () () () <>. Linux 6.15 28 2025 . get_mempolicy(2)