Barrelfish
Functions | Variables
alloc.c File Reference

General Numa functions. More...

Functions

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

Variables

struct bitmap * numa_alloc_interleave_mask
 < numa interleave mask for allocations More...
 

Detailed Description

General Numa functions.

Function Documentation

void* numa_alloc ( size_t  size,
size_t  pagesize 
)

allocates size bytes of memory with the current NUMA policy.

Parameters
sizesize of the memory region in bytes
pagesizepreferred page size to be used
Returns
pointer to the mapped memory region

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.

Parameters
sizesize of the memory region in bytes
pagesizepreferred page size to be used
Returns
pointer to the mapped memory region

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.

Parameters
sizesize of the memory region in bytes
nodemasksubset of nodes to consider for allocation
pagesizepreferred page size to be used
Returns
pointer to the mapped memory region

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

Parameters
sizesize of the memory region in bytes
pagesizepage size to be used for the mapping
Returns
pointer to memory region

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.

Parameters
sizesize of the region in bytes
nodeID of the node to allocate from
pagesizepage size to be used for the mapping
Returns
pointer to memory region

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.

void numa_bind ( struct bitmap *  nodemask)

binds the current task and its children to the nodes specified in nodemask.

Parameters
nodemaskbitmap representing the nodes
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

Parameters
destcapref to store the frame
sizesize of the frame to allocated
nodenode on which the frame should be allocated
ret_sizereturned size of the frame capability
Returns
SYS_ERR_OK on SUCCESS errval on FAILURE
errval_t numa_frame_free ( struct capref  frame)

frees a previously allocated frame

Parameters
framecapability to free
void numa_free ( void *  start,
size_t  size 
)

frees size bytes of memory starting at start

Parameters
startstart of the memory region
sizenumber of bytes to free

the memory must be previously allocated by one of the numa_alloc* functions

struct bitmap* numa_get_interleave_mask ( void  )

returns the current interleave mask

Returns
bitmask representing the current interleave state

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.

Returns
bitmap of nodes from which can be allocated
errval_t numa_migrate_pages ( domainid_t  did,
struct bitmap *  fromnodes,
struct bitmap *  tonodes 
)

migrate a domain from one set of nodes to another

Parameters
didthe domain ID
fromnodesbitmap representing the current nodes
tonodesbitmap representing the
Returns
SYS_ERR_OK on SUCCESS
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

Parameters
didthe domain ID
countnumber of pages to move
pageslist of pages
nodeslist of nodes to which the pages can be moved
statusreturns the outcome for each page
flagsflags for moving the pages
Returns
SYS_ERR_OK on SUCCESS
void* numa_realloc ( void *  old_addr,
size_t  old_size,
size_t  new_size 
)

changes the size of the memory area.

Parameters
old_addrpointer ot the old memory region
old_sizesize of the old memory region
new_sizenew size to allocate
void numa_set_interleave_mask ( struct bitmap *  nodemask)

sets the memory interleave mask for the current task to nodemask

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

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

Variable Documentation

struct bitmap* numa_alloc_interleave_mask

< numa interleave mask for allocations

numa bind mask for allocations