OSDN Git Service

LDP: Update original to LDP v3.79
[linuxjm/LDP_man-pages.git] / original / man2 / move_pages.2
1 .\" This manpage is Copyright (C) 2006 Silicon Graphics, Inc.
2 .\"                               Christoph Lameter
3 .\"
4 .\" %%%LICENSE_START(VERBATIM_TWO_PARA)
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.
13 .\" %%%LICENSE_END
14 .\"
15 .\" FIXME Should programs normally be using move_pages() directly, or should
16 .\" they rather be using interfaces in the numactl package?
17 .\" (e.g., compare with recommendation in mbind(2)).
18 .\" Does this page need to give advise on this topic?
19 .TH MOVE_PAGES 2 2010-06-11 "Linux" "Linux Programmer's Manual"
20 .SH NAME
21 move_pages \- move individual pages of a process to another node
22 .SH SYNOPSIS
23 .nf
24 .B #include <numaif.h>
25 .sp
26 .BI "long move_pages(int " pid ", unsigned long count, void **" pages ,
27 .BI "                const int *" nodes ", int *" status ", int " flags );
28 .fi
29 .sp
30 Link with \fI\-lnuma\fP.
31 .SH DESCRIPTION
32 .BR move_pages ()
33 moves the specified
34 .I pages
35 of the process
36 .I pid
37 to the memory nodes specified by
38 .IR nodes .
39 The result of the move is reflected in
40 .IR status .
41 The
42 .I flags
43 indicate constraints on the pages to be moved.
44
45 .I pid
46 is the ID of the process in which pages are to be moved.
47 To move pages in another process,
48 the caller must be privileged
49 .RB ( CAP_SYS_NICE )
50 or the real or effective user ID of the calling process must match the
51 real or saved-set user ID of the target process.
52 If
53 .I pid
54 is 0, then
55 .BR move_pages ()
56 moves pages of the calling process.
57
58 .I count
59 is the number of pages to move.
60 It defines the size of the three arrays
61 .IR pages ,
62 .IR nodes ,
63 and
64 .IR status .
65
66 .I pages
67 is an array of pointers to the pages that should be moved.
68 These are pointers that should be aligned to page boundaries.
69 .\" FIXME Describe the result if pointers in the 'pages' array are
70 .\" not aligned to page boundaries
71 Addresses are specified as seen by the process specified by
72 .IR pid .
73
74 .I nodes
75 is an array of integers that specify the desired location for each page.
76 Each element in the array is a node number.
77 .I nodes
78 can also be NULL, in which case
79 .BR move_pages ()
80 does not move any pages but instead will return the node
81 where each page currently resides, in the
82 .I status
83 array.
84 Obtaining the status of each page may be necessary to determine
85 pages that need to be moved.
86
87 .I status
88 is an array of integers that return the status of each page.
89 The array contains valid values only if
90 .BR move_pages ()
91 did not return an error.
92
93 .I flags
94 specify what types of pages to move.
95 .B MPOL_MF_MOVE
96 means that only pages that are in exclusive use by the process
97 are to be moved.
98 .B MPOL_MF_MOVE_ALL
99 means that pages shared between multiple processes can also be moved.
100 The process must be privileged
101 .RB ( CAP_SYS_NICE )
102 to use
103 .BR MPOL_MF_MOVE_ALL .
104 .SS Page states in the status array
105 The following values can be returned in each element of the
106 .I status
107 array.
108 .TP
109 .B 0..MAX_NUMNODES
110 Identifies the node on which the page resides.
111 .TP
112 .B -EACCES
113 The page is mapped by multiple processes and can be moved only if
114 .B MPOL_MF_MOVE_ALL
115 is specified.
116 .TP
117 .B -EBUSY
118 The page is currently busy and cannot be moved.
119 Try again later.
120 This occurs if a page is undergoing I/O or another kernel subsystem
121 is holding a reference to the page.
122 .TP
123 .B -EFAULT
124 This is a zero page or the memory area is not mapped by the process.
125 .TP
126 .B -EIO
127 Unable to write back a page.
128 The page has to be written back
129 in order to move it since the page is dirty and the filesystem
130 does not provide a migration function that would allow the move
131 of dirty pages.
132 .TP
133 .B -EINVAL
134 A dirty page cannot be moved.
135 The filesystem does not
136 provide a migration function and has no ability to write back pages.
137 .TP
138 .B -ENOENT
139 The page is not present.
140 .TP
141 .B -ENOMEM
142 Unable to allocate memory on target node.
143 .SH RETURN VALUE
144 On success
145 .BR move_pages ()
146 returns zero.
147 .\" FIXME . Is the following quite true: does the wrapper in numactl
148 .\" do the right thing?
149 On error, it returns \-1, and sets
150 .I errno
151 to indicate the error.
152 .SH ERRORS
153 .TP
154 .B E2BIG
155 Too many pages to move.
156 .TP
157 .B EACCES
158 .\" FIXME Clarify "current cpuset" in the description of the EACCESS error.
159 .\" Is that the cpuset of the caller or the target?
160 One of the target nodes is not allowed by the current cpuset.
161 .TP
162 .B EFAULT
163 Parameter array could not be accessed.
164 .TP
165 .B EINVAL
166 Flags other than
167 .B MPOL_MF_MOVE
168 and
169 .B MPOL_MF_MOVE_ALL
170 was specified or an attempt was made to migrate pages of a kernel thread.
171 .TP
172 .B ENODEV
173 One of the target nodes is not online.
174 .TP
175 .B ENOENT
176 No pages were found that require moving.
177 All pages are either already
178 on the target node, not present, had an invalid address or could not be
179 moved because they were mapped by multiple processes.
180 .TP
181 .B EPERM
182 The caller specified
183 .B MPOL_MF_MOVE_ALL
184 without sufficient privileges
185 .RB ( CAP_SYS_NICE ).
186 Or, the caller attempted to move pages of a process belonging
187 to another user but did not have privilege to do so
188 .RB ( CAP_SYS_NICE ).
189 .TP
190 .B ESRCH
191 Process does not exist.
192 .SH VERSIONS
193 .BR move_pages ()
194 first appeared on Linux in version 2.6.18.
195 .SH CONFORMING TO
196 This system call is Linux-specific.
197 .SH NOTES
198 For information on library support, see
199 .BR numa (7).
200
201 Use
202 .BR get_mempolicy (2)
203 with the
204 .B MPOL_F_MEMS_ALLOWED
205 flag to obtain the set of nodes that are allowed by
206 .\" FIXME Clarify "current cpuset".  Is that the cpuset of the caller
207 .\" or the target?
208 the current cpuset.
209 Note that this information is subject to change at any
210 time by manual or automatic reconfiguration of the cpuset.
211
212 Use of this function may result in pages whose location
213 (node) violates the memory policy established for the
214 specified addresses (See
215 .BR mbind (2))
216 and/or the specified process (See
217 .BR set_mempolicy (2)).
218 That is, memory policy does not constrain the destination
219 nodes used by
220 .BR move_pages ().
221
222 The
223 .I <numaif.h>
224 header is not included with glibc, but requires installing
225 .I libnuma-devel
226 or a similar package.
227 .SH SEE ALSO
228 .BR get_mempolicy (2),
229 .BR mbind (2),
230 .BR set_mempolicy (2),
231 .BR numa (3),
232 .BR numa_maps (5),
233 .BR cpuset (7),
234 .BR numa (7),
235 .BR migratepages (8),
236 .BR numastat (8)
237 .SH COLOPHON
238 This page is part of release 3.79 of the Linux
239 .I man-pages
240 project.
241 A description of the project,
242 information about reporting bugs,
243 and the latest version of this page,
244 can be found at
245 \%http://www.kernel.org/doc/man\-pages/.