]> git.ipfire.org Git - thirdparty/man-pages.git/blob - man2/move_pages.2
Many pages: Use correct letter case in page titles (TH)
[thirdparty/man-pages.git] / man2 / move_pages.2
1 .\" This manpage is Copyright (C) 2006 Silicon Graphics, Inc.
2 .\" Christoph Lameter
3 .\"
4 .\" %%%LICENSE_START(VERBATIM_TWO_PARA)
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 .\" %%%LICENSE_END
14 .\"
15 .\" FIXME Should programs normally be using move_pages() directly, or should
16 .\" they rather be using interfaces in the numactl package?
17 .\" (e.g., compare with recommendation in mbind(2)).
18 .\" Does this page need to give advice on this topic?
19 .\"
20 .TH move_pages 2 (date) "Linux man-pages (unreleased)"
21 .SH NAME
22 move_pages \- move individual pages of a process to another node
23 .SH LIBRARY
24 NUMA (Non-Uniform Memory Access) policy library
25 .RI ( libnuma ", " \-lnuma )
26 .SH SYNOPSIS
27 .nf
28 .B #include <numaif.h>
29 .PP
30 .BI "long move_pages(int " pid ", unsigned long " count ", void **" pages ,
31 .BI " const int *" nodes ", int *" status ", int " flags );
32 .fi
33 .SH DESCRIPTION
34 .BR move_pages ()
35 moves the specified
36 .I pages
37 of the process
38 .I pid
39 to the memory nodes specified by
40 .IR nodes .
41 The result of the move is reflected in
42 .IR status .
43 The
44 .I flags
45 indicate constraints on the pages to be moved.
46 .PP
47 .I pid
48 is the ID of the process in which pages are to be moved.
49 If
50 .I pid
51 is 0, then
52 .BR move_pages ()
53 moves pages of the calling process.
54 .PP
55 To move pages in another process requires the following privileges:
56 .IP \(bu 3
57 In kernels up to and including Linux 4.12:
58 the caller must be privileged
59 .RB ( CAP_SYS_NICE )
60 or the real or effective user ID of the calling process must match the
61 real or saved-set user ID of the target process.
62 .IP \(bu
63 The older rules allowed the caller to discover various
64 virtual address choices made by the kernel that could lead
65 to the defeat of address-space-layout randomization
66 for a process owned by the same UID as the caller,
67 the rules were changed starting with Linux 4.13.
68 Since Linux 4.13,
69 .\" commit 197e7e521384a23b9e585178f3f11c9fa08274b9
70 permission is governed by a ptrace access mode
71 .B PTRACE_MODE_READ_REALCREDS
72 check with respect to the target process; see
73 .BR ptrace (2).
74 .PP
75 .I count
76 is the number of pages to move.
77 It defines the size of the three arrays
78 .IR pages ,
79 .IR nodes ,
80 and
81 .IR status .
82 .PP
83 .I pages
84 is an array of pointers to the pages that should be moved.
85 These are pointers that should be aligned to page boundaries.
86 .\" FIXME Describe the result if pointers in the 'pages' array are
87 .\" not aligned to page boundaries
88 Addresses are specified as seen by the process specified by
89 .IR pid .
90 .PP
91 .I nodes
92 is an array of integers that specify the desired location for each page.
93 Each element in the array is a node number.
94 .I nodes
95 can also be NULL, in which case
96 .BR move_pages ()
97 does not move any pages but instead will return the node
98 where each page currently resides, in the
99 .I status
100 array.
101 Obtaining the status of each page may be necessary to determine
102 pages that need to be moved.
103 .PP
104 .I status
105 is an array of integers that return the status of each page.
106 The array contains valid values only if
107 .BR move_pages ()
108 did not return an error.
109 Preinitialization of the array to a value
110 which cannot represent a real numa node or valid error of status array
111 could help to identify pages that have been migrated.
112 .PP
113 .I flags
114 specify what types of pages to move.
115 .B MPOL_MF_MOVE
116 means that only pages that are in exclusive use by the process
117 are to be moved.
118 .B MPOL_MF_MOVE_ALL
119 means that pages shared between multiple processes can also be moved.
120 The process must be privileged
121 .RB ( CAP_SYS_NICE )
122 to use
123 .BR MPOL_MF_MOVE_ALL .
124 .SS Page states in the status array
125 The following values can be returned in each element of the
126 .I status
127 array.
128 .TP
129 .B 0..MAX_NUMNODES
130 Identifies the node on which the page resides.
131 .TP
132 .B \-EACCES
133 The page is mapped by multiple processes and can be moved only if
134 .B MPOL_MF_MOVE_ALL
135 is specified.
136 .TP
137 .B \-EBUSY
138 The page is currently busy and cannot be moved.
139 Try again later.
140 This occurs if a page is undergoing I/O or another kernel subsystem
141 is holding a reference to the page.
142 .TP
143 .B \-EFAULT
144 This is a zero page or the memory area is not mapped by the process.
145 .TP
146 .B \-EIO
147 Unable to write back a page.
148 The page has to be written back
149 in order to move it since the page is dirty and the filesystem
150 does not provide a migration function that would allow the move
151 of dirty pages.
152 .TP
153 .B \-EINVAL
154 A dirty page cannot be moved.
155 The filesystem does not
156 provide a migration function and has no ability to write back pages.
157 .TP
158 .B \-ENOENT
159 The page is not present.
160 .TP
161 .B \-ENOMEM
162 Unable to allocate memory on target node.
163 .SH RETURN VALUE
164 On success
165 .BR move_pages ()
166 returns zero.
167 .\" FIXME . Is the following quite true: does the wrapper in numactl
168 .\" do the right thing?
169 On error, it returns \-1, and sets
170 .I errno
171 to indicate the error.
172 If positive value is returned, it is the number of
173 nonmigrated pages.
174 .SH ERRORS
175 .TP
176 .B Positive value
177 The number of nonmigrated pages if they were the result of nonfatal
178 reasons (since
179 .\" commit a49bd4d7163707de377aee062f17befef6da891b
180 Linux 4.17).
181 .TP
182 .B E2BIG
183 Too many pages to move.
184 Since Linux 2.6.29,
185 .\" commit 3140a2273009c01c27d316f35ab76a37e105fdd8
186 the kernel no longer generates this error.
187 .TP
188 .B EACCES
189 .\" FIXME Clarify "current cpuset" in the description of the EACCES error.
190 .\" Is that the cpuset of the caller or the target?
191 One of the target nodes is not allowed by the current cpuset.
192 .TP
193 .B EFAULT
194 Parameter array could not be accessed.
195 .TP
196 .B EINVAL
197 Flags other than
198 .B MPOL_MF_MOVE
199 and
200 .B MPOL_MF_MOVE_ALL
201 was specified or an attempt was made to migrate pages of a kernel thread.
202 .TP
203 .B ENODEV
204 One of the target nodes is not online.
205 .TP
206 .B EPERM
207 The caller specified
208 .B MPOL_MF_MOVE_ALL
209 without sufficient privileges
210 .RB ( CAP_SYS_NICE ).
211 Or, the caller attempted to move pages of a process belonging
212 to another user but did not have privilege to do so
213 .RB ( CAP_SYS_NICE ).
214 .TP
215 .B ESRCH
216 Process does not exist.
217 .SH VERSIONS
218 .BR move_pages ()
219 first appeared on Linux in version 2.6.18.
220 .SH STANDARDS
221 This system call is Linux-specific.
222 .SH NOTES
223 For information on library support, see
224 .BR numa (7).
225 .PP
226 Use
227 .BR get_mempolicy (2)
228 with the
229 .B MPOL_F_MEMS_ALLOWED
230 flag to obtain the set of nodes that are allowed by
231 .\" FIXME Clarify "current cpuset". Is that the cpuset of the caller
232 .\" or the target?
233 the current cpuset.
234 Note that this information is subject to change at any
235 time by manual or automatic reconfiguration of the cpuset.
236 .PP
237 Use of this function may result in pages whose location
238 (node) violates the memory policy established for the
239 specified addresses (See
240 .BR mbind (2))
241 and/or the specified process (See
242 .BR set_mempolicy (2)).
243 That is, memory policy does not constrain the destination
244 nodes used by
245 .BR move_pages ().
246 .PP
247 The
248 .I <numaif.h>
249 header is not included with glibc, but requires installing
250 .I libnuma\-devel
251 or a similar package.
252 .SH SEE ALSO
253 .BR get_mempolicy (2),
254 .BR mbind (2),
255 .BR set_mempolicy (2),
256 .BR numa (3),
257 .BR numa_maps (5),
258 .BR cpuset (7),
259 .BR numa (7),
260 .BR migratepages (8),
261 .BR numastat (8)