Barrelfish
|
header specifying the interface of libnuma More...
Macros | |
#define | NUMA_MAX_NUMNODES 16 |
< the maximum number of nodes supported More... | |
#define | NUMA_NODE_LOCAL ((nodeid_t)-1) |
error value for the numa node size | |
#define | NUMA_NODE_INVALID ((uintptr_t)-1) |
error value for invalid cores | |
Typedefs | |
typedef enum numa_policy | numa_policy_t |
typedef for the nodemask | |
Enumerations |
Functions | |
errval_t | numa_available (void) |
checks if numa support is available More... | |
nodeid_t | numa_max_node (void) |
returns the highest node number available on the current system. More... | |
coreid_t | numa_max_core (void) |
returns the highest ID of the present cores More... | |
nodeid_t | numa_current_node (void) |
returns the current node the domain is running on More... | |
nodeid_t | numa_num_possible_nodes (void) |
returns the size of the node mask More... | |
nodeid_t | numa_num_configured_nodes (void) |
Obtains the number of all memory nodes in the system. More... | |
struct bitmap * | numa_get_mems_allowed (void) |
obtains the nodes the domain is allowed to allocate memory from More... | |
coreid_t | numa_num_configured_cpus (void) |
returns the total numberof CPUs in the system More... | |
coreid_t | numa_num_task_cpus (void) |
returns the number of cpus that the calling domain is allowed to use. More... | |
nodeid_t | numa_num_task_nodes (void) |
returns the number of nodes on which the calling domain is allowed to allocate memory More... | |
errval_t | numa_parse_bitmap (char *line, struct bitmap *mask) |
parses line , which is a character string More... | |
struct bitmap * | numa_parse_nodestring (char *string) |
parses a character string list of nodes into a bit mask. More... | |
struct bitmap * | numa_parse_cpustring (char *string) |
parses a character string list of cpus into a bit mask. More... | |
size_t | numa_node_size (nodeid_t node, uintptr_t *freep) |
obtains the size of a node More... | |
lpaddr_t | numa_node_base (nodeid_t node) |
obtains the base address of the numa node More... | |
nodeid_t | numa_preferred (void) |
returns the preferred node of the current task. More... | |
void | numa_set_preferred (nodeid_t node) |
sets the preferred node for the current task to node More... | |
struct bitmap * | numa_get_interleave_mask (void) |
returns the current interleave mask More... | |
void | numa_set_interleave_mask (struct bitmap *nodemask) |
sets the memory interleave mask for the current task to nodemask More... | |
void | numa_bind (struct bitmap *nodemask) |
binds the current task and its children to the nodes specified in nodemask. More... | |
void | numa_set_localalloc (void) |
sets the memory allocation policy for the calling task to local allocation. | |
errval_t | numa_set_membind (struct bitmap *nodemask) |
sets the memory allocation mask. More... | |
struct bitmap * | numa_get_membind (void) |
returns the mask of nodes from which memory can currently be allocated. More... | |
void * | numa_alloc_onnode (size_t size, nodeid_t node, size_t pagesize) |
allocates memory on a specific node. More... | |
void * | numa_alloc_local (size_t size, size_t pagesize) |
allocates size bytes of memory on the local node More... | |
void * | numa_alloc_interleaved (size_t size, size_t pagesize) |
allocates size bytes of memory page interleaved on all nodes. More... | |
void * | numa_alloc_interleaved_subset (size_t size, size_t pagesize, struct bitmap *nodemask) |
allocates size bytes of memory page interleaved the nodes specified in the nodemask. More... | |
void * | numa_alloc (size_t size, size_t pagesize) |
allocates size bytes of memory with the current NUMA policy. More... | |
void * | numa_realloc (void *old_addr, size_t old_size, size_t new_size) |
changes the size of the memory area. More... | |
void | numa_free (void *start, size_t size) |
frees size bytes of memory starting at start More... | |
errval_t | numa_frame_alloc_on_node (struct capref *dest, size_t size, nodeid_t node, size_t *ret_size) |
allocates a frame on a specific node More... | |
errval_t | numa_frame_free (struct capref frame) |
frees a previously allocated frame More... | |
errval_t | numa_run_on_node (nodeid_t node) |
runs the current domain on a specific node. More... | |
errval_t | numa_run_on_node_mask (struct bitmap *nodemask) |
runs the current domain only on nodes specified in nodemask. More... | |
struct bitmap * | numa_get_run_node_mask (void) |
returns a mask of CPUs on which the current task is allowed to run. More... | |
void | numa_set_bind_policy (numa_policy_t strict) |
specify the memory bind policy More... | |
void | numa_set_strict (numa_policy_t strict) |
enable or disable the strict allocation policy More... | |
uint32_t | numa_distance (nodeid_t from, nodeid_t to) |
reports the distance in the machine topology between two nodes More... | |
errval_t | numa_sched_getaffinity (domainid_t did, struct bitmap *mask) |
retrieves a bitmask of the cpus on which a domain may run More... | |
errval_t | numa_sched_setaffinity (domainid_t did, struct bitmap *mask) |
sets a domain's allowed cpu's to those cpu's specified in mask. More... | |
size_t | numa_pagesize (void) |
returns the page size More... | |
errval_t | numa_node_to_cpus (nodeid_t node, struct bitmap *mask) |
converts a node number to a bitmask of CPUs More... | |
coreid_t | numa_num_node_cpus (nodeid_t node) |
gets the number of cores for the given numa node More... | |
coreid_t | numa_node_get_core (nodeid_t node, coreid_t local_core_id) |
gets the system's core ID for a node/local core id configuration More... | |
nodeid_t | numa_node_of_cpu (coreid_t cpu) |
returns the node that a cpu belongs to More... | |
struct bitmap * | numa_allocate_cpumask (void) |
allocates a bit mask to represent the cores in the system More... | |
void | numa_free_cpumask (struct bitmap *cpumask) |
frees a previously allocated CPU bitmask More... | |
struct bitmap * | numa_allocate_nodemask (void) |
allocates a bit mask to represent the nodes in the system More... | |
void | numa_free_nodemask (struct bitmap *nodemask) |
frees a previously allocated node bitmask More... | |
struct bitmap * | numa_bitmask_alloc (unsigned int n) |
allocates a bitmask structure and its associated bit mask More... | |
struct bitmap * | numa_bitmask_clearall (struct bitmap *bmp) |
sets all bits in the bit mask to 0. More... | |
struct bitmap * | numa_bitmask_clearbit (struct bitmap *bmp, unsigned int n) |
clears the n-th bit of a bitmask More... | |
bool | numa_bitmask_equal (const struct bitmap *bmp1, const struct bitmap *bmp2) |
checks if two bitmasks are equal More... | |
void | numa_bitmask_free (struct bitmap *bmp) |
frees the memory of a bitmask More... | |
bool | numa_bitmask_isbitset (const struct bitmap *bmp, unsigned int n) |
checks if the n-th bit is set in the bitmask More... | |
size_t | numa_bitmask_nbytes (struct bitmap *bmp) |
returns the size (in bytes) of the bit mask More... | |
struct bitmap * | numa_bitmask_setall (struct bitmap *bmp) |
sets all bits of a bitmask to 1 More... | |
struct bitmap * | numa_bitmask_setbit (struct bitmap *bmp, unsigned int n) |
sets the n-th bit of a bitmask to 1 More... | |
void | copy_bitmask_to_nodemask (struct bitmap *bmp, nodemask_t *nodemask) |
copies the bitmask to a nodemask More... | |
void | copy_nodemask_to_bitmask (nodemask_t *nodemask, struct bitmap *bmp) |
copies the contents of a nodemask into the bitmask More... | |
void | copy_bitmask_to_bitmask (struct bitmap *bmpfrom, struct bitmap *bmpto) |
copies one bitmask into another More... | |
uint32_t | numa_bitmask_weight (const struct bitmap *bmp) |
returns a count of the bits that are set in the body of the bitmask More... | |
errval_t | numa_move_pages (domainid_t did, size_t count, void **pages, const nodeid_t *nodes, errval_t *status, int flags) |
moves a list of pages in the address space of the current domain More... | |
errval_t | numa_migrate_pages (domainid_t did, struct bitmap *fromnodes, struct bitmap *tonodes) |
migrate a domain from one set of nodes to another More... | |
void | numa_error (char *where) |
void | numa_warn (int number, char *where,...) |
Variables | |
struct bitmap * | numa_all_nodes_ptr |
bitmask that is allocated by the library with bits representing all nodes on which the calling task may allocate memory. | |
struct bitmap * | numa_no_nodes_ptr |
points to a bitmask that is allocated by the library and left all zeroes. | |
struct bitmap * | numa_all_cpus_ptr |
points to a bitmask that is allocated by the library with bits representing all cpus on which the calling task may execute. | |
header specifying the interface of libnuma
This is derived from:
Linux man pages "numa" libnuma from http://oss.sgi.com/projects/libnuma/
#define NUMA_MAX_NUMNODES 16 |
< the maximum number of nodes supported
specify the local node for allocation
enum numa_policy |
void copy_bitmask_to_bitmask | ( | struct bitmap * | bmpfrom, |
struct bitmap * | bmpto | ||
) |
copies one bitmask into another
bmpfrom | the source bitmask |
bmpto | the destination bitmask |
If the two areas differ in size, the copy is truncated to the size of the receiving field or zero-filled.
void copy_bitmask_to_nodemask | ( | struct bitmap * | bmp, |
nodemask_t * | nodemask | ||
) |
copies the bitmask to a nodemask
bmp | the bitmask to copy |
nodemask | the destination nodemask |
If the two areas differ in size, the copy is truncated to the size of the receiving field or zero-filled.
void copy_nodemask_to_bitmask | ( | nodemask_t * | nodemask, |
struct bitmap * | bmp | ||
) |
copies the contents of a nodemask into the bitmask
nodemask | node mask to copy from |
bmp | bitmap to copy into |
If the two areas differ in size, the copy is truncated to the size of the receiving field or zero-filled.
void* numa_alloc | ( | size_t | size, |
size_t | pagesize | ||
) |
allocates size bytes of memory with the current NUMA policy.
size | size of the memory region in bytes |
pagesize | page size to be used for the mapping |
The memory must be freed with numa_free(). On errors NULL is returned.
size | size of the memory region in bytes |
pagesize | preferred page size to be used |
The memory must be freed with numa_free(). On errors NULL is returned.
void* numa_alloc_interleaved | ( | size_t | size, |
size_t | pagesize | ||
) |
allocates size bytes of memory page interleaved on all nodes.
size | size of the memory region in bytes |
pagesize | page size to be used for the mapping |
should only be used for large areas consisting of multiple pages. The memory must be freed with numa_free(). On errors NULL is returned.
size | size of the memory region in bytes |
pagesize | preferred page size to be used |
should only be used for large areas consisting of multiple pages. The memory must be freed with numa_free(). On errors NULL is returned.
void* numa_alloc_interleaved_subset | ( | size_t | size, |
size_t | pagesize, | ||
struct bitmap * | nodemask | ||
) |
allocates size bytes of memory page interleaved the nodes specified in the nodemask.
size | size of the memory region in bytes |
nodemask | subset of nodes to consider for allocation |
pagesize | page size to be used for the mapping |
should only be used for large areas consisting of multiple pages. The memory must be freed with numa_free(). On errors NULL is returned.
size | size of the memory region in bytes |
nodemask | subset of nodes to consider for allocation |
pagesize | preferred page size to be used |
should only be used for large areas consisting of multiple pages. The memory must be freed with numa_free(). On errors NULL is returned.
void* numa_alloc_local | ( | size_t | size, |
size_t | pagesize | ||
) |
allocates size bytes of memory on the local node
size | size of the memory region in bytes |
pagesize | page size to be used for the mapping |
The memory must be freed with numa_free(). On errors NULL is returned.
void* numa_alloc_onnode | ( | size_t | size, |
nodeid_t | node, | ||
size_t | pagesize | ||
) |
allocates memory on a specific node.
size | size of the region in bytes |
node | ID of the node to allocate from |
pagesize | page size to be used for the mapping |
The size argument will be rounded up to a multiple of the system page size. if the specified node is externally denied to this process, this call will fail. The memory must be freed with numa_free(). On errors NULL is returned.
struct bitmap* numa_allocate_cpumask | ( | void | ) |
allocates a bit mask to represent the cores in the system
allocates a bit mask to represent the cores in the system
struct bitmap* numa_allocate_nodemask | ( | void | ) |
allocates a bit mask to represent the nodes in the system
errval_t numa_available | ( | void | ) |
checks if numa support is available
this function must be called before any of the other functions of libnuma. during the call to numa_available the library also gets initialized
void numa_bind | ( | struct bitmap * | nodemask | ) |
binds the current task and its children to the nodes specified in nodemask.
nodemask | bitmap representing the nodes |
struct bitmap* numa_bitmask_alloc | ( | unsigned int | n | ) |
allocates a bitmask structure and its associated bit mask
n | the number of bits |
struct bitmap* numa_bitmask_clearall | ( | struct bitmap * | bmp | ) |
sets all bits in the bit mask to 0.
bmp | pointer to the bitmap |
struct bitmap* numa_bitmask_clearbit | ( | struct bitmap * | bmp, |
unsigned int | n | ||
) |
clears the n-th bit of a bitmask
bmp | the bitmask |
n | the bit to clear |
bool numa_bitmask_equal | ( | const struct bitmap * | bmp1, |
const struct bitmap * | bmp2 | ||
) |
checks if two bitmasks are equal
bmp1 | bitmask 1 |
bmp2 | bitmask 2 |
void numa_bitmask_free | ( | struct bitmap * | bmp | ) |
frees the memory of a bitmask
bmp | the bitmask to be freed |
bool numa_bitmask_isbitset | ( | const struct bitmap * | bmp, |
unsigned int | n | ||
) |
checks if the n-th bit is set in the bitmask
bmp | the bitmap |
n | which bit to check |
size_t numa_bitmask_nbytes | ( | struct bitmap * | bmp | ) |
returns the size (in bytes) of the bit mask
bmp | the bitmask |
struct bitmap* numa_bitmask_setall | ( | struct bitmap * | bmp | ) |
sets all bits of a bitmask to 1
bmp | the bitmask |
struct bitmap* numa_bitmask_setbit | ( | struct bitmap * | bmp, |
unsigned int | n | ||
) |
sets the n-th bit of a bitmask to 1
bmp | the bitmask |
n | which bit to activate |
uint32_t numa_bitmask_weight | ( | const struct bitmap * | bmp | ) |
returns a count of the bits that are set in the body of the bitmask
bmp | the bitmask to count the set bits |
nodeid_t numa_current_node | ( | void | ) |
returns the current node the domain is running on
uint32_t numa_distance | ( | nodeid_t | from, |
nodeid_t | to | ||
) |
reports the distance in the machine topology between two nodes
from | source node to measure the distance |
to | target node to measure the distance |
The factors are a multiple of 10. A node has distance 10 to itself.
void numa_error | ( | char * | where | ) |
is a libnuma internal function that can be overridden by the user program. This function is called with a char * argument when a libnuma function fails. Overriding the library internal definition makes it possible to specify a different error handling strategy when a libnuma function fails. It does not affect numa_available(). The numa_error() function defined in libnuma prints an error on stderr and terminates the program if numa_exit_on_error is set to a non-zero value. The default value of numa_exit_on_error is zero.
where |
errval_t numa_frame_alloc_on_node | ( | struct capref * | dest, |
size_t | size, | ||
nodeid_t | node, | ||
size_t * | ret_size | ||
) |
allocates a frame on a specific node
dest | capref to store the frame |
size | size of the frame to allocated |
node | node on which the frame should be allocated |
ret_size | returned size of the frame capability |
errval_t numa_frame_free | ( | struct capref | frame | ) |
frees a previously allocated frame
frame | capability to free |
void numa_free | ( | void * | start, |
size_t | size | ||
) |
frees size bytes of memory starting at start
start | start of the memory region |
size | number of bytes to free |
the memory must be previously allocated by one of the numa_alloc* functions
void numa_free_cpumask | ( | struct bitmap * | cpumask | ) |
frees a previously allocated CPU bitmask
cpumask | pointer to a previously allocated CPU bitmask |
void numa_free_nodemask | ( | struct bitmap * | nodemask | ) |
frees a previously allocated node bitmask
nodemask | pointer to a previously allocated node bitmask |
struct bitmap* numa_get_interleave_mask | ( | void | ) |
returns the current interleave mask
returns the current interleave mask if the task's memory allocation policy is page interleaved. Otherwise, this function returns an empty mask.
struct bitmap* numa_get_membind | ( | void | ) |
returns the mask of nodes from which memory can currently be allocated.
struct bitmap* numa_get_mems_allowed | ( | void | ) |
obtains the nodes the domain is allowed to allocate memory from
returns the mask of nodes from which the process is allowed to allocate memory in it's current cpuset context.
struct bitmap* numa_get_run_node_mask | ( | void | ) |
returns a mask of CPUs on which the current task is allowed to run.
coreid_t numa_max_core | ( | void | ) |
returns the highest ID of the present cores
nodeid_t numa_max_node | ( | void | ) |
returns the highest node number available on the current system.
errval_t numa_migrate_pages | ( | domainid_t | did, |
struct bitmap * | fromnodes, | ||
struct bitmap * | tonodes | ||
) |
migrate a domain from one set of nodes to another
did | the domain ID |
fromnodes | bitmap representing the current nodes |
tonodes | bitmap representing the |
errval_t numa_move_pages | ( | domainid_t | did, |
size_t | count, | ||
void ** | pages, | ||
const nodeid_t * | nodes, | ||
errval_t * | status, | ||
int | flags | ||
) |
moves a list of pages in the address space of the current domain
did | the domain ID |
count | number of pages to move |
pages | list of pages |
nodes | list of nodes to which the pages can be moved |
status | returns the outcome for each page |
flags | flags for moving the pages |
lpaddr_t numa_node_base | ( | nodeid_t | node | ) |
obtains the base address of the numa node
coreid_t numa_node_get_core | ( | nodeid_t | node, |
coreid_t | local_core_id | ||
) |
gets the system's core ID for a node/local core id configuration
nodeid_t numa_node_of_cpu | ( | coreid_t | cpu | ) |
returns the node that a cpu belongs to
cpu | ID of the core |
size_t numa_node_size | ( | nodeid_t | node, |
uintptr_t * | freep | ||
) |
obtains the size of a node
node | ID of the NUMA node |
freep |
returns the memory size of a node. If the argument freep is not NULL, it used to return the amount of free memory on the node. On error it returns NUMA_NODE_INVALIDalias for NUMA node size 64bit variants
node | ID of the NUMA node |
freep | returns the number of available bytes of the node |
returns the memory size of a node. If the argument freep is not NULL, it used to return the amount of free memory on the node. On error it returns NUMA_NODE_INVALID
errval_t numa_node_to_cpus | ( | nodeid_t | node, |
struct bitmap * | mask | ||
) |
converts a node number to a bitmask of CPUs
node | the ID of the node |
mask | bitmap representing the CPUs of this node |
The user must pass a bitmask structure with a mask buffer long enough to represent all possible cpu's
coreid_t numa_num_configured_cpus | ( | void | ) |
returns the total numberof CPUs in the system
returns the number of cpus in the system. This count includes any cpus that are currently disabled.
nodeid_t numa_num_configured_nodes | ( | void | ) |
Obtains the number of all memory nodes in the system.
returns the number of memory nodes in the system. This count includes any nodes that are currently disabled.
coreid_t numa_num_node_cpus | ( | nodeid_t | node | ) |
gets the number of cores for the given numa node
node | NUMA node to get the number of cores |
nodeid_t numa_num_possible_nodes | ( | void | ) |
returns the size of the node mask
coreid_t numa_num_task_cpus | ( | void | ) |
returns the number of cpus that the calling domain is allowed to use.
nodeid_t numa_num_task_nodes | ( | void | ) |
returns the number of nodes on which the calling domain is allowed to allocate memory
size_t numa_pagesize | ( | void | ) |
returns the page size
errval_t numa_parse_bitmap | ( | char * | line, |
struct bitmap * | mask | ||
) |
parses line , which is a character string
line | character string to parse |
mask | bitmap to store the result |
The string contains the hexadecimal representation of a bit map.
XXX according to the man pages this function is only used internally
struct bitmap* numa_parse_cpustring | ( | char * | string | ) |
parses a character string list of cpus into a bit mask.
string | character string to parse |
The string is a comma-separated list of cpu numbers or cpu ranges Examples: 1-5,7,10 !4-5 +0-3
struct bitmap* numa_parse_nodestring | ( | char * | string | ) |
parses a character string list of nodes into a bit mask.
string | character string to parse |
The string is a comma-separated list of node numbers or node ranges Examples: 1-5,7,10 !4-5 +0-3
If the string length is zero, then the numa_no_nodes_ptr is returned
nodeid_t numa_preferred | ( | void | ) |
returns the preferred node of the current task.
void* numa_realloc | ( | void * | old_addr, |
size_t | old_size, | ||
size_t | new_size | ||
) |
changes the size of the memory area.
old_addr | pointer ot the old memory region |
old_size | size of the old memory region |
new_size | new size to allocate |
errval_t numa_run_on_node | ( | nodeid_t | node | ) |
runs the current domain on a specific node.
node | ID of the node to run the domain on |
Passing -1 permits the kernel to schedule on all nodes again
errval_t numa_run_on_node_mask | ( | struct bitmap * | nodemask | ) |
runs the current domain only on nodes specified in nodemask.
nodemask | bitmap representing the nodes to run the domain on |
errval_t numa_sched_getaffinity | ( | domainid_t | did, |
struct bitmap * | mask | ||
) |
retrieves a bitmask of the cpus on which a domain may run
did | domain ID |
mask | returned bitmask |
errval_t numa_sched_setaffinity | ( | domainid_t | did, |
struct bitmap * | mask | ||
) |
sets a domain's allowed cpu's to those cpu's specified in mask.
did | domain ID |
mask | bitmap representing the CPUs |
void numa_set_bind_policy | ( | numa_policy_t | strict | ) |
specify the memory bind policy
strict | numa policy to apply |
specifies whether calls that bind memory to a specific node should use the preferred policy or a strict policy.
void numa_set_interleave_mask | ( | struct bitmap * | nodemask | ) |
sets the memory interleave mask for the current task to nodemask
nodemask | bitmask representing the nodes |
All new memory allocations are page interleaved over all nodes in the interleave mask. Interleaving can be turned off again by passing an empty mask.
This bitmask is considered to be a hint. Fallback to other nodes may be possible
errval_t numa_set_membind | ( | struct bitmap * | nodemask | ) |
sets the memory allocation mask.
nodemask | bitmap representing the nodes |
The task will only allocate memory from the nodes set in nodemask.
an empty mask or not allowed nodes in the mask will result in an error
void numa_set_preferred | ( | nodeid_t | node | ) |
sets the preferred node for the current task to node
node | ID of the node to set preferred |
The system will attempt to allocate memory from the preferred node, but will fall back to other nodes if no memory is available on the the preferred node
Passing a node of -1 argument specifies local allocation
void numa_set_strict | ( | numa_policy_t | strict | ) |
enable or disable the strict allocation policy
strict | numa policy to apply |
s a flag that says whether the functions allocating on specific nodes should use a strict policy. Strict means the allocation will fail if the memory cannot be allocated on the target node.
void numa_warn | ( | int | number, |
char * | where, | ||
... | |||
) |
is a libnuma internal function that can be also overridden by the user program. It is called to warn the user when a libnuma function encounters a non-fatal error. The default implementation prints a warning to stderr. The first argument is a unique number identifying each warning. After that there is a printf(3)-style format string and a variable number of arguments. numa_warn exits the program when numa_exit_on_warn is set to a non-zero value. The default value of numa_exit_on_warn is zero.
number | |
where |