man-pages/man2/get_mempolicy.2

226 lines
6.0 KiB
Groff
Raw Normal View History

.\" Copyright 2003,2004 Andi Kleen, SuSE Labs.
.\" and Copyright 2007 Lee Schermerhorn, Hewlett Packard
.\"
.\" 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
.\" 2007-08-27, Lee Schermerhorn <Lee.Schermerhorn@hp.com>
.\" more precise specification of behavior.
.\"
2007-08-27 11:34:07 +00:00
.TH GET_MEMPOLICY 2 2007-08-27 Linux "Linux Programmer's Manual"
.SH NAME
2007-05-18 11:01:49 +00:00
get_mempolicy \- Retrieve NUMA memory policy for a process
.SH SYNOPSIS
.B "#include <numaif.h>"
.nf
.sp
.BI "int get_mempolicy(int *" mode ", unsigned long *" nodemask ,
.BI " unsigned long " maxnode ", unsigned long " addr ,
.BI " unsigned long " flags );
.sp
2007-08-27 11:34:07 +00:00
Link with \fI\-lnuma\fP
.fi
.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 from 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 mbind (2)
or one of the helper functions described in
2007-08-27 11:34:07 +00:00
.BR numa (3)
has been used to establish a policy for the memory range containing
.IR addr .
If the
.I mode
argument is not NULL, then
.IR get_mempolicy ()
will store the policy mode of the requested NUMA policy in the location
pointed to by this argument.
If
.IR nodemask
is not NULL, then the nodemask associated with the policy will be stored
in the location pointed to by this argument.
.I maxnode
2007-08-27 11:34:07 +00:00
specifies the number of node IDs
that can be stored into
.IR nodemask \(emthat
2007-08-27 11:34:07 +00:00
is, the maximum node ID plus one.
The value specified by
.I maxnode
is always rounded to a multiple of
.IR "sizeof(unsigned long)" .
If
.I flags
specifies both
.B MPOL_F_NODE
and
.BR MPOL_F_ADDR ,
.IR get_mempolicy ()
2007-08-27 11:34:07 +00:00
will return the node ID of the node on which the address
.I addr
is allocated into the location pointed to by
.IR mode .
If no page has yet been allocated for the specified address,
.IR get_mempolicy ()
will allocate a page as if the process had performed a read
2007-08-27 11:34:07 +00:00
[load] access to that address, and return the ID of the node
where that page was allocated.
If
.I flags
specifies
.BR MPOL_F_NODE ,
but not
.BR MPOL_F_ADDR ,
and the process's current policy is
.BR MPOL_INTERLEAVE ,
then
.IR get_mempolicy ()
will return in the location pointed to by a non-NULL
.I mode
argument,
2007-08-27 11:34:07 +00:00
the node ID of the next node that will be used for
interleaving of internal kernel pages allocated on behalf of the process.
2007-08-27 11:34:07 +00:00
.\" Note: code returns next interleave node via 'mode' argument -Lee Schermerhorn
These allocations include pages for memory mapped files in
process memory ranges mapped using the
.IR mmap (2)
call with the
2007-08-27 11:34:07 +00:00
.B MAP_PRIVATE
flag for read accesses, and in memory ranges mapped with the
2007-08-27 11:34:07 +00:00
.B MAP_SHARED
flag for all accesses.
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
.TP
.B EINVAL
The value specified by
.I maxnode
2007-08-27 11:34:07 +00:00
is less than the number of node IDs supported by the system.
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,
or
.I flags
did not specify
.B MPOL_F_ADDR
and
.I addr
is not NULL.
Or,
.I flags
specified
.B MPOL_F_NODE
but not
.B MPOL_F_ADDR
and the current process policy is not
.BR MPOL_INTERLEAVE .
(And there are other EINVAL cases.)
.TP
.B EFAULT
Part of all of the memory range specified by
.I nodemask
and
.I maxnode
points outside your accessible address space.
.SH NOTES
If the mode of the process policy or the policy governing allocations at the
specified address is
2007-08-27 11:34:07 +00:00
.B MPOL_PREFERRED
and this policy was installed with an empty
.IR nodemask \(emspecifying
local allocation,
.IR get_mempolicy ()
2007-08-27 11:34:07 +00:00
will return the mask of on-line node IDs in the location pointed to by
a non-NULL
.I nodemask
argument.
This mask does not take into consideration any adminstratively imposed
2007-08-27 11:34:07 +00:00
restrictions on the process's context.
.\" FIXME:
2007-08-27 11:34:07 +00:00
.\" "context" above refers to cpusets.
.\" No man page to reference. --Lee Schermerhorn
.\"
.\" Christoph says the following is untrue. These are "fully supported."
.\" Andi concedes that he has lost this battle and approves [?]
2007-08-27 11:34:07 +00:00
.\" updating the man pages to document the behavior. --Lee Schermerhorn
.\" 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.
2007-05-16 03:15:20 +00:00
.SS "Versions and Library Support"
See
.BR mbind (2).
.SH SEE ALSO
.BR mbind (2),
.BR mmap (2),
.BR set_mempolicy (2),
.BR numactl (8),
.BR numa (3)