Section (2) get_mempolicy
get_mempolicy — retrieve NUMA memory policy for a thread
|unsigned long *nodemask,|
|unsigned long maxnode,|
|unsigned long flags
the NUMA policy of the calling thread or of a memory address,
depending on the setting of
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 thread.
specified as 0, then information about the calling thread_zsingle_quotesz_s
default policy (as set by set_mempolicy(2)) is
returned, in the buffers pointed to by
nodemask. The value returned in
these arguments may be used to restore the thread_zsingle_quotesz_s policy to
its state at the time of the call to
get_mempolicy() using set_mempolicy(2). When
flags is 0,
addr must be
specified as NULL.
since Linux 2.6.24), the
mode argument is ignored and
the set of nodes (memories) that the thread is allowed to
specify in subsequent calls to mbind(2) or set_mempolicy(2) (in the
absence of any mode
flags) is returned in
nodemask. It is not permitted
MPOL_F_ADDR, then information
is returned about the policy governing the memory address
policy may be different from the thread_zsingle_quotesz_s default policy if
mbind(2) or one of the
helper functions described in numa(3) has been used to
establish a policy for the memory range containing
argument is not NULL, then
get_mempolicy() will store the policy mode
and any optional mode
flags of the requested NUMA policy in the
location pointed to by this argument. If
nodemask is not NULL, then the
nodemask associated with the policy will be stored in the
location pointed to by this argument.
maxnode specifies the number of
node IDs that can be stored into
nodemask—that is, the
maximum node ID plus one. The value specified by
maxnode is always rounded to a
multiple of sizeof(unsigned
get_mempolicy() will return the node ID of
the node on which the address
addr is allocated into the
location pointed to by
mode. If no page has yet been
allocated for the specified address,
get_mempolicy() will allocate a page as if
the thread had performed a read (load) access to that
address, and return the ID of the node where that page was
MPOL_F_NODE, but not
MPOL_F_ADDR, and the thread_zsingle_quotesz_s
current policy is
get_mempolicy() will return in the location
pointed to by a non-NULL
mode argument, the node ID of
the next node that will be used for interleaving of internal
kernel pages allocated on behalf of the thread. These
allocations include pages for memory-mapped files in process
memory ranges mapped using the mmap(2) call with the
MAP_PRIVATE flag for read
accesses, and in memory ranges mapped with the
MAP_SHARED flag for all accesses.
Other flag values are reserved.
For an overview of the possible policies see set_mempolicy(2).
returns 0; on error, −1 is returned and
errno is set to indicate the error.
Part of all of the memory range specified by
maxnodepoints outside your accessible address space.
The value specified by
maxnodeis less than the number of node IDs supported by the system. Or
flagsspecified values other than
addris NULL, or
flagsdid not specify
addris not NULL. Or,
MPOL_F_ADDRand the current thread policy is not
MPOL_F_NODE. (And there are other EINVAL cases.)
For information on library support, see numa(7).
This page is part of release 4.16 of the Linux
man-pages project. A
description of the project, information about reporting bugs,
and the latest version of this page, can be found at
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.Schermerhornhp.com>
more precise specification of behavior.