1MOVE_PAGES(2)              Linux Programmer's Manual             MOVE_PAGES(2)
2
3
4

NAME

6       move_pages - move individual pages of a process to another node
7

SYNOPSIS

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
16       Note: There is no glibc wrapper for this system call; see NOTES.
17

DESCRIPTION

19       move_pages() moves the specified pages of the process pid to the memory
20       nodes specified by nodes.  The result of the move is reflected in  sta‐
21       tus.  The flags indicate constraints on the pages to be moved.
22
23       pid is the ID of the process in which pages are to be moved.  If pid is
24       0, then move_pages() moves pages of the calling process.
25
26       To move pages in another process requires the following privileges:
27
28       *  In kernels up to and including Linux 4.12: the caller must be privi‐
29          leged (CAP_SYS_NICE) or the real or effective user ID of the calling
30          process must match the real or  saved-set  user  ID  of  the  target
31          process.
32
33       *  The  older  rules allowed the caller to discover various virtual ad‐
34          dress choices made by the kernel that could lead to  the  defeat  of
35          address-space-layout  randomization  for a process owned by the same
36          UID as the caller, the rules were changed starting with Linux  4.13.
37          Since  Linux  4.13,  permission  is governed by a ptrace access mode
38          PTRACE_MODE_READ_REALCREDS check with respect to the target process;
39          see ptrace(2).
40
41       count is the number of pages to move.  It defines the size of the three
42       arrays pages, nodes, and status.
43
44       pages is an array of pointers to the pages that should be moved.  These
45       are  pointers that should be aligned to page boundaries.  Addresses are
46       specified as seen by the process specified by pid.
47
48       nodes is an array of integers that specify  the  desired  location  for
49       each page.  Each element in the array is a node number.  nodes can also
50       be NULL, in which case move_pages() does not move any pages but instead
51       will  return  the node where each page currently resides, in the status
52       array.  Obtaining the status of each page may be necessary to determine
53       pages that need to be moved.
54
55       status  is  an  array  of integers that return the status of each page.
56       The array contains valid values only if move_pages() did not return  an
57       error.   Preinitialization  of the array to a value which cannot repre‐
58       sent a real numa node or valid error of  status  array  could  help  to
59       identify pages that have been migrated.
60
61       flags  specify  what  types  of pages to move.  MPOL_MF_MOVE means that
62       only pages that are in exclusive use by the process are  to  be  moved.
63       MPOL_MF_MOVE_ALL means that pages shared between multiple processes can
64       also be moved.  The process must be privileged  (CAP_SYS_NICE)  to  use
65       MPOL_MF_MOVE_ALL.
66
67   Page states in the status array
68       The  following values can be returned in each element of the status ar‐
69       ray.
70
71       0..MAX_NUMNODES
72              Identifies the node on which the page resides.
73
74       -EACCES
75              The page is mapped by multiple processes and can be  moved  only
76              if MPOL_MF_MOVE_ALL is specified.
77
78       -EBUSY The  page  is  currently  busy  and  cannot be moved.  Try again
79              later.  This occurs if a page is undergoing I/O or another  ker‐
80              nel subsystem is holding a reference to the page.
81
82       -EFAULT
83              This  is  a  zero  page  or the memory area is not mapped by the
84              process.
85
86       -EIO   Unable to write back a page.  The page has to be written back in
87              order to move it since the page is dirty and the filesystem does
88              not provide a migration function that would allow  the  move  of
89              dirty pages.
90
91       -EINVAL
92              A dirty page cannot be moved.  The filesystem does not provide a
93              migration function and has no ability to write back pages.
94
95       -ENOENT
96              The page is not present.
97
98       -ENOMEM
99              Unable to allocate memory on target node.
100

RETURN VALUE

102       On success move_pages() returns zero.  On error,  it  returns  -1,  and
103       sets errno to indicate the error.  If positive value is returned, it is
104       the number of nonmigrated pages.
105

ERRORS

107       Positive value
108              The number of nonmigrated pages if they were the result of  non‐
109              fatal reasons (since Linux 4.17).
110
111       E2BIG  Too  many  pages  to  move.   Since  Linux 2.6.29, the kernel no
112              longer generates this error.
113
114       EACCES One of the target nodes is not allowed by the current cpuset.
115
116       EFAULT Parameter array could not be accessed.
117
118       EINVAL Flags other than MPOL_MF_MOVE and MPOL_MF_MOVE_ALL was specified
119              or an attempt was made to migrate pages of a kernel thread.
120
121       ENODEV One of the target nodes is not online.
122
123       EPERM  The  caller specified MPOL_MF_MOVE_ALL without sufficient privi‐
124              leges (CAP_SYS_NICE).  Or, the caller attempted to move pages of
125              a  process  belonging to another user but did not have privilege
126              to do so (CAP_SYS_NICE).
127
128       ESRCH  Process does not exist.
129

VERSIONS

131       move_pages() first appeared on Linux in version 2.6.18.
132

CONFORMING TO

134       This system call is Linux-specific.
135

NOTES

137       Glibc does not provide a wrapper for this system call.  For information
138       on library support, see numa(7).
139
140       Use  get_mempolicy(2)  with  the MPOL_F_MEMS_ALLOWED flag to obtain the
141       set of nodes that are allowed by the current cpuset.   Note  that  this
142       information is subject to change at any time by manual or automatic re‐
143       configuration of the cpuset.
144
145       Use of this function may result in pages whose location (node) violates
146       the   memory  policy  established  for  the  specified  addresses  (See
147       mbind(2)) and/or the specified process  (See  set_mempolicy(2)).   That
148       is,  memory  policy  does  not  constrain the destination nodes used by
149       move_pages().
150
151       The <numaif.h> header is not included  with  glibc,  but  requires  in‐
152       stalling libnuma-devel or a similar package.
153

SEE ALSO

155       get_mempolicy(2),  mbind(2),  set_mempolicy(2),  numa(3), numa_maps(5),
156       cpuset(7), numa(7), migratepages(8), numastat(8)
157

COLOPHON

159       This page is part of release 5.12 of the Linux  man-pages  project.   A
160       description  of  the project, information about reporting bugs, and the
161       latest    version    of    this    page,    can     be     found     at
162       https://www.kernel.org/doc/man-pages/.
163
164
165
166Linux                             2021-03-22                     MOVE_PAGES(2)
Impressum