FD.io VPP  v19.08.2-294-g37e99c22d
Vector Packet Processing
valloc.c File Reference

Simple first-fit virtual space allocator. More...

+ Include dependency graph for valloc.c:

Go to the source code of this file.

Functions

void clib_valloc_add_chunk (clib_valloc_main_t *vam, clib_valloc_chunk_t *template)
 Add a chunk of memory to a virtual allocation arena. More...
 
void clib_valloc_init (clib_valloc_main_t *vam, clib_valloc_chunk_t *template, int need_lock)
 Initialize a virtual memory allocation arena. More...
 
uword clib_valloc_alloc (clib_valloc_main_t *vam, uword size, int os_out_of_memory_on_failure)
 Allocate virtual space. More...
 
uword clib_valloc_free (clib_valloc_main_t *vam, uword baseva)
 Free virtual space. More...
 
u8format_valloc (u8 *s, va_list *va)
 format a virtual allocation arena (varargs) More...
 

Detailed Description

Simple first-fit virtual space allocator.

Definition in file valloc.c.

Function Documentation

◆ clib_valloc_add_chunk()

void clib_valloc_add_chunk ( clib_valloc_main_t vam,
clib_valloc_chunk_t template 
)

Add a chunk of memory to a virtual allocation arena.

Parameters
vam- clib_valloc_main_t * pointer to the allocation arena
template- clib_valloc_chunk_t * pointer to a template chunk which describes the virtual address range to add
Note
only the baseva and size member of the template chunk are significant It's perfectly OK for the new chunk to be discontinuous with previous chunks, the chunk fusion algorithm won't merge them.

Definition at line 33 of file valloc.c.

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ clib_valloc_alloc()

uword clib_valloc_alloc ( clib_valloc_main_t vam,
uword  size,
int  os_out_of_memory_on_failure 
)

Allocate virtual space.

Parameters
vam- clib_valloc_main_t * pointer to the allocation arena
size- u64 number of bytes to allocate - 1=> panic on allocation failure
Returns
uword allocated space, 0=> failure

Definition at line 151 of file valloc.c.

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ clib_valloc_free()

uword clib_valloc_free ( clib_valloc_main_t vam,
uword  baseva 
)

Free virtual space.

Parameters
vam- clib_valloc_main_t * pointer to the allocation arena
baseva- uword base virtual address of the returned space
Returns
uword - size of the freed virtual chunk
Note
the size is returned since we know it / in case the caller doesn't memorize chunk sizes

Definition at line 228 of file valloc.c.

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ clib_valloc_init()

void clib_valloc_init ( clib_valloc_main_t vam,
clib_valloc_chunk_t template,
int  need_lock 
)

Initialize a virtual memory allocation arena.

Parameters
vam- clib_valloc_main_t * pointer to the arena to initialize
template- clib_valloc_chunk_t * pointer to a template chunk which describes the initial virtual address range

Definition at line 129 of file valloc.c.

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ format_valloc()

u8* format_valloc ( u8 s,
va_list *  va 
)

format a virtual allocation arena (varargs)

Parameters
vam- clib_valloc_main_t pointer to the arena to format
verbose- int - verbosity level
Returns
u8 vector

Definition at line 313 of file valloc.c.

+ Here is the call graph for this function: