FD.io VPP  v20.05.1-6-gf53edbc3b
Vector Packet Processing
valloc.h File Reference

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

+ Include dependency graph for valloc.h:
+ This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Data Structures

struct  clib_valloc_chunk_t
 
struct  clib_valloc_main_t
 

Macros

#define CLIB_VALLOC_BUSY   (1<<0)
 chunk is in use More...
 
#define CLIB_VALLOC_INITIALIZED   (1<<0)
 object has been initialized More...
 

Functions

void clib_valloc_init (clib_valloc_main_t *vam, clib_valloc_chunk_t *template, int need_lock)
 Initialize a virtual memory allocation arena. More...
 
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...
 
uword clib_valloc_free (clib_valloc_main_t *vam, uword baseva)
 Free virtual space. More...
 
uword clib_valloc_alloc (clib_valloc_main_t *vam, uword size, int os_out_of_memory_on_failure)
 Allocate virtual space. More...
 

Variables

format_function_t format_valloc
 

Detailed Description

Simple first-fit virtual space allocator.

Definition in file valloc.h.

Macro Definition Documentation

◆ CLIB_VALLOC_BUSY

#define CLIB_VALLOC_BUSY   (1<<0)

chunk is in use

Definition at line 37 of file valloc.h.

◆ CLIB_VALLOC_INITIALIZED

#define CLIB_VALLOC_INITIALIZED   (1<<0)

object has been initialized

Definition at line 48 of file valloc.h.

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:

Variable Documentation

◆ format_valloc

format_function_t format_valloc

Definition at line 57 of file valloc.h.