Barrelfish
Functions | Variables
numa.c File Reference

General Numa functions. More...

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...
 
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...
 
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...
 
nodeid_t numa_node_of_cpu (coreid_t cpu)
 returns the node that a cpu belongs to More...
 
coreid_t numa_num_node_cpus (nodeid_t node)
 gets the number of cores for the given numa node More...
 

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.
 
struct numa_topology numa_topology
 data structure representing the numa topology More...
 

Detailed Description

General Numa functions.

Function Documentation

errval_t numa_available ( void  )

checks if numa support is available

Returns
NUMA_ERR_NOT_AVAILABLE value all other functions are undefined SYS_ERR_OK: NUMA functionality 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

nodeid_t numa_current_node ( void  )

returns the current node the domain is running on

Returns
ID of the current node
uint32_t numa_distance ( nodeid_t  from,
nodeid_t  to 
)

reports the distance in the machine topology between two nodes

Parameters
fromsource node to measure the distance
totarget node to measure the distance
Returns
distance between two nodes 0 iff cannot be deterimed

The factors are a multiple of 10. A node has distance 10 to itself.

struct bitmap* numa_get_mems_allowed ( void  )

obtains the nodes the domain is allowed to allocate memory from

Returns
bitmask representing the allowing nodes

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.

Returns
bitmap represening the coreids the domain is allowed to run
coreid_t numa_max_core ( void  )

returns the highest ID of the present cores

Returns
the maximum number of cores in the system
nodeid_t numa_max_node ( void  )

returns the highest node number available on the current system.

Returns
ID of the max NUMA node
lpaddr_t numa_node_base ( nodeid_t  node)

obtains the base address of the numa node

Returns
physical address of the start of the numa node NUMA_NODE_INVALID if the node does not exist
nodeid_t numa_node_of_cpu ( coreid_t  cpu)

returns the node that a cpu belongs to

Parameters
cpuID of the core
Returns
node ID on SUCCESS NUMA_NODE_INVALID on FAILURE
size_t numa_node_size ( nodeid_t  node,
uintptr_t *  freep 
)

obtains the size of a node

Parameters
nodeID of the NUMA node
freepreturns the number of available bytes of the node
Returns
size of the node in bytes

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

Parameters
nodethe ID of the node
maskbitmap representing the CPUs of this node
Returns
SYS_ERR_OK on SUCCESS NUMA_ERR_BITMAP_RANGE on FAILURE (too small bitmap)

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
total number of 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
number of 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

Parameters
nodeNUMA node to get the number of cores
Returns
number of cores for the node
nodeid_t numa_num_possible_nodes ( void  )

returns the size of the node mask

Returns
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.

Returns
number of CPUs the 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

Returns
number of nodes the domain is allowed to use
size_t numa_pagesize ( void  )

returns the page size

Returns
the number of bytes in a page
nodeid_t numa_preferred ( void  )

returns the preferred node of the current task.

Returns
node ID where memory is preferably allocated
errval_t numa_run_on_node ( nodeid_t  node)

runs the current domain on a specific node.

Parameters
nodeID of the node to run the domain on
Returns
SYS_ERR_OK on SUCCESS errval on FAILURE

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.

Parameters
nodemaskbitmap representing the nodes to run the domain on
Returns
SYS_ERR_OK on SUCCESS errval on FAILURE
errval_t numa_sched_getaffinity ( domainid_t  did,
struct bitmap *  mask 
)

retrieves a bitmask of the cpus on which a domain may run

Parameters
diddomain ID
maskreturned bitmask
Returns
SYS_ERR_OK on success errval on FAILURE
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.

Parameters
diddomain ID
maskbitmap representing the CPUs
Returns
SYS_ERR_OK on success errval on FAILURE
void numa_set_bind_policy ( numa_policy_t  strict)

specify the memory bind policy

Parameters
strictnuma 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_preferred ( nodeid_t  node)

sets the preferred node for the current task to node

Parameters
nodeID 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

Parameters
strictnuma 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.

Variable Documentation

data structure representing the numa topology

numa interleave mask for allocations