]> git.ipfire.org Git - thirdparty/man-pages.git/blame - man2/move_pages.2
proc.5: ffix
[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.\"
4b8c67d9 20.TH MOVE_PAGES 2 2017-09-15 "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
MK
106.BR move_pages ()
107did not return an error.
efeece04 108.PP
abe7c871
MK
109.I flags
110specify what types of pages to move.
111.B MPOL_MF_MOVE
112means that only pages that are in exclusive use by the process
113are to be moved.
114.B MPOL_MF_MOVE_ALL
115means that pages shared between multiple processes can also be moved.
116The process must be privileged
117.RB ( CAP_SYS_NICE )
118to use
119.BR MPOL_MF_MOVE_ALL .
3944ae0c 120.SS Page states in the status array
abe7c871
MK
121The following values can be returned in each element of the
122.I status
123array.
124.TP
125.B 0..MAX_NUMNODES
126Identifies the node on which the page resides.
127.TP
128.B -EACCES
33a0ccb2 129The page is mapped by multiple processes and can be moved only if
abe7c871
MK
130.B MPOL_MF_MOVE_ALL
131is specified.
132.TP
133.B -EBUSY
134The page is currently busy and cannot be moved.
135Try again later.
136This occurs if a page is undergoing I/O or another kernel subsystem
137is holding a reference to the page.
138.TP
139.B -EFAULT
140This is a zero page or the memory area is not mapped by the process.
141.TP
142.B -EIO
143Unable to write back a page.
144The page has to be written back
9ee4a2b6 145in order to move it since the page is dirty and the filesystem
abe7c871
MK
146does not provide a migration function that would allow the move
147of dirty pages.
148.TP
149.B -EINVAL
150A dirty page cannot be moved.
9ee4a2b6 151The filesystem does not
abe7c871
MK
152provide a migration function and has no ability to write back pages.
153.TP
154.B -ENOENT
155The page is not present.
156.TP
157.B -ENOMEM
158Unable to allocate memory on target node.
47297adb 159.SH RETURN VALUE
abe7c871
MK
160On success
161.BR move_pages ()
162returns zero.
bea08fec 163.\" FIXME . Is the following quite true: does the wrapper in numactl
abe7c871
MK
164.\" do the right thing?
165On error, it returns \-1, and sets
166.I errno
167to indicate the error.
168.SH ERRORS
169.TP
170.B E2BIG
171Too many pages to move.
172.TP