2006-02-08 03:20:44 +00:00
|
|
|
.\" Copyright 2003,2004 Andi Kleen, SuSE Labs.
|
2007-08-27 11:09:06 +00:00
|
|
|
.\" and Copyright 2007 Lee Schermerhorn, Hewlett Packard
|
2006-02-08 03:20:44 +00:00
|
|
|
.\"
|
2013-03-10 09:29:06 +00:00
|
|
|
.\" %%%LICENSE_START(VERBATIM_PROF)
|
2006-02-08 03:20:44 +00:00
|
|
|
.\" 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.
|
2007-04-12 22:42:49 +00:00
|
|
|
.\"
|
2006-02-08 03:20:44 +00:00
|
|
|
.\" 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
|
2007-04-12 22:42:49 +00:00
|
|
|
.\" the use of the information contained herein.
|
|
|
|
.\"
|
2006-02-08 03:20:44 +00:00
|
|
|
.\" Formatted or processed versions of this manual, if unaccompanied by
|
|
|
|
.\" the source, must acknowledge the copyright and authors of this work.
|
2013-03-10 09:29:06 +00:00
|
|
|
.\" %%%LICENSE_END
|
2007-04-12 22:42:49 +00:00
|
|
|
.\"
|
2006-02-08 03:20:44 +00:00
|
|
|
.\" 2006-02-03, mtk, substantial wording changes and other improvements
|
2007-08-27 11:09:06 +00:00
|
|
|
.\" 2007-08-27, Lee Schermerhorn <Lee.Schermerhorn@hp.com>
|
|
|
|
.\" more precise specification of behavior.
|
2006-02-08 03:20:44 +00:00
|
|
|
.\"
|
ldd.1, localedef.1, add_key.2, chroot.2, clone.2, fork.2, futex.2, get_mempolicy.2, get_robust_list.2, getitimer.2, getpriority.2, ioctl.2, ioctl_ficlonerange.2, ioctl_fideduperange.2, kcmp.2, kill.2, lookup_dcookie.2, mmap.2, mount.2, open.2, pciconfig_read.2, perf_event_open.2, prctl.2, process_vm_readv.2, ptrace.2, quotactl.2, recv.2, setfsgid.2, setfsuid.2, sysinfo.2, umask.2, umount.2, unshare.2, utimensat.2, wait.2, assert.3, fmax.3, fmin.3, getauxval.3, inet_pton.3, malloc_hook.3, memmem.3, mkdtemp.3, mktemp.3, printf.3, strcasecmp.3, strcat.3, strtoul.3, strxfrm.3, console_codes.4, console_ioctl.4, lirc.4, tty.4, vcs.4, charmap.5, elf.5, locale.5, proc.5, repertoiremap.5, utmp.5, capabilities.7, cgroup_namespaces.7, cgroups.7, charsets.7, cp1251.7, cp1252.7, credentials.7, feature_test_macros.7, iso_8859-1.7, iso_8859-15.7, iso_8859-5.7, koi8-r.7, koi8-u.7, man-pages.7, mount_namespaces.7, namespaces.7, netlink.7, pid_namespaces.7, unix.7, user_namespaces.7, utf-8.7: tstamp
Signed-off-by: Michael Kerrisk <mtk.manpages@gmail.com>
2016-07-17 16:07:58 +00:00
|
|
|
.TH GET_MEMPOLICY 2 2016-07-17 Linux "Linux Programmer's Manual"
|
2006-02-08 03:20:44 +00:00
|
|
|
.SH NAME
|
2015-04-30 10:31:09 +00:00
|
|
|
get_mempolicy \- retrieve NUMA memory policy for a thread
|
2007-05-18 11:01:49 +00:00
|
|
|
.SH SYNOPSIS
|
2007-04-12 22:42:49 +00:00
|
|
|
.B "#include <numaif.h>"
|
2006-08-04 09:41:28 +00:00
|
|
|
.nf
|
2006-02-08 03:20:44 +00:00
|
|
|
.sp
|
2007-08-27 11:09:06 +00:00
|
|
|
.BI "int get_mempolicy(int *" mode ", unsigned long *" nodemask ,
|
2016-06-03 02:18:16 +00:00
|
|
|
.BI " unsigned long " maxnode ", void *" addr ,
|
2006-08-04 09:41:28 +00:00
|
|
|
.BI " unsigned long " flags );
|
2007-08-27 11:09:06 +00:00
|
|
|
.sp
|
2009-02-23 18:40:41 +00:00
|
|
|
Link with \fI\-lnuma\fP.
|
2006-08-04 09:41:28 +00:00
|
|
|
.fi
|
2006-02-08 03:20:44 +00:00
|
|
|
.SH DESCRIPTION
|
|
|
|
.BR get_mempolicy ()
|
2015-04-30 10:31:09 +00:00
|
|
|
retrieves the NUMA policy of the calling thread or of a memory address,
|
2006-02-08 03:20:44 +00:00
|
|
|
depending on the setting of
|
|
|
|
.IR flags .
|
|
|
|
|
|
|
|
A NUMA machine has different
|
|
|
|
memory controllers with different distances to specific CPUs.
|
2007-08-27 11:09:06 +00:00
|
|
|
The memory policy defines from which node memory is allocated for
|
2015-04-30 10:31:09 +00:00
|
|
|
the thread.
|
2006-02-08 03:20:44 +00:00
|
|
|
|
|
|
|
If
|
2007-09-20 16:26:31 +00:00
|
|
|
.I flags
|
2006-02-08 03:20:44 +00:00
|
|
|
is specified as 0,
|
2015-04-30 10:31:09 +00:00
|
|
|
then information about the calling thread's default policy
|
2006-02-08 03:20:44 +00:00
|
|
|
(as set by
|
|
|
|
.BR set_mempolicy (2))
|
2016-10-13 07:56:55 +00:00
|
|
|
is returned, in the buffers pointed to by
|
2016-10-13 07:40:44 +00:00
|
|
|
.I mode
|
2008-08-08 19:47:20 +00:00
|
|
|
and
|
2016-10-13 07:56:55 +00:00
|
|
|
.IR nodemask .
|
|
|
|
The value returned in these arguments
|
2015-04-30 10:31:09 +00:00
|
|
|
may be used to restore the thread's policy to its state at
|
2008-08-08 19:47:20 +00:00
|
|
|
the time of the call to
|
|
|
|
.BR get_mempolicy ()
|
|
|
|
using
|
|
|
|
.BR set_mempolicy (2).
|
2016-10-13 07:58:03 +00:00
|
|
|
When
|
|
|
|
.I flags
|
|
|
|
is 0,
|
|
|
|
.I addr
|
|
|
|
must be specified as NULL.
|
2006-02-08 03:20:44 +00:00
|
|
|
|
2008-08-08 20:02:56 +00:00
|
|
|
If
|
|
|
|
.I flags
|
|
|
|
specifies
|
2008-08-12 10:27:05 +00:00
|
|
|
.BR MPOL_F_MEMS_ALLOWED
|
2008-08-08 20:02:56 +00:00
|
|
|
(available since Linux 2.6.24), the
|
|
|
|
.I mode
|
2016-10-13 07:40:21 +00:00
|
|
|
argument is ignored and the set of nodes (memories) that the
|
2015-04-30 10:31:09 +00:00
|
|
|
thread is allowed to specify in subsequent calls to
|
2008-08-08 20:02:56 +00:00
|
|
|
.BR mbind (2)
|
|
|
|
or
|
|
|
|
.BR set_mempolicy (2)
|
2016-10-13 07:40:21 +00:00
|
|
|
(in the absence of any
|
|
|
|
.IR "mode flags" )
|
2008-08-08 20:02:56 +00:00
|
|
|
is returned in
|
|
|
|
.IR nodemask .
|
|
|
|
It is not permitted to combine
|
|
|
|
.B MPOL_F_MEMS_ALLOWED
|
|
|
|
with either
|
|
|
|
.B MPOL_F_ADDR
|
|
|
|
or
|
|
|
|
.BR MPOL_F_NODE .
|
|
|
|
|
2007-04-12 22:42:49 +00:00
|
|
|
If
|
2006-02-08 03:20:44 +00:00
|
|
|
.I flags
|
|
|
|
specifies
|
|
|
|
.BR MPOL_F_ADDR ,
|
|
|
|
then information is returned about the policy governing the memory
|
|
|
|
address given in
|
|
|
|
.IR addr .
|
2015-04-30 10:31:09 +00:00
|
|
|
This policy may be different from the thread's default policy if
|
2007-08-27 11:09:06 +00:00
|
|
|
.BR mbind (2)
|
|
|
|
or one of the helper functions described in
|
2007-08-27 11:34:07 +00:00
|
|
|
.BR numa (3)
|
2007-08-27 11:09:06 +00:00
|
|
|
has been used to establish a policy for the memory range containing
|
2006-02-08 03:20:44 +00:00
|
|
|
.IR addr .
|
|
|
|
|
2007-08-27 11:09:06 +00:00
|
|
|
If the
|
|
|
|
.I mode
|
|
|
|
argument is not NULL, then
|
2007-12-20 11:25:58 +00:00
|
|
|
.BR get_mempolicy ()
|
2008-08-08 19:47:20 +00:00
|
|
|
will store the policy mode and any optional
|
|
|
|
.I "mode flags"
|
|
|
|
of the requested NUMA policy in the location pointed to by this argument.
|
2007-04-12 22:42:49 +00:00
|
|
|
If
|
2007-09-20 16:26:31 +00:00
|
|
|
.I nodemask
|
2007-08-27 11:09:06 +00:00
|
|
|
is not NULL, then the nodemask associated with the policy will be stored
|
|
|
|
in the location pointed to by this argument.
|
2007-04-12 22:42:49 +00:00
|
|
|
.I maxnode
|
2007-08-27 11:34:07 +00:00
|
|
|
specifies the number of node IDs
|
2007-08-27 11:09:06 +00:00
|
|
|
that can be stored into
|
|
|
|
.IR nodemask \(emthat
|
2007-08-27 11:34:07 +00:00
|
|
|
is, the maximum node ID plus one.
|
2007-08-27 11:09:06 +00:00
|
|
|
The value specified by
|
|
|
|
.I maxnode
|
|
|
|
is always rounded to a multiple of
|
2016-06-03 02:32:22 +00:00
|
|
|
.IR "sizeof(unsigned\ long)*8" .
|
2007-08-27 11:09:06 +00:00
|
|
|
|
|
|
|
If
|
|
|
|
.I flags
|
|
|
|
specifies both
|
|
|
|
.B MPOL_F_NODE
|
|
|
|
and
|
|
|
|
.BR MPOL_F_ADDR ,
|
2007-12-20 11:25:58 +00:00
|
|
|
.BR get_mempolicy ()
|
2007-08-27 11:34:07 +00:00
|
|
|
will return the node ID of the node on which the address
|
2007-08-27 11:09:06 +00:00
|
|
|
.I addr
|
|
|
|
is allocated into the location pointed to by
|
|
|
|
.IR mode .
|
|
|
|
If no page has yet been allocated for the specified address,
|
2007-12-20 11:25:58 +00:00
|
|
|
.BR get_mempolicy ()
|
2015-04-30 10:31:09 +00:00
|
|
|
will allocate a page as if the thread had performed a read
|
2016-10-13 07:40:21 +00:00
|
|
|
(load) access to that address, and return the ID of the node
|
2007-08-27 11:09:06 +00:00
|
|
|
where that page was allocated.
|
|
|
|
|
|
|
|
If
|
|
|
|
.I flags
|
|
|
|
specifies
|
|
|
|
.BR MPOL_F_NODE ,
|
|
|
|
but not
|
|
|
|
.BR MPOL_F_ADDR ,
|
2015-04-30 10:31:09 +00:00
|
|
|
and the thread's current policy is
|
2007-08-27 11:09:06 +00:00
|
|
|
.BR MPOL_INTERLEAVE ,
|
|
|
|
then
|
2007-12-20 11:25:58 +00:00
|
|
|
.BR get_mempolicy ()
|
2007-08-27 11:09:06 +00:00
|
|
|
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
|
2015-04-30 10:31:09 +00:00
|
|
|
interleaving of internal kernel pages allocated on behalf of the thread.
|
2007-08-27 11:34:07 +00:00
|
|
|
.\" Note: code returns next interleave node via 'mode' argument -Lee Schermerhorn
|
2014-01-04 22:00:31 +00:00
|
|
|
These allocations include pages for memory-mapped files in
|
2007-08-27 11:09:06 +00:00
|
|
|
process memory ranges mapped using the
|
2007-12-20 11:25:58 +00:00
|
|
|
.BR mmap (2)
|
2007-08-27 11:09:06 +00:00
|
|
|
call with the
|
2007-08-27 11:34:07 +00:00
|
|
|
.B MAP_PRIVATE
|
2007-08-27 11:09:06 +00:00
|
|
|
flag for read accesses, and in memory ranges mapped with the
|
2007-08-27 11:34:07 +00:00
|
|
|
.B MAP_SHARED
|
2007-08-27 11:09:06 +00:00
|
|
|
flag for all accesses.
|
|
|
|
|
|
|
|
Other flag values are reserved.
|
2006-02-08 03:20:44 +00:00
|
|
|
|
|
|
|
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
|
2007-04-12 22:42:49 +00:00
|
|
|
.I errno
|
2006-02-08 03:20:44 +00:00
|
|
|
is set to indicate the error.
|
2007-08-27 11:09:06 +00:00
|
|
|
.SH ERRORS
|
|
|
|
.TP
|
2007-10-23 06:21:25 +00:00
|
|
|
.B EFAULT
|
|
|
|
Part of all of the memory range specified by
|
|
|
|
.I nodemask
|
|
|
|
and
|
|
|
|
.I maxnode
|
|
|
|
points outside your accessible address space.
|
|
|
|
.TP
|
2007-08-27 11:09:06 +00:00
|
|
|
.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.
|
2007-08-27 11:09:06 +00:00
|
|
|
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
|
2015-04-30 10:31:09 +00:00
|
|
|
and the current thread policy is not
|
2007-08-27 11:09:06 +00:00
|
|
|
.BR MPOL_INTERLEAVE .
|
2008-08-08 20:02:56 +00:00
|
|
|
Or,
|
|
|
|
.I flags
|
|
|
|
specified
|
|
|
|
.B MPOL_F_MEMS_ALLOWED
|
|
|
|
with either
|
|
|
|
.B MPOL_F_ADDR
|
|
|
|
or
|
|
|
|
.BR MPOL_F_NODE .
|
2007-12-20 11:25:58 +00:00
|
|
|
(And there are other
|
|
|
|
.B EINVAL
|
|
|
|
cases.)
|
2008-08-13 08:19:47 +00:00
|
|
|
.SH VERSIONS
|
|
|
|
The
|
2009-09-27 07:26:27 +00:00
|
|
|
.BR get_mempolicy ()
|
2008-08-13 08:19:47 +00:00
|
|
|
system call was added to the Linux kernel in version 2.6.7.
|
2007-11-24 10:15:53 +00:00
|
|
|
.SH CONFORMING TO
|
2007-12-25 21:28:09 +00:00
|
|
|
This system call is Linux-specific.
|
2006-02-08 03:20:44 +00:00
|
|
|
.SH NOTES
|
2008-08-13 08:19:47 +00:00
|
|
|
For information on library support, see
|
|
|
|
.BR numa (7).
|
2006-02-08 03:20:44 +00:00
|
|
|
.SH SEE ALSO
|
2008-07-03 12:20:42 +00:00
|
|
|
.BR getcpu (2),
|
2006-02-08 03:20:44 +00:00
|
|
|
.BR mbind (2),
|
2007-08-27 11:09:06 +00:00
|
|
|
.BR mmap (2),
|
2006-02-08 03:20:44 +00:00
|
|
|
.BR set_mempolicy (2),
|
2008-07-14 15:52:21 +00:00
|
|
|
.BR numa (3),
|
2008-08-13 08:19:47 +00:00
|
|
|
.BR numa (7),
|
2008-07-14 15:52:21 +00:00
|
|
|
.BR numactl (8)
|