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

DESCRIPTION

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.   Preinitialization  of the array to a value which cannot repre‐
56       sent a real numa node or valid error of  status  array  could  help  to
57       identify pages that have been migrated.
58
59       flags  specify  what  types  of pages to move.  MPOL_MF_MOVE means that
60       only pages that are in exclusive use by the process are  to  be  moved.
61       MPOL_MF_MOVE_ALL means that pages shared between multiple processes can
62       also be moved.  The process must be privileged  (CAP_SYS_NICE)  to  use
63       MPOL_MF_MOVE_ALL.
64
65   Page states in the status array
66       The  following  values  can  be  returned in each element of the status
67       array.
68
69       0..MAX_NUMNODES
70              Identifies the node on which the page resides.
71
72       -EACCES
73              The page is mapped by multiple processes and can be  moved  only
74              if MPOL_MF_MOVE_ALL is specified.
75
76       -EBUSY The  page  is  currently  busy  and  cannot be moved.  Try again
77              later.  This occurs if a page is undergoing I/O or another  ker‐
78              nel subsystem is holding a reference to the page.
79
80       -EFAULT
81              This  is  a  zero  page  or the memory area is not mapped by the
82              process.
83
84       -EIO   Unable to write back a page.  The page has to be written back in
85              order to move it since the page is dirty and the filesystem does
86              not provide a migration function that would allow  the  move  of
87              dirty pages.
88
89       -EINVAL
90              A dirty page cannot be moved.  The filesystem does not provide a
91              migration function and has no ability to write back pages.
92
93       -ENOENT
94              The page is not present.
95
96       -ENOMEM
97              Unable to allocate memory on target node.
98

RETURN VALUE

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

ERRORS

105       Positive value
106              The number of nonmigrated pages if they were the result of  non‐
107              fatal reasons (since Linux 4.17).  E2BIG Too many pages to move.
108              Since Linux 2.6.29, the kernel no longer generates this error.
109
110       EACCES One of the target nodes is not allowed by the current cpuset.
111
112       EFAULT Parameter array could not be accessed.
113
114       EINVAL Flags other than MPOL_MF_MOVE and MPOL_MF_MOVE_ALL was specified
115              or an attempt was made to migrate pages of a kernel thread.
116
117       ENODEV One of the target nodes is not online.
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

VERSIONS

127       move_pages() first appeared on Linux in version 2.6.18.
128

CONFORMING TO

130       This system call is Linux-specific.
131

NOTES

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

SEE ALSO

150       get_mempolicy(2), mbind(2),  set_mempolicy(2),  numa(3),  numa_maps(5),
151       cpuset(7), numa(7), migratepages(8), numastat(8)
152

COLOPHON

154       This  page  is  part of release 5.07 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                             2020-06-09                     MOVE_PAGES(2)
Impressum