1move_pages(2)                 System Calls Manual                move_pages(2)
2
3
4

NAME

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

LIBRARY

9       NUMA (Non-Uniform Memory Access) policy library (libnuma, -lnuma)
10

SYNOPSIS

12       #include <numaif.h>
13
14       long move_pages(int pid, unsigned long count, void *pages[.count],
15                       const int nodes[.count], int status[.count], int flags);
16

DESCRIPTION

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

RETURN VALUE

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

ERRORS

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

STANDARDS

130       Linux.
131

HISTORY

133       Linux 2.6.18.
134

NOTES

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

SEE ALSO

153       get_mempolicy(2), mbind(2),  set_mempolicy(2),  numa(3),  numa_maps(5),
154       cpuset(7), numa(7), migratepages(8), numastat(8)
155
156
157
158Linux man-pages 6.05              2023-07-15                     move_pages(2)
Impressum