]> git.ipfire.org Git - thirdparty/man-pages.git/blame - man2/move_pages.2
mmap.2: srcfix: note kernel commit that caused MAP_POPULATE | MAP_NONBLOCK to be...
[thirdparty/man-pages.git] / man2 / move_pages.2
CommitLineData
abe7c871
MK
1.\" This manpage is Copyright (C) 2006 Silicon Graphics, Inc.
2.\" Christoph Lameter
3.\"
89b25c0f 4.\" %%%LICENSE_START(VERBATIM_TWO_PARA)
abe7c871
MK
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.
8.\"
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.
8ff7380d 13.\" %%%LICENSE_END
abe7c871 14.\"
bea08fec 15.\" FIXME Should programs normally be using move_pages() directly, or should
abe7c871
MK
16.\" they rather be using interfaces in the numactl package?
17.\" (e.g., compare with recommendation in mbind(2)).
3af37891
MK
18.\" Does this page need to give advice on this topic?
19.\"
6b621d05 20.TH MOVE_PAGES 2 2020-02-09 "Linux" "Linux Programmer's Manual"
abe7c871
MK
21.SH NAME
22move_pages \- move individual pages of a process to another node
23.SH SYNOPSIS
24.nf
25.B #include <numaif.h>
68e4db0a 26.PP
abe7c871
MK
27.BI "long move_pages(int " pid ", unsigned long count, void **" pages ,
28.BI " const int *" nodes ", int *" status ", int " flags );
29.fi
68e4db0a 30.PP
cb8fbbcd 31Link with \fI\-lnuma\fP.
abe7c871
MK
32.SH DESCRIPTION
33.BR move_pages ()
34moves the specified
35.I pages
36of the process
37.I pid
38to the memory nodes specified by
39.IR nodes .
40The result of the move is reflected in
41.IR status .
42The
43.I flags
44indicate constraints on the pages to be moved.
efeece04 45.PP
abe7c871
MK
46.I pid
47is the ID of the process in which pages are to be moved.
18997ae3
MK
48If
49.I pid
50is 0, then
51.BR move_pages ()
52moves pages of the calling process.
53.PP
f211b01b
MK
54To move pages in another process requires the following privileges:
55.IP * 3
56In kernels up to and including Linux 4.12:
abe7c871 57the caller must be privileged
f211b01b
MK
58.RB ( CAP_SYS_NICE )
59or the real or effective user ID of the calling process must match the
60real or saved-set user ID of the target process.
61.IP *
62The older rules allowed the caller to discover various
63virtual address choices made by the kernel that could lead
64to the defeat of address-space-layout randomization
65for a process owned by the same UID as the caller,
66the rules were changed starting with Linux 4.13.
67Since Linux 4.13,
68.\" commit 197e7e521384a23b9e585178f3f11c9fa08274b9
69permission is governed by a ptrace access mode
70.B PTRACE_MODE_READ_REALCREDS
71check with respect to the target process; see
72.BR ptrace (2).
efeece04 73.PP
abe7c871
MK
74.I count
75is the number of pages to move.
76It defines the size of the three arrays
77.IR pages ,
78.IR nodes ,
79and
80.IR status .
efeece04 81.PP
abe7c871
MK
82.I pages
83is an array of pointers to the pages that should be moved.
84These are pointers that should be aligned to page boundaries.
bea08fec
MK
85.\" FIXME Describe the result if pointers in the 'pages' array are
86.\" not aligned to page boundaries
abe7c871
MK
87Addresses are specified as seen by the process specified by
88.IR pid .
efeece04 89.PP
abe7c871
MK
90.I nodes
91is an array of integers that specify the desired location for each page.
92Each element in the array is a node number.
93.I nodes
94can also be NULL, in which case
95.BR move_pages ()
96does not move any pages but instead will return the node
97where each page currently resides, in the
98.I status
99array.
100Obtaining the status of each page may be necessary to determine
101pages that need to be moved.
efeece04 102.PP
abe7c871
MK
103.I status
104is an array of integers that return the status of each page.
33a0ccb2 105The array contains valid values only if
abe7c871 106.BR move_pages ()
d407f83e
MK
107did not return an error.
108Preinitialization of the array to a value
e7b72190 109which cannot represent a real numa node or valid error of status array
d407f83e 110could help to identify pages that have been migrated.
efeece04 111.PP
abe7c871
MK
112.I flags
113specify what types of pages to move.
114.B MPOL_MF_MOVE
115means that only pages that are in exclusive use by the process
116are to be moved.
117.B MPOL_MF_MOVE_ALL
118means that pages shared between multiple processes can also be moved.
119The process must be privileged
120.RB ( CAP_SYS_NICE )
121to use
122.BR MPOL_MF_MOVE_ALL .
3944ae0c 123.SS Page states in the status array
abe7c871
MK
124The following values can be returned in each element of the
125.I status
126array.
127.TP
128.B 0..MAX_NUMNODES
129Identifies the node on which the page resides.
130.TP
131.B -EACCES
33a0ccb2 132The page is mapped by multiple processes and can be moved only if
abe7c871
MK
133.B MPOL_MF_MOVE_ALL
134is specified.
135.TP
136.B -EBUSY
137The page is currently busy and cannot be moved.
138Try again later.
139This occurs if a page is undergoing I/O or another kernel subsystem
140is holding a reference to the page.
141.TP
142.B -EFAULT
143This is a zero page or the memory area is not mapped by the process.
144.TP
145.B -EIO
146Unable to write back a page.
147The page has to be written back
9ee4a2b6 148in order to move it since the page is dirty and the filesystem
abe7c871
MK
149does not provide a migration function that would allow the move
150of dirty pages.
151.TP
152.B -EINVAL
153A dirty page cannot be moved.
9ee4a2b6 154The filesystem does not
abe7c871
MK
155provide a migration function and has no ability to write back pages.
156.TP
157.B -ENOENT
158The page is not present.
159.TP
160.B -ENOMEM
161Unable to allocate memory on target node.
47297adb 162.SH RETURN VALUE
abe7c871
MK
163On success
164.BR move_pages ()
165returns zero.
bea08fec 166.\" FIXME . Is the following quite true: does the wrapper in numactl
abe7c871
MK
167.\" do the right thing?
168On error, it returns \-1, and sets
169.I errno
d407f83e
MK
170to indicate the error.
171If positive value is returned, it is the number of
172nonmigrated pages.
abe7c871
MK
173.SH ERRORS
174.TP
e7b72190 175.B Positive value
d407f83e
MK
176The number of nonmigrated pages if they were the result of nonfatal
177reasons (since
178.\" commit a49bd4d7163707de377aee062f17befef6da891b
179Linux 4.17).
abe7c871 180.B E2BIG
6812112d
MK
181Too many pages to move.
182Since Linux 2.6.29,
183.\" commit 3140a2273009c01c27d316f35ab76a37e105fdd8
184the kernel no longer generates this error.
abe7c871 185.TP