]> git.ipfire.org Git - thirdparty/man-pages.git/blob - man2/get_mempolicy.2
Many pages: Use correct letter case in page titles (TH)
[thirdparty/man-pages.git] / man2 / get_mempolicy.2
1 .\" Copyright 2003,2004 Andi Kleen, SuSE Labs.
2 .\" and Copyright 2007 Lee Schermerhorn, Hewlett Packard
3 .\"
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.
8 .\"
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.
13 .\"
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.
18 .\"
19 .\" Formatted or processed versions of this manual, if unaccompanied by
20 .\" the source, must acknowledge the copyright and authors of this work.
21 .\" %%%LICENSE_END
22 .\"
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.
26 .\"
27 .TH get_mempolicy 2 (date) "Linux man-pages (unreleased)"
28 .SH NAME
29 get_mempolicy \- retrieve NUMA memory policy for a thread
30 .SH LIBRARY
31 NUMA (Non-Uniform Memory Access) policy library
32 .RI ( libnuma ", " \-lnuma )
33 .SH SYNOPSIS
34 .B "#include <numaif.h>"
35 .nf
36 .PP
37 .BI "long get_mempolicy(int *" mode ", unsigned long *" nodemask ,
38 .BI " unsigned long " maxnode ", void *" addr ,
39 .BI " unsigned long " flags );
40 .fi
41 .SH DESCRIPTION
42 .BR get_mempolicy ()
43 retrieves the NUMA policy of the calling thread or of a memory address,
44 depending on the setting of
45 .IR flags .
46 .PP
47 A NUMA machine has different
48 memory controllers with different distances to specific CPUs.
49 The memory policy defines from which node memory is allocated for
50 the thread.
51 .PP
52 If
53 .I flags
54 is specified as 0,
55 then information about the calling thread's default policy
56 (as set by
57 .BR set_mempolicy (2))
58 is returned, in the buffers pointed to by
59 .I mode
60 and
61 .IR nodemask .
62 The value returned in these arguments
63 may be used to restore the thread's policy to its state at
64 the time of the call to
65 .BR get_mempolicy ()
66 using
67 .BR set_mempolicy (2).
68 When
69 .I flags
70 is 0,
71 .I addr
72 must be specified as NULL.
73 .PP
74 If
75 .I flags
76 specifies
77 .B MPOL_F_MEMS_ALLOWED
78 (available since Linux 2.6.24), the
79 .I mode
80 argument is ignored and the set of nodes (memories) that the
81 thread is allowed to specify in subsequent calls to
82 .BR mbind (2)
83 or
84 .BR set_mempolicy (2)
85 (in the absence of any
86 .IR "mode flags" )
87 is returned in
88 .IR nodemask .
89 It is not permitted to combine
90 .B MPOL_F_MEMS_ALLOWED
91 with either
92 .B MPOL_F_ADDR
93 or
94 .BR MPOL_F_NODE .
95 .PP
96 If
97 .I flags
98 specifies
99 .BR MPOL_F_ADDR ,
100 then information is returned about the policy governing the memory
101 address given in
102 .IR addr .
103 This policy may be different from the thread's default policy if
104 .BR mbind (2)
105 or one of the helper functions described in
106 .BR numa (3)
107 has been used to establish a policy for the memory range containing
108 .IR addr .
109 .PP
110 If the
111 .I mode
112 argument is not NULL, then
113 .BR get_mempolicy ()
114 will store the policy mode and any optional
115 .I "mode flags"
116 of the requested NUMA policy in the location pointed to by this argument.
117 If
118 .I nodemask
119 is not NULL, then the nodemask associated with the policy will be stored
120 in the location pointed to by this argument.
121 .I maxnode
122 specifies the number of node IDs
123 that can be stored into
124 .IR nodemask \(emthat
125 is, the maximum node ID plus one.
126 The value specified by
127 .I maxnode
128 is always rounded to a multiple of
129 .IR "sizeof(unsigned\ long)*8" .
130 .PP
131 If
132 .I flags
133 specifies both
134 .B MPOL_F_NODE
135 and
136 .BR MPOL_F_ADDR ,
137 .BR get_mempolicy ()
138 will return the node ID of the node on which the address
139 .I addr
140 is allocated into the location pointed to by
141 .IR mode .
142 If no page has yet been allocated for the specified address,
143 .BR get_mempolicy ()
144 will allocate a page as if the thread had performed a read
145 (load) access to that address, and return the ID of the node
146 where that page was allocated.
147 .PP
148 If
149 .I flags
150 specifies
151 .BR MPOL_F_NODE ,
152 but not
153 .BR MPOL_F_ADDR ,
154 and the thread's current policy is
155 .BR MPOL_INTERLEAVE ,
156 then
157 .BR get_mempolicy ()
158 will return in the location pointed to by a non-NULL
159 .I mode
160 argument,
161 the node ID of the next node that will be used for
162 interleaving of internal kernel pages allocated on behalf of the thread.
163 .\" Note: code returns next interleave node via 'mode' argument -Lee Schermerhorn
164 These allocations include pages for memory-mapped files in
165 process memory ranges mapped using the
166 .BR mmap (2)
167 call with the
168 .B MAP_PRIVATE
169 flag for read accesses, and in memory ranges mapped with the
170 .B MAP_SHARED
171 flag for all accesses.
172 .PP
173 Other flag values are reserved.
174 .PP
175 For an overview of the possible policies see
176 .BR set_mempolicy (2).
177 .SH RETURN VALUE
178 On success,
179 .BR get_mempolicy ()
180 returns 0;
181 on error, \-1 is returned and
182 .I errno
183 is set to indicate the error.
184 .SH ERRORS
185 .TP
186 .B EFAULT
187 Part of all of the memory range specified by
188 .I nodemask
189 and
190 .I maxnode
191 points outside your accessible address space.
192 .TP
193 .B EINVAL
194 The value specified by
195 .I maxnode
196 is less than the number of node IDs supported by the system.
197 Or
198 .I flags
199 specified values other than
200 .B MPOL_F_NODE
201 or
202 .BR MPOL_F_ADDR ;
203 or
204 .I flags
205 specified
206 .B MPOL_F_ADDR
207 and
208 .I addr
209 is NULL,
210 or
211 .I flags
212 did not specify
213 .B MPOL_F_ADDR
214 and
215 .I addr
216 is not NULL.
217 Or,
218 .I flags
219 specified
220 .B MPOL_F_NODE
221 but not
222 .B MPOL_F_ADDR
223 and the current thread policy is not
224 .BR MPOL_INTERLEAVE .
225 Or,
226 .I flags
227 specified
228 .B MPOL_F_MEMS_ALLOWED
229 with either
230 .B MPOL_F_ADDR
231 or
232 .BR MPOL_F_NODE .
233 (And there are other
234 .B EINVAL
235 cases.)
236 .SH VERSIONS
237 The
238 .BR get_mempolicy ()
239 system call was added to the Linux kernel in version 2.6.7.
240 .SH STANDARDS
241 This system call is Linux-specific.
242 .SH NOTES
243 For information on library support, see
244 .BR numa (7).
245 .SH SEE ALSO
246 .BR getcpu (2),
247 .BR mbind (2),
248 .BR mmap (2),
249 .BR set_mempolicy (2),
250 .BR numa (3),
251 .BR numa (7),
252 .BR numactl (8)