1 .\" Copyright 2003,2004 Andi Kleen, SuSE Labs.
2 .\" and Copyright 2007 Lee Schermerhorn, Hewlett Packard
4 .\" %%%LICENSE_START(VERBATIM_PROF)
5 .\" Permission is granted to make and distribute verbatim copies of this
6 .\" manual provided the copyright notice and this permission notice are
7 .\" preserved on all copies.
9 .\" Permission is granted to copy and distribute modified versions of this
10 .\" manual under the conditions for verbatim copying, provided that the
11 .\" entire resulting derived work is distributed under the terms of a
12 .\" permission notice identical to this one.
14 .\" Since the Linux kernel and libraries are constantly changing, this
15 .\" manual page may be incorrect or out-of-date. The author(s) assume no
16 .\" responsibility for errors or omissions, or for damages resulting from
17 .\" the use of the information contained herein.
19 .\" Formatted or processed versions of this manual, if unaccompanied by
20 .\" the source, must acknowledge the copyright and authors of this work.
23 .\" 2006-02-03, mtk, substantial wording changes and other improvements
24 .\" 2007-08-27, Lee Schermerhorn <Lee.Schermerhorn@hp.com>
25 .\" more precise specification of behavior.
27 .TH GET_MEMPOLICY 2 2021-03-22 Linux "Linux Programmer's Manual"
29 get_mempolicy \- retrieve NUMA memory policy for a thread
31 .B "#include <numaif.h>"
34 .BI "long get_mempolicy(int *" mode ", unsigned long *" nodemask ,
35 .BI " unsigned long " maxnode ", void *" addr ,
36 .BI " unsigned long " flags );
38 Link with \fI\-lnuma\fP.
42 There is no glibc wrapper for this system call; see NOTES.
45 retrieves the NUMA policy of the calling thread or of a memory address,
46 depending on the setting of
49 A NUMA machine has different
50 memory controllers with different distances to specific CPUs.
51 The memory policy defines from which node memory is allocated for
57 then information about the calling thread's default policy
59 .BR set_mempolicy (2))
60 is returned, in the buffers pointed to by
64 The value returned in these arguments
65 may be used to restore the thread's policy to its state at
66 the time of the call to
69 .BR set_mempolicy (2).
74 must be specified as NULL.
79 .BR MPOL_F_MEMS_ALLOWED
80 (available since Linux 2.6.24), the
82 argument is ignored and the set of nodes (memories) that the
83 thread is allowed to specify in subsequent calls to
87 (in the absence of any
91 It is not permitted to combine
92 .B MPOL_F_MEMS_ALLOWED
102 then information is returned about the policy governing the memory
105 This policy may be different from the thread's default policy if
107 or one of the helper functions described in
109 has been used to establish a policy for the memory range containing
114 argument is not NULL, then
116 will store the policy mode and any optional
118 of the requested NUMA policy in the location pointed to by this argument.
121 is not NULL, then the nodemask associated with the policy will be stored
122 in the location pointed to by this argument.
124 specifies the number of node IDs
125 that can be stored into
126 .IR nodemask \(emthat
127 is, the maximum node ID plus one.
128 The value specified by
130 is always rounded to a multiple of
131 .IR "sizeof(unsigned\ long)*8" .
140 will return the node ID of the node on which the address
142 is allocated into the location pointed to by
144 If no page has yet been allocated for the specified address,
146 will allocate a page as if the thread had performed a read
147 (load) access to that address, and return the ID of the node
148 where that page was allocated.
156 and the thread's current policy is
157 .BR MPOL_INTERLEAVE ,
160 will return in the location pointed to by a non-NULL
163 the node ID of the next node that will be used for
164 interleaving of internal kernel pages allocated on behalf of the thread.
165 .\" Note: code returns next interleave node via 'mode' argument -Lee Schermerhorn
166 These allocations include pages for memory-mapped files in
167 process memory ranges mapped using the
171 flag for read accesses, and in memory ranges mapped with the
173 flag for all accesses.
175 Other flag values are reserved.
177 For an overview of the possible policies see
178 .BR set_mempolicy (2).
183 on error, \-1 is returned and
185 is set to indicate the error.
189 Part of all of the memory range specified by
193 points outside your accessible address space.
196 The value specified by
198 is less than the number of node IDs supported by the system.
201 specified values other than
225 and the current thread policy is not
226 .BR MPOL_INTERLEAVE .
230 .B MPOL_F_MEMS_ALLOWED
241 system call was added to the Linux kernel in version 2.6.7.
243 This system call is Linux-specific.
245 Glibc does not provide a wrapper for this system call.
246 For information on library support, see
252 .BR set_mempolicy (2),