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