1MOVE_PAGES(2) Linux Programmer's Manual MOVE_PAGES(2)
2
3
4
6 move_pages - move individual pages of a process to another node
7
9 #include <numaif.h>
10
11 long move_pages(int pid, unsigned long count, void **pages,
12 const int *nodes, int *status, int flags);
13
14 Link with -lnuma.
15
17 move_pages() moves the specified pages of the process pid to the memory
18 nodes specified by nodes. The result of the move is reflected in sta‐
19 tus. The flags indicate constraints on the pages to be moved.
20
21 pid is the ID of the process in which pages are to be moved. If pid is
22 0, then move_pages() moves pages of the calling process.
23
24 To move pages in another process requires the following privileges:
25
26 * In kernels up to and including Linux 4.12: the caller must be privi‐
27 leged (CAP_SYS_NICE) or the real or effective user ID of the calling
28 process must match the real or saved-set user ID of the target
29 process.
30
31 * The older rules allowed the caller to discover various virtual
32 address choices made by the kernel that could lead to the defeat of
33 address-space-layout randomization for a process owned by the same
34 UID as the caller, the rules were changed starting with Linux 4.13.
35 Since Linux 4.13, permission is governed by a ptrace access mode
36 PTRACE_MODE_READ_REALCREDS check with respect to the target process;
37 see ptrace(2).
38
39 count is the number of pages to move. It defines the size of the three
40 arrays pages, nodes, and status.
41
42 pages is an array of pointers to the pages that should be moved. These
43 are pointers that should be aligned to page boundaries. Addresses are
44 specified as seen by the process specified by pid.
45
46 nodes is an array of integers that specify the desired location for
47 each page. Each element in the array is a node number. nodes can also
48 be NULL, in which case move_pages() does not move any pages but instead
49 will return the node where each page currently resides, in the status
50 array. Obtaining the status of each page may be necessary to determine
51 pages that need to be moved.
52
53 status is an array of integers that return the status of each page.
54 The array contains valid values only if move_pages() did not return an
55 error.
56
57 flags specify what types of pages to move. MPOL_MF_MOVE means that
58 only pages that are in exclusive use by the process are to be moved.
59 MPOL_MF_MOVE_ALL means that pages shared between multiple processes can
60 also be moved. The process must be privileged (CAP_SYS_NICE) to use
61 MPOL_MF_MOVE_ALL.
62
63 Page states in the status array
64 The following values can be returned in each element of the status
65 array.
66
67 0..MAX_NUMNODES
68 Identifies the node on which the page resides.
69
70 -EACCES
71 The page is mapped by multiple processes and can be moved only
72 if MPOL_MF_MOVE_ALL is specified.
73
74 -EBUSY The page is currently busy and cannot be moved. Try again
75 later. This occurs if a page is undergoing I/O or another ker‐
76 nel subsystem is holding a reference to the page.
77
78 -EFAULT
79 This is a zero page or the memory area is not mapped by the
80 process.
81
82 -EIO Unable to write back a page. The page has to be written back in
83 order to move it since the page is dirty and the filesystem does
84 not provide a migration function that would allow the move of
85 dirty pages.
86
87 -EINVAL
88 A dirty page cannot be moved. The filesystem does not provide a
89 migration function and has no ability to write back pages.
90
91 -ENOENT
92 The page is not present.
93
94 -ENOMEM
95 Unable to allocate memory on target node.
96
98 On success move_pages() returns zero. On error, it returns -1, and
99 sets errno to indicate the error.
100
102 E2BIG Too many pages to move. Since Linux 2.6.29, the kernel no
103 longer generates this error.
104
105 EACCES One of the target nodes is not allowed by the current cpuset.
106
107 EFAULT Parameter array could not be accessed.
108
109 EINVAL Flags other than MPOL_MF_MOVE and MPOL_MF_MOVE_ALL was specified
110 or an attempt was made to migrate pages of a kernel thread.
111
112 ENODEV One of the target nodes is not online.
113
114 ENOENT No pages were found that require moving. All pages are either
115 already on the target node, not present, had an invalid address
116 or could not be moved because they were mapped by multiple pro‐
117 cesses.
118
119 EPERM The caller specified MPOL_MF_MOVE_ALL without sufficient privi‐
120 leges (CAP_SYS_NICE). Or, the caller attempted to move pages of
121 a process belonging to another user but did not have privilege
122 to do so (CAP_SYS_NICE).
123
124 ESRCH Process does not exist.
125
127 move_pages() first appeared on Linux in version 2.6.18.
128
130 This system call is Linux-specific.
131
133 For information on library support, see numa(7).
134
135 Use get_mempolicy(2) with the MPOL_F_MEMS_ALLOWED flag to obtain the
136 set of nodes that are allowed by the current cpuset. Note that this
137 information is subject to change at any time by manual or automatic
138 reconfiguration of the cpuset.
139
140 Use of this function may result in pages whose location (node) violates
141 the memory policy established for the specified addresses (See
142 mbind(2)) and/or the specified process (See set_mempolicy(2)). That
143 is, memory policy does not constrain the destination nodes used by
144 move_pages().
145
146 The <numaif.h> header is not included with glibc, but requires
147 installing libnuma-devel or a similar package.
148
150 get_mempolicy(2), mbind(2), set_mempolicy(2), numa(3), numa_maps(5),
151 cpuset(7), numa(7), migratepages(8), numastat(8)
152
154 This page is part of release 5.04 of the Linux man-pages project. A
155 description of the project, information about reporting bugs, and the
156 latest version of this page, can be found at
157 https://www.kernel.org/doc/man-pages/.
158
159
160
161Linux 2019-10-10 MOVE_PAGES(2)