man-pages/man2/get_mempolicy.2

167 lines
4.4 KiB
Groff

.\" Copyright 2003,2004 Andi Kleen, SuSE Labs.
.\"
.\" Permission is granted to make and distribute verbatim copies of this
.\" manual provided the copyright notice and this permission notice are
.\" preserved on all copies.
.\"
.\" Permission is granted to copy and distribute modified versions of this
.\" manual under the conditions for verbatim copying, provided that the
.\" entire resulting derived work is distributed under the terms of a
.\" permission notice identical to this one.
.\"
.\" Since the Linux kernel and libraries are constantly changing, this
.\" manual page may be incorrect or out-of-date. The author(s) assume no
.\" responsibility for errors or omissions, or for damages resulting from
.\" the use of the information contained herein.
.\"
.\" Formatted or processed versions of this manual, if unaccompanied by
.\" the source, must acknowledge the copyright and authors of this work.
.\"
.\" 2006-02-03, mtk, substantial wording changes and other improvements
.\"
.TH GET_MEMPOLICY 2 "2006-02-07" "SuSE Labs" "Linux Programmer's Manual"
.SH SYNOPSIS
get_mempolicy \- Retrieve NUMA memory policy for a process
.SH NAME
.B "#include <numaif.h>"
.nf
.sp
.BI "int get_mempolicy(int *" policy ", unsigned long *" nodemask ,
.BI " unsigned long " maxnode ", unsigned long " addr ,
.BI " unsigned long " flags );
.fi
.\" TBD rewrite this. it is confusing.
.SH DESCRIPTION
.BR get_mempolicy ()
retrieves the NUMA policy of the calling process or of a memory address,
depending on the setting of
.IR flags .
A NUMA machine has different
memory controllers with different distances to specific CPUs.
The memory policy defines in which node memory is allocated for
the process.
If
.IR flags
is specified as 0,
then information about the calling process's default policy
(as set by
.BR set_mempolicy (2))
is returned.
If
.I flags
specifies
.BR MPOL_F_ADDR ,
then information is returned about the policy governing the memory
address given in
.IR addr .
This policy may be different from the process's default policy if
.BR set_mempolicy (2)
has been used to establish a policy for the page containing
.IR addr .
If
.I policy
is not NULL, then it is used to return the policy.
If
.IR nodemask
is not NULL, then it is used to return the nodemask associated
with the policy.
.I maxnode
is the maximum bit number plus one that can be stored into
.IR nodemask .
The bit number is always rounded to a multiple of
.IR "unsigned long" .
.\"
.\" If
.\" .I flags
.\" specifies both
.\" .B MPOL_F_NODE
.\" and
.\" .BR MPOL_F_ADDR ,
.\" then
.\" .I policy
.\" instead returns the number of the node on which the address
.\" .I addr
.\" is allocated.
.\"
.\" If
.\" .I flags
.\" specifies
.\" .B MPOL_F_NODE
.\" but not
.\" .BR MPOL_F_ADDR ,
.\" and the process's current policy is
.\" .BR MPOL_INTERLEAVE ,
.\" then
.\" checkme: Andi's text below says that the info is returned in
.\" 'nodemask', not 'policy':
.\" .I policy
.\" instead returns the number of the next node that will be used for
.\" interleaving allocation.
.\" FIXME .
.\" The other valid flag is
.\" .I MPOL_F_NODE.
.\" It is only valid when the policy is
.\" .I MPOL_INTERLEAVE.
.\" In this case not the interleave mask, but an unsigned long with the next
.\" node that would be used for interleaving is returned in
.\" .I nodemask.
.\" Other flag values are reserved.
For an overview of the possible policies see
.BR set_mempolicy (2).
.SH RETURN VALUE
On success,
.BR get_mempolicy ()
returns 0;
on error, \-1 is returned and
.I errno
is set to indicate the error.
.\" .SH ERRORS
.\" FIXME writeme -- no errors are listed on this page
.\" .
.\" .TP
.\" .B EINVAL
.\" .I nodemask
.\" is non-NULL, and
.\" .I maxnode
.\" is too small;
.\" or
.\" .I flags
.\" specified values other than
.\" .B MPOL_F_NODE
.\" or
.\" .BR MPOL_F_ADDR ;
.\" or
.\" .I flags
.\" specified
.\" .B MPOL_F_ADDR
.\" and
.\" .I addr
.\" is NULL.
.\" (And there are other EINVAL cases.)
.SH NOTES
This manual page is incomplete:
it does not document the details the
.BR MPOL_F_NODE
flag,
which modifies the operation of
.BR get_mempolicy ().
This is deliberate: this flag is not intended for application use,
and its operation may change or it may be removed altogether in
future kernel versions.
.B Do not use it.
.SH "VERSIONS AND LIBRARY SUPPORT"
See
.BR mbind (2).
.SH CONFORMING TO
This system call is Linux specific.
.SH SEE ALSO
.BR mbind (2),
.BR set_mempolicy (2),
.BR numactl (8),
.BR numa (3)