1 .\" This manpage is Copyright (C) 2006 Silicon Graphics, Inc.
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.
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.
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?
20 .TH MOVE_PAGES 2 2017-09-15 "Linux" "Linux Programmer's Manual"
22 move_pages \- move individual pages of a process to another node
25 .B #include <numaif.h>
27 .BI "long move_pages(int " pid ", unsigned long count, void **" pages ,
28 .BI " const int *" nodes ", int *" status ", int " flags );
31 Link with \fI\-lnuma\fP.
38 to the memory nodes specified by
40 The result of the move is reflected in
44 indicate constraints on the pages to be moved.
47 is the ID of the process in which pages are to be moved.
52 moves pages of the calling process.
54 To move pages in another process requires the following privileges:
56 In kernels up to and including Linux 4.12:
57 the caller must be privileged
59 or the real or effective user ID of the calling process must match the
60 real or saved-set user ID of the target process.
62 The older rules allowed the caller to discover various
63 virtual address choices made by the kernel that could lead
64 to the defeat of address-space-layout randomization
65 for a process owned by the same UID as the caller,
66 the rules were changed starting with Linux 4.13.
68 .\" commit 197e7e521384a23b9e585178f3f11c9fa08274b9
69 permission is governed by a ptrace access mode
70 .B PTRACE_MODE_READ_REALCREDS
71 check with respect to the target process; see
75 is the number of pages to move.
76 It defines the size of the three arrays
83 is an array of pointers to the pages that should be moved.
84 These are pointers that should be aligned to page boundaries.
85 .\" FIXME Describe the result if pointers in the 'pages' array are
86 .\" not aligned to page boundaries
87 Addresses are specified as seen by the process specified by
91 is an array of integers that specify the desired location for each page.
92 Each element in the array is a node number.
94 can also be NULL, in which case
96 does not move any pages but instead will return the node
97 where each page currently resides, in the
100 Obtaining the status of each page may be necessary to determine
101 pages that need to be moved.
104 is an array of integers that return the status of each page.
105 The array contains valid values only if
107 did not return an error.
110 specify what types of pages to move.
112 means that only pages that are in exclusive use by the process
115 means that pages shared between multiple processes can also be moved.
116 The process must be privileged
119 .BR MPOL_MF_MOVE_ALL .
120 .SS Page states in the status array
121 The following values can be returned in each element of the
126 Identifies the node on which the page resides.
129 The page is mapped by multiple processes and can be moved only if
134 The page is currently busy and cannot be moved.
136 This occurs if a page is undergoing I/O or another kernel subsystem
137 is holding a reference to the page.
140 This is a zero page or the memory area is not mapped by the process.
143 Unable to write back a page.
144 The page has to be written back
145 in order to move it since the page is dirty and the filesystem
146 does not provide a migration function that would allow the move
150 A dirty page cannot be moved.
151 The filesystem does not
152 provide a migration function and has no ability to write back pages.
155 The page is not present.
158 Unable to allocate memory on target node.
163 .\" FIXME . Is the following quite true: does the wrapper in numactl
164 .\" do the right thing?
165 On error, it returns \-1, and sets
167 to indicate the error.
171 Too many pages to move.
174 .\" FIXME Clarify "current cpuset" in the description of the EACCES error.
175 .\" Is that the cpuset of the caller or the target?
176 One of the target nodes is not allowed by the current cpuset.
179 Parameter array could not be accessed.
186 was specified or an attempt was made to migrate pages of a kernel thread.
189 One of the target nodes is not online.
192 No pages were found that require moving.
193 All pages are either already
194 on the target node, not present, had an invalid address or could not be
195 moved because they were mapped by multiple processes.
200 without sufficient privileges
201 .RB ( CAP_SYS_NICE ).
202 Or, the caller attempted to move pages of a process belonging
203 to another user but did not have privilege to do so
204 .RB ( CAP_SYS_NICE ).
207 Process does not exist.
210 first appeared on Linux in version 2.6.18.
212 This system call is Linux-specific.
214 For information on library support, see
218 .BR get_mempolicy (2)
220 .B MPOL_F_MEMS_ALLOWED
221 flag to obtain the set of nodes that are allowed by
222 .\" FIXME Clarify "current cpuset". Is that the cpuset of the caller
225 Note that this information is subject to change at any
226 time by manual or automatic reconfiguration of the cpuset.
228 Use of this function may result in pages whose location
229 (node) violates the memory policy established for the
230 specified addresses (See
232 and/or the specified process (See
233 .BR set_mempolicy (2)).
234 That is, memory policy does not constrain the destination
240 header is not included with glibc, but requires installing
242 or a similar package.
244 .BR get_mempolicy (2),
246 .BR set_mempolicy (2),
251 .BR migratepages (8),