1 .\" Copyright 2003,2004 Andi Kleen, SuSE Labs.
2 .\" and Copyright 2007 Lee Schermerhorn, Hewlett Packard
4 .\" Permission is granted to make and distribute verbatim copies of this
5 .\" manual provided the copyright notice and this permission notice are
6 .\" preserved on all copies.
8 .\" Permission is granted to copy and distribute modified versions of this
9 .\" manual under the conditions for verbatim copying, provided that the
10 .\" entire resulting derived work is distributed under the terms of a
11 .\" permission notice identical to this one.
13 .\" Since the Linux kernel and libraries are constantly changing, this
14 .\" manual page may be incorrect or out-of-date. The author(s) assume no
15 .\" responsibility for errors or omissions, or for damages resulting from
16 .\" the use of the information contained herein.
18 .\" Formatted or processed versions of this manual, if unaccompanied by
19 .\" the source, must acknowledge the copyright and authors of this work.
21 .\" 2006-02-03, mtk, substantial wording changes and other improvements
22 .\" 2007-08-27, Lee Schermerhorn <Lee.Schermerhorn@hp.com>
23 .\" more precise specification of behavior.
25 .TH GET_MEMPOLICY 2 2007-08-27 Linux "Linux Programmer's Manual"
27 get_mempolicy \- Retrieve NUMA memory policy for a process
29 .B "#include <numaif.h>"
32 .BI "int get_mempolicy(int *" mode ", unsigned long *" nodemask ,
33 .BI " unsigned long " maxnode ", unsigned long " addr ,
34 .BI " unsigned long " flags );
36 Link with \fI\-lnuma\fP
40 retrieves the NUMA policy of the calling process or of a memory address,
41 depending on the setting of
44 A NUMA machine has different
45 memory controllers with different distances to specific CPUs.
46 The memory policy defines from which node memory is allocated for
52 then information about the calling process's default policy
54 .BR set_mempolicy (2))
61 then information is returned about the policy governing the memory
64 This policy may be different from the process's default policy if
66 or one of the helper functions described in
68 has been used to establish a policy for the memory range containing
73 argument is not NULL, then
75 will store the policy mode of the requested NUMA policy in the location
76 pointed to by this argument.
79 is not NULL, then the nodemask associated with the policy will be stored
80 in the location pointed to by this argument.
82 specifies the number of node IDs
83 that can be stored into
85 is, the maximum node ID plus one.
86 The value specified by
88 is always rounded to a multiple of
89 .IR "sizeof(unsigned long)" .
98 will return the node ID of the node on which the address
100 is allocated into the location pointed to by
102 If no page has yet been allocated for the specified address,
104 will allocate a page as if the process had performed a read
105 [load] access to that address, and return the ID of the node
106 where that page was allocated.
114 and the process's current policy is
115 .BR MPOL_INTERLEAVE ,
118 will return in the location pointed to by a non-NULL
121 the node ID of the next node that will be used for
122 interleaving of internal kernel pages allocated on behalf of the process.
123 .\" Note: code returns next interleave node via 'mode' argument -Lee Schermerhorn
124 These allocations include pages for memory mapped files in
125 process memory ranges mapped using the
129 flag for read accesses, and in memory ranges mapped with the
131 flag for all accesses.
133 Other flag values are reserved.
135 For an overview of the possible policies see
136 .BR set_mempolicy (2).
141 on error, \-1 is returned and
143 is set to indicate the error.
147 The value specified by
149 is less than the number of node IDs supported by the system.
152 specified values other than
176 and the current process policy is not
177 .BR MPOL_INTERLEAVE .
178 (And there are other EINVAL cases.)
181 Part of all of the memory range specified by
185 points outside your accessible address space.
187 If the mode of the process policy or the policy governing allocations at the
190 and this policy was installed with an empty
191 .IR nodemask \(emspecifying
194 will return the mask of on-line node IDs in the location pointed to by
198 This mask does not take into consideration any adminstratively imposed
199 restrictions on the process's context.
201 .\" "context" above refers to cpusets.
202 .\" No man page to reference. --Lee Schermerhorn
204 .\" Christoph says the following is untrue. These are "fully supported."
205 .\" Andi concedes that he has lost this battle and approves [?]
206 .\" updating the man pages to document the behavior. --Lee Schermerhorn
207 .\" This manual page is incomplete:
208 .\" it does not document the details the
211 .\" which modifies the operation of
212 .\" .BR get_mempolicy ().
213 .\" This is deliberate: this flag is not intended for application use,
214 .\" and its operation may change or it may be removed altogether in
215 .\" future kernel versions.
216 .\" .B Do not use it.
217 .SS "Versions and Library Support"
223 .BR set_mempolicy (2),