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