Blame man2/move_pages.2

Packit 7cfc04
.\" This manpage is Copyright (C) 2006 Silicon Graphics, Inc.
Packit 7cfc04
.\"                               Christoph Lameter
Packit 7cfc04
.\"
Packit 7cfc04
.\" %%%LICENSE_START(VERBATIM_TWO_PARA)
Packit 7cfc04
.\" Permission is granted to make and distribute verbatim copies of this
Packit 7cfc04
.\" manual provided the copyright notice and this permission notice are
Packit 7cfc04
.\" preserved on all copies.
Packit 7cfc04
.\"
Packit 7cfc04
.\" Permission is granted to copy and distribute modified versions of this
Packit 7cfc04
.\" manual under the conditions for verbatim copying, provided that the
Packit 7cfc04
.\" entire resulting derived work is distributed under the terms of a
Packit 7cfc04
.\" permission notice identical to this one.
Packit 7cfc04
.\" %%%LICENSE_END
Packit 7cfc04
.\"
Packit 7cfc04
.\" FIXME Should programs normally be using move_pages() directly, or should
Packit 7cfc04
.\" they rather be using interfaces in the numactl package?
Packit 7cfc04
.\" (e.g., compare with recommendation in mbind(2)).
Packit 7cfc04
.\" Does this page need to give advice on this topic?
Packit 7cfc04
.\"
Packit 7cfc04
.TH MOVE_PAGES 2 2017-09-15 "Linux" "Linux Programmer's Manual"
Packit 7cfc04
.SH NAME
Packit 7cfc04
move_pages \- move individual pages of a process to another node
Packit 7cfc04
.SH SYNOPSIS
Packit 7cfc04
.nf
Packit 7cfc04
.B #include <numaif.h>
Packit 7cfc04
.PP
Packit 7cfc04
.BI "long move_pages(int " pid ", unsigned long count, void **" pages ,
Packit 7cfc04
.BI "                const int *" nodes ", int *" status ", int " flags );
Packit 7cfc04
.fi
Packit 7cfc04
.PP
Packit 7cfc04
Link with \fI\-lnuma\fP.
Packit 7cfc04
.SH DESCRIPTION
Packit 7cfc04
.BR move_pages ()
Packit 7cfc04
moves the specified
Packit 7cfc04
.I pages
Packit 7cfc04
of the process
Packit 7cfc04
.I pid
Packit 7cfc04
to the memory nodes specified by
Packit 7cfc04
.IR nodes .
Packit 7cfc04
The result of the move is reflected in
Packit 7cfc04
.IR status .
Packit 7cfc04
The
Packit 7cfc04
.I flags
Packit 7cfc04
indicate constraints on the pages to be moved.
Packit 7cfc04
.PP
Packit 7cfc04
.I pid
Packit 7cfc04
is the ID of the process in which pages are to be moved.
Packit 7cfc04
If
Packit 7cfc04
.I pid
Packit 7cfc04
is 0, then
Packit 7cfc04
.BR move_pages ()
Packit 7cfc04
moves pages of the calling process.
Packit 7cfc04
.PP
Packit 7cfc04
To move pages in another process requires the following privileges:
Packit 7cfc04
.IP * 3
Packit 7cfc04
In kernels up to and including Linux 4.12:
Packit 7cfc04
the caller must be privileged
Packit 7cfc04
.RB ( CAP_SYS_NICE )
Packit 7cfc04
or the real or effective user ID of the calling process must match the
Packit 7cfc04
real or saved-set user ID of the target process.
Packit 7cfc04
.IP *
Packit 7cfc04
The older rules allowed the caller to discover various
Packit 7cfc04
virtual address choices made by the kernel that could lead
Packit 7cfc04
to the defeat of address-space-layout randomization
Packit 7cfc04
for a process owned by the same UID as the caller,
Packit 7cfc04
the rules were changed starting with Linux 4.13.
Packit 7cfc04
Since Linux 4.13,
Packit 7cfc04
.\" commit 197e7e521384a23b9e585178f3f11c9fa08274b9
Packit 7cfc04
permission is governed by a ptrace access mode
Packit 7cfc04
.B PTRACE_MODE_READ_REALCREDS
Packit 7cfc04
check with respect to the target process; see
Packit 7cfc04
.BR ptrace (2).
Packit 7cfc04
.PP
Packit 7cfc04
.I count
Packit 7cfc04
is the number of pages to move.
Packit 7cfc04
It defines the size of the three arrays
Packit 7cfc04
.IR pages ,
Packit 7cfc04
.IR nodes ,
Packit 7cfc04
and
Packit 7cfc04
.IR status .
Packit 7cfc04
.PP
Packit 7cfc04
.I pages
Packit 7cfc04
is an array of pointers to the pages that should be moved.
Packit 7cfc04
These are pointers that should be aligned to page boundaries.
Packit 7cfc04
.\" FIXME Describe the result if pointers in the 'pages' array are
Packit 7cfc04
.\" not aligned to page boundaries
Packit 7cfc04
Addresses are specified as seen by the process specified by
Packit 7cfc04
.IR pid .
Packit 7cfc04
.PP
Packit 7cfc04
.I nodes
Packit 7cfc04
is an array of integers that specify the desired location for each page.
Packit 7cfc04
Each element in the array is a node number.
Packit 7cfc04
.I nodes
Packit 7cfc04
can also be NULL, in which case
Packit 7cfc04
.BR move_pages ()
Packit 7cfc04
does not move any pages but instead will return the node
Packit 7cfc04
where each page currently resides, in the
Packit 7cfc04
.I status
Packit 7cfc04
array.
Packit 7cfc04
Obtaining the status of each page may be necessary to determine
Packit 7cfc04
pages that need to be moved.
Packit 7cfc04
.PP
Packit 7cfc04
.I status
Packit 7cfc04
is an array of integers that return the status of each page.
Packit 7cfc04
The array contains valid values only if
Packit 7cfc04
.BR move_pages ()
Packit 7cfc04
did not return an error.
Packit 7cfc04
.PP
Packit 7cfc04
.I flags
Packit 7cfc04
specify what types of pages to move.
Packit 7cfc04
.B MPOL_MF_MOVE
Packit 7cfc04
means that only pages that are in exclusive use by the process
Packit 7cfc04
are to be moved.
Packit 7cfc04
.B MPOL_MF_MOVE_ALL
Packit 7cfc04
means that pages shared between multiple processes can also be moved.
Packit 7cfc04
The process must be privileged
Packit 7cfc04
.RB ( CAP_SYS_NICE )
Packit 7cfc04
to use
Packit 7cfc04
.BR MPOL_MF_MOVE_ALL .
Packit 7cfc04
.SS Page states in the status array
Packit 7cfc04
The following values can be returned in each element of the
Packit 7cfc04
.I status
Packit 7cfc04
array.
Packit 7cfc04
.TP
Packit 7cfc04
.B 0..MAX_NUMNODES
Packit 7cfc04
Identifies the node on which the page resides.
Packit 7cfc04
.TP
Packit 7cfc04
.B -EACCES
Packit 7cfc04
The page is mapped by multiple processes and can be moved only if
Packit 7cfc04
.B MPOL_MF_MOVE_ALL
Packit 7cfc04
is specified.
Packit 7cfc04
.TP
Packit 7cfc04
.B -EBUSY
Packit 7cfc04
The page is currently busy and cannot be moved.
Packit 7cfc04
Try again later.
Packit 7cfc04
This occurs if a page is undergoing I/O or another kernel subsystem
Packit 7cfc04
is holding a reference to the page.
Packit 7cfc04
.TP
Packit 7cfc04
.B -EFAULT
Packit 7cfc04
This is a zero page or the memory area is not mapped by the process.
Packit 7cfc04
.TP
Packit 7cfc04
.B -EIO
Packit 7cfc04
Unable to write back a page.
Packit 7cfc04
The page has to be written back
Packit 7cfc04
in order to move it since the page is dirty and the filesystem
Packit 7cfc04
does not provide a migration function that would allow the move
Packit 7cfc04
of dirty pages.
Packit 7cfc04
.TP
Packit 7cfc04
.B -EINVAL
Packit 7cfc04
A dirty page cannot be moved.
Packit 7cfc04
The filesystem does not
Packit 7cfc04
provide a migration function and has no ability to write back pages.
Packit 7cfc04
.TP
Packit 7cfc04
.B -ENOENT
Packit 7cfc04
The page is not present.
Packit 7cfc04
.TP
Packit 7cfc04
.B -ENOMEM
Packit 7cfc04
Unable to allocate memory on target node.
Packit 7cfc04
.SH RETURN VALUE
Packit 7cfc04
On success
Packit 7cfc04
.BR move_pages ()
Packit 7cfc04
returns zero.
Packit 7cfc04
.\" FIXME . Is the following quite true: does the wrapper in numactl
Packit 7cfc04
.\" do the right thing?
Packit 7cfc04
On error, it returns \-1, and sets
Packit 7cfc04
.I errno
Packit 7cfc04
to indicate the error.
Packit 7cfc04
.SH ERRORS
Packit 7cfc04
.TP
Packit 7cfc04
.B E2BIG
Packit 7cfc04
Too many pages to move.
Packit 7cfc04
.TP
Packit 7cfc04
.B EACCES
Packit 7cfc04
.\" FIXME Clarify "current cpuset" in the description of the EACCESS error.
Packit 7cfc04
.\" Is that the cpuset of the caller or the target?
Packit 7cfc04
One of the target nodes is not allowed by the current cpuset.
Packit 7cfc04
.TP
Packit 7cfc04
.B EFAULT
Packit 7cfc04
Parameter array could not be accessed.
Packit 7cfc04
.TP
Packit 7cfc04
.B EINVAL
Packit 7cfc04
Flags other than
Packit 7cfc04
.B MPOL_MF_MOVE
Packit 7cfc04
and
Packit 7cfc04
.B MPOL_MF_MOVE_ALL
Packit 7cfc04
was specified or an attempt was made to migrate pages of a kernel thread.
Packit 7cfc04
.TP
Packit 7cfc04
.B ENODEV
Packit 7cfc04
One of the target nodes is not online.
Packit 7cfc04
.TP
Packit 7cfc04
.B ENOENT
Packit 7cfc04
No pages were found that require moving.
Packit 7cfc04
All pages are either already
Packit 7cfc04
on the target node, not present, had an invalid address or could not be
Packit 7cfc04
moved because they were mapped by multiple processes.
Packit 7cfc04
.TP
Packit 7cfc04
.B EPERM
Packit 7cfc04
The caller specified
Packit 7cfc04
.B MPOL_MF_MOVE_ALL
Packit 7cfc04
without sufficient privileges
Packit 7cfc04
.RB ( CAP_SYS_NICE ).
Packit 7cfc04
Or, the caller attempted to move pages of a process belonging
Packit 7cfc04
to another user but did not have privilege to do so
Packit 7cfc04
.RB ( CAP_SYS_NICE ).
Packit 7cfc04
.TP
Packit 7cfc04
.B ESRCH
Packit 7cfc04
Process does not exist.
Packit 7cfc04
.SH VERSIONS
Packit 7cfc04
.BR move_pages ()
Packit 7cfc04
first appeared on Linux in version 2.6.18.
Packit 7cfc04
.SH CONFORMING TO
Packit 7cfc04
This system call is Linux-specific.
Packit 7cfc04
.SH NOTES
Packit 7cfc04
For information on library support, see
Packit 7cfc04
.BR numa (7).
Packit 7cfc04
.PP
Packit 7cfc04
Use
Packit 7cfc04
.BR get_mempolicy (2)
Packit 7cfc04
with the
Packit 7cfc04
.B MPOL_F_MEMS_ALLOWED
Packit 7cfc04
flag to obtain the set of nodes that are allowed by
Packit 7cfc04
.\" FIXME Clarify "current cpuset".  Is that the cpuset of the caller
Packit 7cfc04
.\" or the target?
Packit 7cfc04
the current cpuset.
Packit 7cfc04
Note that this information is subject to change at any
Packit 7cfc04
time by manual or automatic reconfiguration of the cpuset.
Packit 7cfc04
.PP
Packit 7cfc04
Use of this function may result in pages whose location
Packit 7cfc04
(node) violates the memory policy established for the
Packit 7cfc04
specified addresses (See
Packit 7cfc04
.BR mbind (2))
Packit 7cfc04
and/or the specified process (See
Packit 7cfc04
.BR set_mempolicy (2)).
Packit 7cfc04
That is, memory policy does not constrain the destination
Packit 7cfc04
nodes used by
Packit 7cfc04
.BR move_pages ().
Packit 7cfc04
.PP
Packit 7cfc04
The
Packit 7cfc04
.I <numaif.h>
Packit 7cfc04
header is not included with glibc, but requires installing
Packit 7cfc04
.I libnuma-devel
Packit 7cfc04
or a similar package.
Packit 7cfc04
.SH SEE ALSO
Packit 7cfc04
.BR get_mempolicy (2),
Packit 7cfc04
.BR mbind (2),
Packit 7cfc04
.BR set_mempolicy (2),
Packit 7cfc04
.BR numa (3),
Packit 7cfc04
.BR numa_maps (5),
Packit 7cfc04
.BR cpuset (7),
Packit 7cfc04
.BR numa (7),
Packit 7cfc04
.BR migratepages (8),
Packit 7cfc04
.BR numastat (8)
Packit 7cfc04
.SH COLOPHON
Packit 7cfc04
This page is part of release 4.15 of the Linux
Packit 7cfc04
.I man-pages
Packit 7cfc04
project.
Packit 7cfc04
A description of the project,
Packit 7cfc04
information about reporting bugs,
Packit 7cfc04
and the latest version of this page,
Packit 7cfc04
can be found at
Packit 7cfc04
\%https://www.kernel.org/doc/man\-pages/.