Blame numa.3

Packit Service db5786
.\" Copyright 2003,2004 Andi Kleen, SuSE Labs.
Packit Service db5786
.\"
Packit Service db5786
.\" Permission is granted to make and distribute verbatim copies of this
Packit Service db5786
.\" manual provided the copyright notice and this permission notice are
Packit Service db5786
.\" preserved on all copies.
Packit Service db5786
.\"
Packit Service db5786
.\" Permission is granted to copy and distribute modified versions of this
Packit Service db5786
.\" manual under the conditions for verbatim copying, provided that the
Packit Service db5786
.\" entire resulting derived work is distributed under the terms of a
Packit Service db5786
.\" permission notice identical to this one.
Packit Service db5786
.\"
Packit Service db5786
.\" Since the Linux kernel and libraries are constantly changing, this
Packit Service db5786
.\" manual page may be incorrect or out-of-date.  The author(s) assume no
Packit Service db5786
.\" responsibility for errors or omissions, or for damages resulting from
Packit Service db5786
.\" the use of the information contained herein.
Packit Service db5786
.\"
Packit Service db5786
.\" Formatted or processed versions of this manual, if unaccompanied by
Packit Service db5786
.\" the source, must acknowledge the copyright and authors of this work.
Packit Service db5786
.TH NUMA 3 "December 2007" "SuSE Labs" "Linux Programmer's Manual"
Packit Service db5786
.SH NAME
Packit Service db5786
numa \- NUMA policy library
Packit Service db5786
.SH SYNOPSIS
Packit Service db5786
.B #include <numa.h>
Packit Service db5786
.sp
Packit Service db5786
.B cc ... \-lnuma
Packit Service db5786
.sp
Packit Service db5786
.B int numa_available(void);
Packit Service db5786
.sp
Packit Service db5786
.BI "int numa_max_possible_node(void);"
Packit Service db5786
.br
Packit Service db5786
.BI "int numa_num_possible_nodes();"
Packit Service db5786
.sp
Packit Service db5786
.B int numa_max_node(void);
Packit Service db5786
.br
Packit Service db5786
.BI "int numa_num_configured_nodes();"
Packit Service db5786
.br
Packit Service db5786
.B struct bitmask *numa_get_mems_allowed(void);
Packit Service db5786
.sp
Packit Service db5786
.BI "int numa_num_configured_cpus(void);"
Packit Service db5786
.br
Packit Service db5786
.BI "struct bitmask *numa_all_nodes_ptr;"
Packit Service db5786
.br
Packit Service db5786
.BI "struct bitmask *numa_no_nodes_ptr;"
Packit Service db5786
.br
Packit Service db5786
.BI "struct bitmask *numa_all_cpus_ptr;"
Packit Service db5786
.sp
Packit Service db5786
.BI "int numa_num_task_cpus();"
Packit Service db5786
.br
Packit Service db5786
.BI "int numa_num_task_nodes();"
Packit Service db5786
.sp
Packit Service db5786
.BI "int numa_parse_bitmap(char *" line " , struct bitmask *" mask ");
Packit Service db5786
.br
Packit Service db5786
.BI "struct bitmask *numa_parse_nodestring(const char *" string );
Packit Service db5786
.br
Packit Service db5786
.BI "struct bitmask *numa_parse_nodestring_all(const char *" string );
Packit Service db5786
.br
Packit Service db5786
.BI "struct bitmask *numa_parse_cpustring(const char *" string );
Packit Service db5786
.br
Packit Service db5786
.BI "struct bitmask *numa_parse_cpustring_all(const char *" string );
Packit Service db5786
.sp
Packit Service db5786
.BI "long numa_node_size(int " node ", long *" freep );
Packit Service db5786
.br
Packit Service db5786
.BI "long long numa_node_size64(int " node ", long long *" freep );
Packit Service db5786
.sp
Packit Service db5786
.B int numa_preferred(void);
Packit Service db5786
.br
Packit Service db5786
.BI "void numa_set_preferred(int " node );
Packit Service db5786
.br
Packit Service db5786
.BI "int numa_get_interleave_node(void);
Packit Service db5786
.br
Packit Service db5786
.B struct bitmask *numa_get_interleave_mask(void);
Packit Service db5786
.br
Packit Service db5786
.BI "void numa_set_interleave_mask(struct bitmask *" nodemask );
Packit Service db5786
.br
Packit Service db5786
.BI "void numa_interleave_memory(void *" start ", size_t " size ", struct bitmask *" nodemask );
Packit Service db5786
.br
Packit Service db5786
.BI "void numa_bind(struct bitmask *" nodemask );
Packit Service db5786
.br
Packit Service db5786
.BI "void numa_set_localalloc(void);
Packit Service db5786
.br
Packit Service db5786
.BI "void numa_set_membind(struct bitmask *" nodemask );
Packit Service db5786
.br
Packit Service db5786
.B struct bitmask *numa_get_membind(void);
Packit Service db5786
.sp
Packit Service db5786
.BI "void *numa_alloc_onnode(size_t " size ", int " node );
Packit Service db5786
.br
Packit Service db5786
.BI "void *numa_alloc_local(size_t " size );
Packit Service db5786
.br
Packit Service db5786
.BI "void *numa_alloc_interleaved(size_t " size );
Packit Service db5786
.br
Packit Service db5786
.BI "void *numa_alloc_interleaved_subset(size_t " size ",  struct bitmask *" nodemask );
Packit Service db5786
.BI "void *numa_alloc(size_t " size );
Packit Service db5786
.br
Packit Service db5786
.BI "void *numa_realloc(void *"old_addr ", size_t " old_size ", size_t " new_size );
Packit Service db5786
.br
Packit Service db5786
.BI "void numa_free(void *" start ", size_t " size );
Packit Service db5786
.sp
Packit Service db5786
.BI "int numa_run_on_node(int " node );
Packit Service db5786
.br
Packit Service db5786
.BI "int numa_run_on_node_mask(struct bitmask *" nodemask );
Packit Service db5786
.br
Packit Service db5786
.BI "int numa_run_on_node_mask_all(struct bitmask *" nodemask );
Packit Service db5786
.br
Packit Service db5786
.B struct bitmask *numa_get_run_node_mask(void);
Packit Service db5786
.sp
Packit Service db5786
.BI "void numa_tonode_memory(void *" start ", size_t " size ", int " node );
Packit Service db5786
.br
Packit Service db5786
.BI "void numa_tonodemask_memory(void *" start ", size_t " size ", struct bitmask *" nodemask );
Packit Service db5786
.br
Packit Service db5786
.BI "void numa_setlocal_memory(void *" start ", size_t " size );
Packit Service db5786
.br
Packit Service db5786
.BI "void numa_police_memory(void *" start ", size_t " size );
Packit Service db5786
.br
Packit Service db5786
.BI "void numa_set_bind_policy(int " strict );
Packit Service db5786
.br
Packit Service db5786
.BI "void numa_set_strict(int " strict );
Packit Service db5786
.sp
Packit Service db5786
.\" should be undocumented ??
Packit Service db5786
.BI "int numa_distance(int " node1 ", int " node2 );
Packit Service db5786
.sp
Packit Service db5786
.BI "int numa_sched_getaffinity(pid_t " pid ", struct bitmask *" mask );
Packit Service db5786
.br
Packit Service db5786
.BI "int numa_sched_setaffinity(pid_t " pid ", struct bitmask *" mask );
Packit Service db5786
.br
Packit Service db5786
.BI "int numa_node_to_cpus(int " node ", struct bitmask *" mask ");
Packit Service db5786
.br
Packit Service db5786
.BI "int numa_node_of_cpu(int " cpu ");
Packit Service db5786
.sp
Packit Service db5786
.BI "struct bitmask *numa_allocate_cpumask();"
Packit Service db5786
.sp
Packit Service db5786
.BI "void numa_free_cpumask();"
Packit Service db5786
.br
Packit Service db5786
.BI "struct bitmask *numa_allocate_nodemask();"
Packit Service db5786
.sp
Packit Service db5786
.BI "void numa_free_nodemask();"
Packit Service db5786
.br
Packit Service db5786
.BI "struct bitmask *numa_bitmask_alloc(unsigned int " n ");
Packit Service db5786
.br
Packit Service db5786
.BI "struct bitmask *numa_bitmask_clearall(struct bitmask *" bmp );
Packit Service db5786
.br
Packit Service db5786
.BI "struct bitmask *numa_bitmask_clearbit(struct bitmask *" bmp ", unsigned int " n );
Packit Service db5786
.br
Packit Service db5786
.BI "int numa_bitmask_equal(const struct bitmask *" bmp1 ", const struct bitmask *" bmp2 );
Packit Service db5786
.br
Packit Service db5786
.BI "void numa_bitmask_free(struct bitmask *" bmp );
Packit Service db5786
.br
Packit Service db5786
.BI "int numa_bitmask_isbitset(const struct bitmask *" bmp ", unsigned int " n ");"
Packit Service db5786
.br
Packit Service db5786
.BI "unsigned int numa_bitmask_nbytes(struct bitmask *" bmp );
Packit Service db5786
.br
Packit Service db5786
.BI "struct bitmask *numa_bitmask_setall(struct bitmask *" bmp );
Packit Service db5786
.br
Packit Service db5786
.BI "struct bitmask *numa_bitmask_setbit(struct bitmask *" bmp ", unsigned int " n );
Packit Service db5786
.br
Packit Service db5786
.BI "void copy_bitmask_to_nodemask(struct bitmask *" bmp ", nodemask_t *" nodemask )
Packit Service db5786
.br
Packit Service db5786
.BI "void copy_nodemask_to_bitmask(nodemask_t *" nodemask ", struct bitmask *" bmp )
Packit Service db5786
.br
Packit Service db5786
.BI "void copy_bitmask_to_bitmask(struct bitmask *" bmpfrom ", struct bitmask *" bmpto )
Packit Service db5786
.br
Packit Service db5786
.BI "unsigned int numa_bitmask_weight(const struct bitmask *bmp )
Packit Service db5786
.sp
Packit Service db5786
.BI "int numa_move_pages(int " pid ", unsigned long " count ", void **" pages ", const int *" nodes ", int *" status ", int " flags );
Packit Service db5786
.br
Packit Service db5786
.BI "int numa_migrate_pages(int " pid ", struct bitmask *" fromnodes ", struct bitmask *" tonodes );
Packit Service db5786
.sp
Packit Service db5786
.BI "void numa_error(char *" where );
Packit Service db5786
.sp
Packit Service db5786
.BI "extern int " numa_exit_on_error ;
Packit Service db5786
.br
Packit Service db5786
.BI "extern int " numa_exit_on_warn ;
Packit Service db5786
.br
Packit Service db5786
.BI "void numa_warn(int " number ", char *" where ", ...);"
Packit Service db5786
.br
Packit Service db5786
Packit Service db5786
.SH DESCRIPTION
Packit Service db5786
The
Packit Service db5786
.I libnuma
Packit Service db5786
library offers a simple programming interface to the
Packit Service db5786
NUMA (Non Uniform Memory Access)
Packit Service db5786
policy supported by the
Packit Service db5786
Linux kernel. On a NUMA architecture some
Packit Service db5786
memory areas have different latency or bandwidth than others.
Packit Service db5786
Packit Service db5786
Available policies are
Packit Service db5786
page interleaving (i.e., allocate in a round-robin fashion from all,
Packit Service db5786
or a subset, of the nodes on the system),
Packit Service db5786
preferred node allocation (i.e., preferably allocate on a particular node),
Packit Service db5786
local allocation (i.e., allocate on the node on which
Packit Service db5786
the task is currently executing),
Packit Service db5786
or allocation only on specific nodes (i.e., allocate on
Packit Service db5786
some subset of the available nodes).
Packit Service db5786
It is also possible to bind tasks to specific nodes.
Packit Service db5786
Packit Service db5786
Numa memory allocation policy may be specified as a per-task attribute,
Packit Service db5786
that is inherited by children tasks and processes, or as an attribute
Packit Service db5786
of a range of process virtual address space.
Packit Service db5786
Numa memory policies specified for a range of virtual address space are
Packit Service db5786
shared by all tasks in the process.
Packit Service db5786
Furthermore, memory policies specified for a range of a shared memory
Packit Service db5786
attached using
Packit Service db5786
.I shmat(2)
Packit Service db5786
or
Packit Service db5786
.I mmap(2)
Packit Service db5786
from shmfs/hugetlbfs are shared by all processes that attach to that region.
Packit Service db5786
Memory policies for shared disk backed file mappings are currently ignored.
Packit Service db5786
Packit Service db5786
The default memory allocation policy for tasks and all memory range
Packit Service db5786
is local allocation.
Packit Service db5786
This assumes that no ancestor has installed a non-default policy.
Packit Service db5786
Packit Service db5786
For setting a specific policy globally for all memory allocations
Packit Service db5786
in a process and its children it is easiest
Packit Service db5786
to start it with the
Packit Service db5786
.BR numactl (8)
Packit Service db5786
utility. For more finegrained policy inside an application this library
Packit Service db5786
can be used.
Packit Service db5786
Packit Service db5786
All numa memory allocation policy only takes effect when a page is actually
Packit Service db5786
faulted into the address space of a process by accessing it. The
Packit Service db5786
.B numa_alloc_*
Packit Service db5786
functions take care of this automatically.
Packit Service db5786
Packit Service db5786
A
Packit Service db5786
.I node
Packit Service db5786
is defined as an area where all memory has the same speed as seen from
Packit Service db5786
a particular CPU.
Packit Service db5786
A node can contain multiple CPUs.
Packit Service db5786
Caches are ignored for this definition.
Packit Service db5786
Packit Service db5786
Most functions in this library are only concerned about numa nodes and
Packit Service db5786
their memory.
Packit Service db5786
The exceptions to this are:
Packit Service db5786
.IR numa_node_to_cpus (),
Packit Service db5786
.IR numa_node_of_cpu (),
Packit Service db5786
.IR numa_bind (),
Packit Service db5786
.IR numa_run_on_node (),
Packit Service db5786
.IR numa_run_on_node_mask (),
Packit Service db5786
.IR numa_run_on_node_mask_all (),
Packit Service db5786
and
Packit Service db5786
.IR numa_get_run_node_mask ().
Packit Service db5786
These functions deal with the CPUs associated with numa nodes.
Packit Service db5786
See the descriptions below for more information.
Packit Service db5786
Packit Service db5786
Some of these functions accept or return a pointer to struct bitmask.
Packit Service db5786
A struct bitmask controls a bit map of arbitrary length containing a bit
Packit Service db5786
representation of nodes.  The predefined variable
Packit Service db5786
.I numa_all_nodes_ptr
Packit Service db5786
points to a bit mask that has all available nodes set;
Packit Service db5786
.I numa_no_nodes_ptr
Packit Service db5786
points to the empty set.
Packit Service db5786
Packit Service db5786
Before any other calls in this library can be used
Packit Service db5786
.BR numa_available ()
Packit Service db5786
must be called. If it returns \-1, all other functions in this
Packit Service db5786
library are undefined.
Packit Service db5786
Packit Service db5786
.BR numa_max_possible_node()
Packit Service db5786
returns the number of the highest possible node in a system.
Packit Service db5786
In other words, the size of a kernel type nodemask_t (in bits) minus 1.
Packit Service db5786
This number can be gotten by calling
Packit Service db5786
.BR numa_num_possible_nodes()
Packit Service db5786
and subtracting 1.
Packit Service db5786
Packit Service db5786
.BR numa_num_possible_nodes()
Packit Service db5786
returns the size of kernel's node mask (kernel type nodemask_t).
Packit Service db5786
In other words, large enough to represent the maximum number of nodes that
Packit Service db5786
the kernel can handle. This will match the kernel's MAX_NUMNODES value.
Packit Service db5786
This count is derived from /proc/self/status, field Mems_allowed.
Packit Service db5786
Packit Service db5786
.BR numa_max_node ()
Packit Service db5786
returns the highest node number available on the current system.
Packit Service db5786
(See the node numbers in /sys/devices/system/node/ ).  Also see
Packit Service db5786
.BR numa_num_configured_nodes().
Packit Service db5786
Packit Service db5786
.BR numa_num_configured_nodes()
Packit Service db5786
returns the number of memory nodes in the system. This count
Packit Service db5786
includes any nodes that are currently disabled. This count is derived from
Packit Service db5786
the node numbers in /sys/devices/system/node. (Depends on the kernel being
Packit Service db5786
configured with /sys (CONFIG_SYSFS)).
Packit Service db5786
Packit Service db5786
.BR numa_get_mems_allowed()
Packit Service db5786
returns the mask of nodes from which the process is allowed to allocate
Packit Service db5786
memory in it's current cpuset context.
Packit Service db5786
Any nodes that are not included in the returned bitmask will be ignored
Packit Service db5786
in any of the following libnuma memory policy calls.
Packit Service db5786
Packit Service db5786
.BR numa_num_configured_cpus()
Packit Service db5786
returns the number of cpus in the system.  This count includes
Packit Service db5786
any cpus that are currently disabled. This count is derived from the cpu
Packit Service db5786
numbers in /sys/devices/system/cpu. If the kernel is configured without
Packit Service db5786
/sys (CONFIG_SYSFS=n) then it falls back to using the number of online cpus.
Packit Service db5786
Packit Service db5786
.BR numa_all_nodes_ptr
Packit Service db5786
points to a bitmask that is allocated by the library with bits
Packit Service db5786
representing all nodes on which the calling task may allocate memory.
Packit Service db5786
This set may be up to all nodes on the system, or up to the nodes in
Packit Service db5786
the current cpuset.
Packit Service db5786
The bitmask is allocated by a call to
Packit Service db5786
.BR numa_allocate_nodemask()
Packit Service db5786
using size
Packit Service db5786
.BR numa_max_possible_node().
Packit Service db5786
The set of nodes to record is derived from /proc/self/status, field
Packit Service db5786
"Mems_allowed".  The user should not alter this bitmask.
Packit Service db5786
Packit Service db5786
.BR numa_no_nodes_ptr
Packit Service db5786
points to a bitmask that is allocated by the library and left all
Packit Service db5786
zeroes.  The bitmask is allocated by a call to
Packit Service db5786
.BR numa_allocate_nodemask()
Packit Service db5786
using size
Packit Service db5786
.BR numa_max_possible_node().
Packit Service db5786
The user should not alter this bitmask.
Packit Service db5786
Packit Service db5786
.BR numa_all_cpus_ptr
Packit Service db5786
points to a bitmask that is allocated by the library with bits
Packit Service db5786
representing all cpus on which the calling task may execute.
Packit Service db5786
This set may be up to all cpus on the system, or up to the cpus in
Packit Service db5786
the current cpuset.
Packit Service db5786
The bitmask is allocated by a call to
Packit Service db5786
.BR numa_allocate_cpumask()
Packit Service db5786
using size
Packit Service db5786
.BR numa_num_possible_cpus().
Packit Service db5786
The set of cpus to record is derived from /proc/self/status, field
Packit Service db5786
"Cpus_allowed".  The user should not alter this bitmask.
Packit Service db5786
Packit Service db5786
.BR numa_num_task_cpus()
Packit Service db5786
returns the number of cpus that the calling task is allowed
Packit Service db5786
to use.  This count is derived from the map /proc/self/status, field
Packit Service db5786
"Cpus_allowed". Also see the bitmask
Packit Service db5786
.BR numa_all_cpus_ptr.
Packit Service db5786
Packit Service db5786
.BR numa_num_task_nodes()
Packit Service db5786
returns the number of nodes on which the calling task is
Packit Service db5786
allowed to allocate memory.  This count is derived from the map
Packit Service db5786
/proc/self/status, field "Mems_allowed".
Packit Service db5786
Also see the bitmask
Packit Service db5786
.BR numa_all_nodes_ptr.
Packit Service db5786
Packit Service db5786
.BR numa_parse_bitmap()
Packit Service db5786
parses
Packit Service db5786
.I line
Packit Service db5786
, which is a character string such as found in
Packit Service db5786
/sys/devices/system/node/nodeN/cpumap into a bitmask structure.
Packit Service db5786
The string contains the hexadecimal representation of a bit map.
Packit Service db5786
The bitmask may be allocated with
Packit Service db5786
.BR numa_allocate_cpumask().
Packit Service db5786
Returns  0 on success.  Returns -1 on failure.
Packit Service db5786
This function is probably of little use to a user application, but
Packit Service db5786
it is used by
Packit Service db5786
.I libnuma
Packit Service db5786
internally.
Packit Service db5786
Packit Service db5786
.BR numa_parse_nodestring()
Packit Service db5786
parses a character string list of nodes into a bit mask.
Packit Service db5786
The bit mask is allocated by
Packit Service db5786
.BR numa_allocate_nodemask().
Packit Service db5786
The string is a comma-separated list of node numbers or node ranges.
Packit Service db5786
A leading ! can be used to indicate "not" this list (in other words, all
Packit Service db5786
nodes except this list), and a leading + can be used to indicate that the
Packit Service db5786
node numbers in the list are relative to the task's cpuset.  The string can
Packit Service db5786
be "all" to specify all (
Packit Service db5786
.BR numa_num_task_nodes()
Packit Service db5786
) nodes.  Node numbers are limited by the number in the system.  See
Packit Service db5786
.BR numa_max_node()
Packit Service db5786
and
Packit Service db5786
.BR numa_num_configured_nodes().
Packit Service db5786
.br
Packit Service db5786
Examples:  1-5,7,10   !4-5   +0-3
Packit Service db5786
.br
Packit Service db5786
If the string is of 0 length, bitmask
Packit Service db5786
.BR numa_no_nodes_ptr
Packit Service db5786
is returned.  Returns 0 if the string is invalid.
Packit Service db5786
Packit Service db5786
.BR numa_parse_nodestring_all()
Packit Service db5786
is similar to
Packit Service db5786
.BR numa_parse_nodestring
Packit Service db5786
, but can parse all possible nodes, not only current nodeset.
Packit Service db5786
Packit Service db5786
.BR numa_parse_cpustring()
Packit Service db5786
parses a character string list of cpus into a bit mask.
Packit Service db5786
The bit mask is allocated by
Packit Service db5786
.BR numa_allocate_cpumask().
Packit Service db5786
The string is a comma-separated list of cpu numbers or cpu ranges.
Packit Service db5786
A leading ! can be used to indicate "not" this list (in other words, all
Packit Service db5786
cpus except this list), and a leading + can be used to indicate that the cpu
Packit Service db5786
numbers in the list are relative to the task's cpuset.  The string can be
Packit Service db5786
"all" to specify all (
Packit Service db5786
.BR numa_num_task_cpus()
Packit Service db5786
) cpus.
Packit Service db5786
Cpu numbers are limited by the number in the system.  See
Packit Service db5786
.BR numa_num_task_cpus()
Packit Service db5786
and
Packit Service db5786
.BR numa_num_configured_cpus().
Packit Service db5786
.br
Packit Service db5786
Examples:  1-5,7,10   !4-5   +0-3
Packit Service db5786
.br
Packit Service db5786
Returns 0 if the string is invalid.
Packit Service db5786
Packit Service db5786
.BR numa_parse_cpustring_all()
Packit Service db5786
is similar to
Packit Service db5786
.BR numa_parse_cpustring
Packit Service db5786
, but can parse all possible cpus, not only current cpuset.
Packit Service db5786
Packit Service db5786
.BR numa_node_size ()
Packit Service db5786
returns the memory size of a node. If the argument
Packit Service db5786
.I freep
Packit Service db5786
is not NULL, it used to return the amount of free memory on the node.
Packit Service db5786
On error it returns \-1.
Packit Service db5786
Packit Service db5786
.BR numa_node_size64 ()
Packit Service db5786
works the same as
Packit Service db5786
.BR numa_node_size ()
Packit Service db5786
except that it returns values as
Packit Service db5786
.I long long
Packit Service db5786
instead of
Packit Service db5786
.IR long .
Packit Service db5786
This is useful on 32-bit architectures with large nodes.
Packit Service db5786
Packit Service db5786
.BR numa_preferred ()
Packit Service db5786
returns the preferred node of the current task.
Packit Service db5786
This is the node on which the kernel preferably
Packit Service db5786
allocates memory, unless some other policy overrides this.
Packit Service db5786
.\" TODO:   results are misleading for MPOL_PREFERRED and may
Packit Service db5786
.\" be incorrect for MPOL_BIND when Mel Gorman's twozonelist
Packit Service db5786
.\" patches go in.  In the latter case, we'd need to know the
Packit Service db5786
.\" order of the current node's zonelist to return the correct
Packit Service db5786
.\" node.  Need to tighten this up with the syscall results.
Packit Service db5786
Packit Service db5786
.BR numa_set_preferred ()
Packit Service db5786
sets the preferred node for the current task to
Packit Service db5786
.IR node .
Packit Service db5786
The system will attempt to allocate memory from the preferred node,
Packit Service db5786
but will fall back to other nodes if no memory is available on the
Packit Service db5786
the preferred node.
Packit Service db5786
Passing a
Packit Service db5786
.I node
Packit Service db5786
of \-1 argument specifies local allocation and is equivalent to
Packit Service db5786
calling
Packit Service db5786
.BR numa_set_localalloc ().
Packit Service db5786
Packit Service db5786
.BR numa_get_interleave_mask ()
Packit Service db5786
returns the current interleave mask if the task's memory allocation policy
Packit Service db5786
is page interleaved.
Packit Service db5786
Otherwise, this function returns an empty mask.
Packit Service db5786
Packit Service db5786
.BR numa_set_interleave_mask ()
Packit Service db5786
sets the memory interleave mask for the current task to
Packit Service db5786
.IR nodemask .
Packit Service db5786
All new memory allocations
Packit Service db5786
are page interleaved over all nodes in the interleave mask. Interleaving
Packit Service db5786
can be turned off again by passing an empty mask
Packit Service db5786
.RI ( numa_no_nodes ).
Packit Service db5786
The page interleaving only occurs on the actual page fault that puts a new
Packit Service db5786
page into the current address space. It is also only a hint: the kernel
Packit Service db5786
will fall back to other nodes if no memory is available on the interleave
Packit Service db5786
target.
Packit Service db5786
.\" NOTE:  the following is not really the case.  this function sets the
Packit Service db5786
.\" task policy for all future allocations, including stack,  bss, ...
Packit Service db5786
.\" The functions specified in this sentence actually allocate a new memory
Packit Service db5786
.\" range [via mmap()].  This is quite a different thing.  Suggest we drop
Packit Service db5786
.\" this.
Packit Service db5786
.\" This is a low level
Packit Service db5786
.\" function, it may be more convenient to use the higher level functions like
Packit Service db5786
.\" .BR numa_alloc_interleaved ()
Packit Service db5786
.\" or
Packit Service db5786
.\" .BR numa_alloc_interleaved_subset ().
Packit Service db5786
Packit Service db5786
.BR numa_interleave_memory ()
Packit Service db5786
interleaves
Packit Service db5786
.I size
Packit Service db5786
bytes of memory page by page from
Packit Service db5786
.I start
Packit Service db5786
on nodes specified in
Packit Service db5786
.IR nodemask .
Packit Service db5786
The
Packit Service db5786
.I size
Packit Service db5786
argument will be rounded up to a multiple of the system page size.
Packit Service db5786
If
Packit Service db5786
.I nodemask
Packit Service db5786
contains nodes that are externally denied to this process,
Packit Service db5786
this call will fail.
Packit Service db5786
This is a lower level function to interleave allocated but not yet faulted in
Packit Service db5786
memory. Not yet faulted in means the memory is allocated using
Packit Service db5786
.BR mmap (2)
Packit Service db5786
or
Packit Service db5786
.BR shmat (2),
Packit Service db5786
but has not been accessed by the current process yet. The memory is page
Packit Service db5786
interleaved to all nodes specified in
Packit Service db5786
.IR nodemask .
Packit Service db5786
Normally
Packit Service db5786
.BR numa_alloc_interleaved ()
Packit Service db5786
should be used for private memory instead, but this function is useful to
Packit Service db5786
handle shared memory areas. To be useful the memory area should be
Packit Service db5786
several megabytes at least (or tens of megabytes of hugetlbfs mappings)
Packit Service db5786
If the
Packit Service db5786
.BR numa_set_strict ()
Packit Service db5786
flag is true then the operation will cause a numa_error if there were already
Packit Service db5786
pages in the mapping that do not follow the policy.
Packit Service db5786
Packit Service db5786
.BR numa_bind ()
Packit Service db5786
binds the current task and its children to the nodes
Packit Service db5786
specified in
Packit Service db5786
.IR nodemask .
Packit Service db5786
They will only run on the CPUs of the specified nodes and only be able to allocate
Packit Service db5786
memory from them.
Packit Service db5786
This function is equivalent to calling
Packit Service db5786
.\" FIXME checkme
Packit Service db5786
.\" This is the case.  --lts
Packit Service db5786
.I numa_run_on_node_mask(nodemask)
Packit Service db5786
followed by
Packit Service db5786
.IR numa_set_membind(nodemask) .
Packit Service db5786
If tasks should be bound to individual CPUs inside nodes
Packit Service db5786
consider using
Packit Service db5786
.I numa_node_to_cpus
Packit Service db5786
and the
Packit Service db5786
.I sched_setaffinity(2)
Packit Service db5786
syscall.
Packit Service db5786
Packit Service db5786
.BR numa_set_localalloc ()
Packit Service db5786
sets the memory allocation policy for the calling task to
Packit Service db5786
local allocation.
Packit Service db5786
In this mode, the preferred node for memory allocation is
Packit Service db5786
effectively the node where the task is executing at the
Packit Service db5786
time of a page allocation.
Packit Service db5786
Packit Service db5786
.BR numa_set_membind ()
Packit Service db5786
sets the memory allocation mask.
Packit Service db5786
The task will only allocate memory from the nodes set in
Packit Service db5786
.IR nodemask .
Packit Service db5786
Passing an empty
Packit Service db5786
.I nodemask
Packit Service db5786
or a
Packit Service db5786
.I nodemask
Packit Service db5786
that contains nodes other than those in the mask returned by
Packit Service db5786
.IR numa_get_mems_allowed ()
Packit Service db5786
will result in an error.
Packit Service db5786
Packit Service db5786
.BR numa_get_membind ()
Packit Service db5786
returns the mask of nodes from which memory can currently be allocated.
Packit Service db5786
If the returned mask is equal to
Packit Service db5786
.IR numa_all_nodes ,
Packit Service db5786
then memory allocation is allowed from all nodes.
Packit Service db5786
Packit Service db5786
.BR numa_alloc_onnode ()
Packit Service db5786
allocates memory on a specific node.
Packit Service db5786
The
Packit Service db5786
.I size
Packit Service db5786
argument will be rounded up to a multiple of the system page size.
Packit Service db5786
if the specified
Packit Service db5786
.I node
Packit Service db5786
is externally denied to this process, this call will fail.
Packit Service db5786
This function is relatively slow compared to the
Packit Service db5786
.IR malloc (3),
Packit Service db5786
family of functions.
Packit Service db5786
The memory must be freed
Packit Service db5786
with
Packit Service db5786
.BR numa_free ().
Packit Service db5786
On errors NULL is returned.
Packit Service db5786
Packit Service db5786
.BR numa_alloc_local ()
Packit Service db5786
allocates
Packit Service db5786
.I size
Packit Service db5786
bytes of memory on the local node.
Packit Service db5786
The
Packit Service db5786
.I size
Packit Service db5786
argument will be rounded up to a multiple of the system page size.
Packit Service db5786
This function is relatively slow compared to the
Packit Service db5786
.IR malloc (3)
Packit Service db5786
family of functions.
Packit Service db5786
The memory must be freed
Packit Service db5786
with
Packit Service db5786
.BR numa_free ().
Packit Service db5786
On errors NULL is returned.
Packit Service db5786
Packit Service db5786
.BR numa_alloc_interleaved ()
Packit Service db5786
allocates
Packit Service db5786
.I size
Packit Service db5786
bytes of memory page interleaved on all nodes. This function is relatively slow
Packit Service db5786
and should only be used for large areas consisting of multiple pages. The
Packit Service db5786
interleaving works at page level and will only show an effect when the
Packit Service db5786
area is large.
Packit Service db5786
The allocated memory must be freed with
Packit Service db5786
.BR numa_free ().
Packit Service db5786
On error, NULL is returned.
Packit Service db5786
Packit Service db5786
.BR numa_alloc_interleaved_subset ()
Packit Service db5786
attempts to allocate
Packit Service db5786
.I size
Packit Service db5786
bytes of memory page interleaved on all nodes.
Packit Service db5786
The
Packit Service db5786
.I size
Packit Service db5786
argument will be rounded up to a multiple of the system page size.
Packit Service db5786
The nodes on which a process is allowed to allocate memory may
Packit Service db5786
be constrained externally.
Packit Service db5786
If this is the case, this function may fail.
Packit Service db5786
This function is relatively slow compare to
Packit Service db5786
.IR malloc (3),
Packit Service db5786
family of functions and should only be used for large areas consisting
Packit Service db5786
of multiple pages.
Packit Service db5786
The interleaving works at page level and will only show an effect when the
Packit Service db5786
area is large.
Packit Service db5786
The allocated memory must be freed with
Packit Service db5786
.BR numa_free ().
Packit Service db5786
On error, NULL is returned.
Packit Service db5786
Packit Service db5786
.BR numa_alloc ()
Packit Service db5786
allocates
Packit Service db5786
.I size
Packit Service db5786
bytes of memory with the current NUMA policy.
Packit Service db5786
The
Packit Service db5786
.I size
Packit Service db5786
argument will be rounded up to a multiple of the system page size.
Packit Service db5786
This function is relatively slow compare to the
Packit Service db5786
.IR malloc (3)
Packit Service db5786
family of functions.
Packit Service db5786
The memory must be freed
Packit Service db5786
with
Packit Service db5786
.BR numa_free ().
Packit Service db5786
On errors NULL is returned.
Packit Service db5786
Packit Service db5786
.BR numa_realloc ()
Packit Service db5786
changes the size of the memory area pointed to by
Packit Service db5786
.I old_addr
Packit Service db5786
from
Packit Service db5786
.I old_size
Packit Service db5786
to
Packit Service db5786
.I new_size.
Packit Service db5786
The memory area pointed to by
Packit Service db5786
.I old_addr
Packit Service db5786
must have been allocated with one of the
Packit Service db5786
.BR numa_alloc*
Packit Service db5786
functions.
Packit Service db5786
The
Packit Service db5786
.I new_size
Packit Service db5786
will be rounded up to a multiple of the system page size. The contents of the
Packit Service db5786
memory area will be unchanged to the minimum of the old and new sizes; newly
Packit Service db5786
allocated memory will be uninitialized. The memory policy (and node bindings)
Packit Service db5786
associated with the original memory area will be preserved in the resized
Packit Service db5786
area. For example, if the initial area was allocated with a call to
Packit Service db5786
.BR numa_alloc_onnode(),
Packit Service db5786
then the new pages (if the area is enlarged) will be allocated on the same node.
Packit Service db5786
However, if no memory policy was set for the original area, then
Packit Service db5786
.BR numa_realloc ()
Packit Service db5786
cannot guarantee that the new pages will be allocated on the same node. On
Packit Service db5786
success, the address of the resized area is returned (which might be different
Packit Service db5786
from that of the initial area), otherwise NULL is returned and
Packit Service db5786
.I errno
Packit Service db5786
is set to indicate the error. The pointer returned by
Packit Service db5786
.BR numa_realloc ()
Packit Service db5786
is suitable for passing to
Packit Service db5786
.BR numa_free ().
Packit Service db5786
Packit Service db5786
Packit Service db5786
.BR numa_free ()
Packit Service db5786
frees
Packit Service db5786
.I size
Packit Service db5786
bytes of memory starting at
Packit Service db5786
.IR start ,
Packit Service db5786
allocated by the
Packit Service db5786
.B numa_alloc_*
Packit Service db5786
functions above.
Packit Service db5786
The
Packit Service db5786
.I size
Packit Service db5786
argument will be rounded up to a multiple of the system page size.
Packit Service db5786
Packit Service db5786
.BR numa_run_on_node ()
Packit Service db5786
runs the current task and its children
Packit Service db5786
on a specific node. They will not migrate to CPUs of
Packit Service db5786
other nodes until the node affinity is reset with a new call to
Packit Service db5786
.BR numa_run_on_node_mask ().
Packit Service db5786
Passing \-1
Packit Service db5786
permits the kernel to schedule on all nodes again.
Packit Service db5786
On success, 0 is returned; on error \-1 is returned, and
Packit Service db5786
.I errno
Packit Service db5786
is set to indicate the error.
Packit Service db5786
Packit Service db5786
.BR numa_run_on_node_mask ()
Packit Service db5786
runs the current task and its children only on nodes specified in
Packit Service db5786
.IR nodemask .
Packit Service db5786
They will not migrate to CPUs of
Packit Service db5786
other nodes until the node affinity is reset with a new call to
Packit Service db5786
.BR numa_run_on_node_mask ()
Packit Service db5786
or
Packit Service db5786
.BR numa_run_on_node ().
Packit Service db5786
Passing
Packit Service db5786
.I numa_all_nodes
Packit Service db5786
permits the kernel to schedule on all nodes again.
Packit Service db5786
On success, 0 is returned; on error \-1 is returned, and
Packit Service db5786
.I errno
Packit Service db5786
is set to indicate the error.
Packit Service db5786
Packit Service db5786
.BR numa_run_on_node_mask_all ()
Packit Service db5786
runs the current task and its children only on nodes specified in
Packit Service db5786
.IR nodemask
Packit Service db5786
like
Packit Service db5786
.I numa_run_on_node_mask
Packit Service db5786
but without any cpuset awareness.
Packit Service db5786
Packit Service db5786
.BR numa_get_run_node_mask ()
Packit Service db5786
returns a mask of CPUs on which the current task is allowed to run.
Packit Service db5786
Packit Service db5786
.BR numa_tonode_memory ()
Packit Service db5786
put memory on a specific node. The constraints described for
Packit Service db5786
.BR numa_interleave_memory ()
Packit Service db5786
apply here too.
Packit Service db5786
Packit Service db5786
.BR numa_tonodemask_memory ()
Packit Service db5786
put memory on a specific set of nodes. The constraints described for
Packit Service db5786
.BR numa_interleave_memory ()
Packit Service db5786
apply here too.
Packit Service db5786
Packit Service db5786
.BR numa_setlocal_memory ()
Packit Service db5786
locates memory on the current node. The constraints described for
Packit Service db5786
.BR numa_interleave_memory ()
Packit Service db5786
apply here too.
Packit Service db5786
Packit Service db5786
.BR numa_police_memory ()
Packit Service db5786
locates memory with the current NUMA policy. The constraints described for
Packit Service db5786
.BR numa_interleave_memory ()
Packit Service db5786
apply here too.
Packit Service db5786
Packit Service db5786
.BR numa_distance ()
Packit Service db5786
reports the distance in the machine topology between two nodes.
Packit Service db5786
The factors are a multiple of 10. It returns 0 when the distance
Packit Service db5786
cannot be determined. A node has distance 10 to itself.
Packit Service db5786
Reporting the distance requires a Linux
Packit Service db5786
kernel version of
Packit Service db5786
.I 2.6.10
Packit Service db5786
or newer.
Packit Service db5786
Packit Service db5786
.BR numa_set_bind_policy ()
Packit Service db5786
specifies whether calls that bind memory to a specific node should
Packit Service db5786
use the preferred policy or a strict policy.
Packit Service db5786
The preferred policy allows the kernel
Packit Service db5786
to allocate memory on other nodes when there isn't enough free
Packit Service db5786
on the target node. strict will fail the allocation in that case.
Packit Service db5786
Setting the argument to specifies strict, 0 preferred.
Packit Service db5786
Note that specifying more than one node non strict may only use
Packit Service db5786
the first node in some kernel versions.
Packit Service db5786
Packit Service db5786
.BR numa_set_strict ()
Packit Service db5786
sets a flag that says whether the functions allocating on specific
Packit Service db5786
nodes should use use a strict policy. Strict means the allocation
Packit Service db5786
will fail if the memory cannot be allocated on the target node.
Packit Service db5786
Default operation is to fall back to other nodes.
Packit Service db5786
This doesn't apply to interleave and default.
Packit Service db5786
Packit Service db5786
.BR numa_get_interleave_node()
Packit Service db5786
is used by
Packit Service db5786
.I libnuma
Packit Service db5786
internally. It is probably not useful for user applications.
Packit Service db5786
It uses the MPOL_F_NODE flag of the get_mempolicy system call, which is
Packit Service db5786
not intended for application use (its operation may change or be removed
Packit Service db5786
altogether in future kernel versions). See get_mempolicy(2).
Packit Service db5786
Packit Service db5786
.BR numa_pagesize()
Packit Service db5786
returns the number of bytes in page. This function is simply a fast
Packit Service db5786
alternative to repeated calls to the getpagesize system call.
Packit Service db5786
See getpagesize(2).
Packit Service db5786
Packit Service db5786
.BR numa_sched_getaffinity()
Packit Service db5786
retrieves a bitmask of the cpus on which a task may run.  The task is
Packit Service db5786
specified by
Packit Service db5786
.I pid.
Packit Service db5786
Returns the return value of the sched_getaffinity
Packit Service db5786
system call.  See sched_getaffinity(2).
Packit Service db5786
The bitmask must be at least the size of the kernel's cpu mask structure. Use
Packit Service db5786
.BR numa_allocate_cpumask()
Packit Service db5786
to allocate it.
Packit Service db5786
Test the bits in the mask by calling
Packit Service db5786
.BR numa_bitmask_isbitset().
Packit Service db5786
Packit Service db5786
.BR numa_sched_setaffinity()
Packit Service db5786
sets a task's allowed cpu's to those cpu's specified in
Packit Service db5786
.I mask.
Packit Service db5786
The task is specified by
Packit Service db5786
.I pid.
Packit Service db5786
Returns the return value of the sched_setaffinity system call.
Packit Service db5786
See sched_setaffinity(2).  You may allocate the bitmask with
Packit Service db5786
.BR numa_allocate_cpumask().
Packit Service db5786
Or the bitmask may be smaller than the kernel's cpu mask structure. For
Packit Service db5786
example, call
Packit Service db5786
.BR numa_bitmask_alloc()
Packit Service db5786
using a maximum number of cpus from
Packit Service db5786
.BR numa_num_configured_cpus().
Packit Service db5786
Set the bits in the mask by calling
Packit Service db5786
.BR numa_bitmask_setbit().
Packit Service db5786
Packit Service db5786
.BR numa_node_to_cpus ()
Packit Service db5786
converts a node number to a bitmask of CPUs. The user must pass a bitmask
Packit Service db5786
structure with a mask buffer long enough to represent all possible cpu's.
Packit Service db5786
Use numa_allocate_cpumask() to create it.  If the bitmask is not long enough
Packit Service db5786
.I errno
Packit Service db5786
will be set to
Packit Service db5786
.I ERANGE
Packit Service db5786
and \-1 returned. On success 0 is returned.
Packit Service db5786
Packit Service db5786
.BR numa_node_of_cpu ()
Packit Service db5786
returns the node that a cpu belongs to. If the user supplies an invalid cpu
Packit Service db5786
.I errno
Packit Service db5786
will be set to
Packit Service db5786
.I EINVAL
Packit Service db5786
and \-1 will be returned.
Packit Service db5786
Packit Service db5786
.BR numa_allocate_cpumask
Packit Service db5786
() returns a bitmask of a size equal to the kernel's cpu
Packit Service db5786
mask (kernel type cpumask_t).  In other words, large enough to represent
Packit Service db5786
NR_CPUS cpus.  This number of cpus can be gotten by calling
Packit Service db5786
.BR numa_num_possible_cpus().
Packit Service db5786
The bitmask is zero-filled.
Packit Service db5786
Packit Service db5786
.BR numa_free_cpumask
Packit Service db5786
frees a cpumask previously allocate by
Packit Service db5786
.I numa_allocate_cpumask.
Packit Service db5786
Packit Service db5786
.BR numa_allocate_nodemask()
Packit Service db5786
returns a bitmask of a size equal to the kernel's node
Packit Service db5786
mask (kernel type nodemask_t).  In other words, large enough to represent
Packit Service db5786
MAX_NUMNODES nodes.  This number of nodes can be gotten by calling
Packit Service db5786
.BR numa_num_possible_nodes().
Packit Service db5786
The bitmask is zero-filled.
Packit Service db5786
Packit Service db5786
.BR numa_free_nodemask()
Packit Service db5786
frees a nodemask previous allocated by
Packit Service db5786
.I numa_allocate_nodemask().
Packit Service db5786
Packit Service db5786
.BR numa_bitmask_alloc()
Packit Service db5786
allocates a bitmask structure and its associated bit mask.
Packit Service db5786
The memory allocated for the bit mask contains enough words (type unsigned
Packit Service db5786
long) to contain
Packit Service db5786
.I n
Packit Service db5786
bits.  The bit mask is zero-filled.  The bitmask
Packit Service db5786
structure points to the bit mask and contains the
Packit Service db5786
.I n
Packit Service db5786
value.
Packit Service db5786
Packit Service db5786
.BR numa_bitmask_clearall()
Packit Service db5786
sets all bits in the bit mask to 0.  The bitmask structure
Packit Service db5786
points to the bit mask and contains its size (
Packit Service db5786
.I bmp
Packit Service db5786
->size).  The value of
Packit Service db5786
.I bmp
Packit Service db5786
is always returned.  Note that
Packit Service db5786
.BR numa_bitmask_alloc()
Packit Service db5786
creates a zero-filled bit mask.
Packit Service db5786
Packit Service db5786
.BR numa_bitmask_clearbit()
Packit Service db5786
sets a specified bit in a bit mask to 0.  Nothing is done if
Packit Service db5786
the
Packit Service db5786
.I n
Packit Service db5786
value is greater than the size of the bitmask (and no error is
Packit Service db5786
returned). The value of
Packit Service db5786
.I bmp
Packit Service db5786
is always returned.
Packit Service db5786
Packit Service db5786
.BR numa_bitmask_equal()
Packit Service db5786
returns 1 if two bitmasks are equal.  It returns 0 if they
Packit Service db5786
are not equal.  If the bitmask structures control bit masks of different
Packit Service db5786
sizes, the "missing" trailing bits of the smaller bit mask are considered
Packit Service db5786
to be 0.
Packit Service db5786
Packit Service db5786
.BR numa_bitmask_free()
Packit Service db5786
deallocates the memory of both the bitmask structure pointed
Packit Service db5786
to by
Packit Service db5786
.I bmp
Packit Service db5786
and the bit mask.  It is an error to attempt to free this bitmask twice.
Packit Service db5786
Packit Service db5786
.BR numa_bitmask_isbitset()
Packit Service db5786
returns the value of a specified bit in a bit mask.
Packit Service db5786
If the
Packit Service db5786
.I n
Packit Service db5786
value is greater than the size of the bit map, 0 is returned.
Packit Service db5786
Packit Service db5786
.BR numa_bitmask_nbytes()
Packit Service db5786
returns the size (in bytes) of the bit mask controlled by
Packit Service db5786
.I bmp.
Packit Service db5786
The bit masks are always full words (type unsigned long), and the returned
Packit Service db5786
size is the actual size of all those words.
Packit Service db5786
Packit Service db5786
.BR numa_bitmask_setall()
Packit Service db5786
sets all bits in the bit mask to 1.  The bitmask structure
Packit Service db5786
points to the bit mask and contains its size (
Packit Service db5786
.I bmp
Packit Service db5786
->size).
Packit Service db5786
The value of
Packit Service db5786
.I bmp
Packit Service db5786
is always returned.
Packit Service db5786
Packit Service db5786
.BR numa_bitmask_setbit()
Packit Service db5786
sets a specified bit in a bit mask to 1.  Nothing is done if
Packit Service db5786
.I n
Packit Service db5786
is greater than the size of the bitmask (and no error is
Packit Service db5786
returned). The value of
Packit Service db5786
.I bmp
Packit Service db5786
is always returned.
Packit Service db5786
Packit Service db5786
.BR copy_bitmask_to_nodemask()
Packit Service db5786
copies the body (the bit map itself) of the bitmask structure pointed
Packit Service db5786
to by
Packit Service db5786
.I bmp
Packit Service db5786
to the nodemask_t structure pointed to by the
Packit Service db5786
.I nodemask
Packit Service db5786
pointer. If the two areas differ in size, the copy is truncated to the size
Packit Service db5786
of the receiving field or zero-filled.
Packit Service db5786
Packit Service db5786
.BR copy_nodemask_to_bitmask()
Packit Service db5786
copies the nodemask_t structure pointed to by the
Packit Service db5786
.I nodemask
Packit Service db5786
pointer to the body (the bit map itself) of the bitmask structure pointed
Packit Service db5786
to by the
Packit Service db5786
.I bmp
Packit Service db5786
pointer. If the two areas differ in size, the copy is truncated to the size
Packit Service db5786
of the receiving field or zero-filled.
Packit Service db5786
Packit Service db5786
.BR copy_bitmask_to_bitmask()
Packit Service db5786
copies the body (the bit map itself) of the bitmask structure pointed
Packit Service db5786
to by the
Packit Service db5786
.I bmpfrom
Packit Service db5786
pointer to the body of the bitmask structure pointed to by the
Packit Service db5786
.I bmpto
Packit Service db5786
pointer. If the two areas differ in size, the copy is truncated to the size
Packit Service db5786
of the receiving field or zero-filled.
Packit Service db5786
Packit Service db5786
.BR numa_bitmask_weight()
Packit Service db5786
returns a count of the bits that are set in the body of the bitmask pointed
Packit Service db5786
to by the
Packit Service db5786
.I bmp
Packit Service db5786
argument.
Packit Service db5786
Packit Service db5786
.br
Packit Service db5786
.BR numa_move_pages()
Packit Service db5786
moves a list of pages in the address space of the currently
Packit Service db5786
executing or current process.
Packit Service db5786
It simply uses the move_pages system call.
Packit Service db5786
.br
Packit Service db5786
.I pid
Packit Service db5786
- ID of task.  If not valid, use the current task.
Packit Service db5786
.br
Packit Service db5786
.I count
Packit Service db5786
- Number of pages.
Packit Service db5786
.br
Packit Service db5786
.I pages
Packit Service db5786
- List of pages to move.
Packit Service db5786
.br
Packit Service db5786
.I nodes
Packit Service db5786
- List of nodes to which pages can be moved.
Packit Service db5786
.br
Packit Service db5786
.I status
Packit Service db5786
- Field to which status is to be returned.
Packit Service db5786
.br
Packit Service db5786
.I flags
Packit Service db5786
- MPOL_MF_MOVE or MPOL_MF_MOVE_ALL
Packit Service db5786
.br
Packit Service db5786
See move_pages(2).
Packit Service db5786
Packit Service db5786
.BR numa_migrate_pages()
Packit Service db5786
simply uses the migrate_pages system call to cause the pages of the calling
Packit Service db5786
task, or a specified task, to be migated from one set of nodes to another.
Packit Service db5786
See migrate_pages(2).
Packit Service db5786
The bit masks representing the nodes should be allocated with
Packit Service db5786
.BR numa_allocate_nodemask()
Packit Service db5786
, or with
Packit Service db5786
.BR numa_bitmask_alloc()
Packit Service db5786
using an
Packit Service db5786
.I n
Packit Service db5786
value returned from
Packit Service db5786
.BR numa_num_possible_nodes().
Packit Service db5786
A task's current node set can be gotten by calling
Packit Service db5786
.BR numa_get_membind().
Packit Service db5786
Bits in the
Packit Service db5786
.I tonodes
Packit Service db5786
mask can be set by calls to
Packit Service db5786
.BR numa_bitmask_setbit().
Packit Service db5786
Packit Service db5786
.BR numa_error ()
Packit Service db5786
is a
Packit Service db5786
.I libnuma
Packit Service db5786
internal function that can be overridden by the
Packit Service db5786
user program.
Packit Service db5786
This function is called with a
Packit Service db5786
.I char *
Packit Service db5786
argument when a
Packit Service db5786
.I libnuma
Packit Service db5786
function fails.
Packit Service db5786
Overriding the library internal definition
Packit Service db5786
makes it possible to specify a different error handling strategy
Packit Service db5786
when a
Packit Service db5786
.I libnuma
Packit Service db5786
function fails. It does not affect
Packit Service db5786
.BR numa_available ().
Packit Service db5786
The
Packit Service db5786
.BR numa_error ()
Packit Service db5786
function defined in
Packit Service db5786
.I libnuma
Packit Service db5786
prints an error on
Packit Service db5786
.I stderr
Packit Service db5786
and terminates
Packit Service db5786
the program if
Packit Service db5786
.I numa_exit_on_error
Packit Service db5786
is set to a non-zero value.
Packit Service db5786
The default value of
Packit Service db5786
.I numa_exit_on_error
Packit Service db5786
is zero.
Packit Service db5786
Packit Service db5786
.BR numa_warn ()
Packit Service db5786
is a
Packit Service db5786
.I libnuma
Packit Service db5786
internal function that can be also overridden
Packit Service db5786
by the user program.
Packit Service db5786
It is called to warn the user when a
Packit Service db5786
.I libnuma
Packit Service db5786
function encounters a non-fatal error.
Packit Service db5786
The default implementation
Packit Service db5786
prints a warning to
Packit Service db5786
.IR stderr .
Packit Service db5786
The first argument is a unique
Packit Service db5786
number identifying each warning. After that there is a
Packit Service db5786
.BR printf (3)-style
Packit Service db5786
format string and a variable number of arguments.
Packit Service db5786
.I numa_warn
Packit Service db5786
exits the program when
Packit Service db5786
.I numa_exit_on_warn
Packit Service db5786
is set to a non-zero value.
Packit Service db5786
The default value of
Packit Service db5786
.I numa_exit_on_warn
Packit Service db5786
is zero.
Packit Service db5786
Packit Service db5786
.SH Compatibility with libnuma version 1
Packit Service db5786
Binaries that were compiled for libnuma version 1 need not be re-compiled
Packit Service db5786
to run with libnuma version 2.
Packit Service db5786
.br
Packit Service db5786
Source codes written for libnuma version 1 may be re-compiled without
Packit Service db5786
change with version 2 installed. To do so, in the code's Makefile add
Packit Service db5786
this option to CFLAGS:  -DNUMA_VERSION1_COMPATIBILITY
Packit Service db5786
Packit Service db5786
.SH THREAD SAFETY
Packit Service db5786
.I numa_set_bind_policy
Packit Service db5786
and
Packit Service db5786
.I numa_exit_on_error
Packit Service db5786
are process global. The other calls are thread safe.
Packit Service db5786
Packit Service db5786
.SH COPYRIGHT
Packit Service db5786
Copyright 2002, 2004, 2007, 2008 Andi Kleen, SuSE Labs.
Packit Service db5786
.I libnuma
Packit Service db5786
is under the GNU Lesser General Public License, v2.1.
Packit Service db5786
Packit Service db5786
.SH SEE ALSO
Packit Service db5786
.BR get_mempolicy (2),
Packit Service db5786
.BR set_mempolicy (2),
Packit Service db5786
.BR getpagesize (2),
Packit Service db5786
.BR mbind (2),
Packit Service db5786
.BR mmap (2),
Packit Service db5786
.BR shmat (2),
Packit Service db5786
.BR numactl (8),
Packit Service db5786
.BR sched_getaffinity (2)
Packit Service db5786
.BR sched_setaffinity (2)
Packit Service db5786
.BR move_pages (2)
Packit Service db5786
.BR migrate_pages (2)