1GET_MEMPOLICY(2)           Linux Programmer's Manual          GET_MEMPOLICY(2)
2
3
4

NAME

6       get_mempolicy - retrieve NUMA memory policy for a process
7

SYNOPSIS

9       #include <numaif.h>
10
11       int get_mempolicy(int *mode, unsigned long *nodemask,
12                         unsigned long maxnode, unsigned long addr,
13                         unsigned long flags);
14
15       Link with -lnuma.
16

DESCRIPTION

18       get_mempolicy()  retrieves the NUMA policy of the calling process or of
19       a memory address, depending on the setting of flags.
20
21       A NUMA machine has different memory  controllers  with  different  dis‐
22       tances  to  specific  CPUs.   The memory policy defines from which node
23       memory is allocated for the process.
24
25       If flags  is  specified  as  0,  then  information  about  the  calling
26       process's default policy (as set by set_mempolicy(2)) is returned.  The
27       policy returned  [mode  and  nodemask]  may  be  used  to  restore  the
28       process's  policy  to  its state at the time of the call to get_mempol‐
29       icy() using set_mempolicy(2).
30
31       If flags specifies MPOL_F_MEMS_ALLOWED (available since Linux  2.6.24),
32       the  mode  argument is ignored and the set of nodes [memories] that the
33       process is allowed to  specify  in  subsequent  calls  to  mbind(2)  or
34       set_mempolicy(2)  [in  the  absence  of  any mode flags] is returned in
35       nodemask.  It is not  permitted  to  combine  MPOL_F_MEMS_ALLOWED  with
36       either MPOL_F_ADDR or MPOL_F_NODE.
37
38       If  flags specifies MPOL_F_ADDR, then information is returned about the
39       policy governing the memory address given in addr.  This policy may  be
40       different  from  the process's default policy if mbind(2) or one of the
41       helper functions described in numa(3) has been used to establish a pol‐
42       icy for the memory range containing addr.
43
44       If  the  mode argument is not NULL, then get_mempolicy() will store the
45       policy mode and any optional mode flags of the requested NUMA policy in
46       the  location  pointed  to  by this argument.  If nodemask is not NULL,
47       then the nodemask associated with the policy  will  be  stored  in  the
48       location  pointed to by this argument.  maxnode specifies the number of
49       node IDs that can be stored into nodemask—that is, the maximum node  ID
50       plus one.  The value specified by maxnode is always rounded to a multi‐
51       ple of sizeof(unsigned long).
52
53       If flags specifies both MPOL_F_NODE  and  MPOL_F_ADDR,  get_mempolicy()
54       will  return the node ID of the node on which the address addr is allo‐
55       cated into the location pointed to by mode.  If no page  has  yet  been
56       allocated  for  the  specified address, get_mempolicy() will allocate a
57       page as if the process had performed  a  read  [load]  access  to  that
58       address, and return the ID of the node where that page was allocated.
59
60       If  flags specifies MPOL_F_NODE, but not MPOL_F_ADDR, and the process's
61       current policy is MPOL_INTERLEAVE, then get_mempolicy() will return  in
62       the location pointed to by a non-NULL mode argument, the node ID of the
63       next node that will be used for interleaving of internal  kernel  pages
64       allocated  on  behalf  of the process.  These allocations include pages
65       for memory mapped files in  process  memory  ranges  mapped  using  the
66       mmap(2) call with the MAP_PRIVATE flag for read accesses, and in memory
67       ranges mapped with the MAP_SHARED flag for all accesses.
68
69       Other flag values are reserved.
70
71       For an overview of the possible policies see set_mempolicy(2).
72

RETURN VALUE

74       On success, get_mempolicy() returns 0; on error,  -1  is  returned  and
75       errno is set to indicate the error.
76

ERRORS

78       EFAULT Part  of all of the memory range specified by nodemask and maxn‐
79              ode points outside your accessible address space.
80
81       EINVAL The value specified by maxnode is less than the number  of  node
82              IDs  supported  by  the system.  Or flags specified values other
83              than MPOL_F_NODE or MPOL_F_ADDR; or flags specified  MPOL_F_ADDR
84              and  addr is NULL, or flags did not specify MPOL_F_ADDR and addr
85              is  not  NULL.   Or,  flags  specified   MPOL_F_NODE   but   not
86              MPOL_F_ADDR  and  the  current process policy is not MPOL_INTER‐
87              LEAVE.  Or,  flags  specified  MPOL_F_MEMS_ALLOWED  with  either
88              MPOL_F_ADDR or MPOL_F_NODE.  (And there are other EINVAL cases.)
89

VERSIONS

91       The  get_mempolicy()  system call was added to the Linux kernel in ver‐
92       sion 2.6.7.
93

CONFORMING TO

95       This system call is Linux-specific.
96

NOTES

98       For information on library support, see numa(7).
99

SEE ALSO

101       getcpu(2),  mbind(2),  mmap(2),  set_mempolicy(2),  numa(3),   numa(7),
102       numactl(8)
103

COLOPHON

105       This  page  is  part of release 3.53 of the Linux man-pages project.  A
106       description of the project, and information about reporting  bugs,  can
107       be found at http://www.kernel.org/doc/man-pages/.
108
109
110
111Linux                             2008-08-15                  GET_MEMPOLICY(2)
Impressum