Arax -8d09c51940345c86062e8ef2427c705ae66e5926
A Runtime Framework for Decoupling Applications from Heterogeneous Accelerators
Loading...
Searching...
No Matches
alloc.c File Reference
#include "arch/alloc.h"
#include "tlsf.h"
+ Include dependency graph for tlsf/alloc.c:

Go to the source code of this file.

Data Structures

struct  arch_alloc_inner_s
 
struct  inspect_walker_state
 

Functions

int arch_alloc_init_once (arch_alloc_s *_alloc, size_t size)
 
void arch_alloc_init_always (arch_alloc_s *alloc)
 
void * arch_alloc_allocate (arch_alloc_s *_alloc, size_t size)
 
void _arch_alloc_free (arch_alloc_s *_alloc, void *mem)
 
void arch_alloc_exit (arch_alloc_s *_alloc)
 
arch_alloc_stats_s arch_alloc_stats (arch_alloc_s *_alloc)
 
void inspect_walker (void *ptr, size_t size, int used, void *user)
 
void arch_alloc_inspect (arch_alloc_s *_alloc, void(*inspector)(void *start, void *end, size_t size, void *arg), void *arg)
 
void * arax_mmap (size_t s)
 
void * arax_ummap (void *a, size_t s)
 
arch_alloc_sarch_alloc_create_sub_alloc (arch_alloc_s *parent)
 
utils_bitmap_sarch_alloc_get_bitmap ()
 

Function Documentation

◆ _arch_alloc_free()

◆ arax_mmap()

void * arax_mmap ( size_t s)

Allocate enough pages(4096 bytes) to hold s bytes.

Parameters
sNumber of bytes requested (has to be multiple of BIT_ALLOCATOR_BLOCK)
Returns
Page alligned pointer to memory

Definition at line 114 of file tlsf/alloc.c.

References arax_assert, BIT_ALLOCATOR_BLOCK, BIT_ALLOCATOR_BLOCK_MASK, BITMAP_NOT_FOUND, global_alloc, and utils_bitmap_alloc_bits().

+ Here is the call graph for this function:

◆ arax_ummap()

void * arax_ummap ( void * a,
size_t s )

Release the pages starting from a and ending after bytes

Parameters
aPointer returned from a call of arax_mmap().
sNumber of bytes to be freed (has to be multiple of BIT_ALLOCATOR_BLOCK)
Returns
NULL on success

Definition at line 119 of file tlsf/alloc.c.

References BIT_ALLOCATOR_BLOCK, global_alloc, arch_alloc_inner_s::start, and utils_bitmap_free_bits().

+ Here is the call graph for this function:

◆ arch_alloc_allocate()

void * arch_alloc_allocate ( arch_alloc_s * alloc,
size_t size )

Allocate contiguous memory from the alloc arch_alloc_s instance.

Parameters
allocAn initialized arch_alloc_s instance.
sizeThe size of the allocation.
Returns
Pointer to the beginning of size usable bytes, or NULL on failure.

Definition at line 26 of file tlsf/alloc.c.

References arch_alloc_inner_s::lock, arch_alloc_inner_s::root, arch_alloc_inner_s::start, utils_spinlock_lock, utils_spinlock_unlock, utils_timer_get_duration_ns, and utils_timer_set.

Referenced by arax_object_register(), arax_object_rename(), arax_plot_register_metric(), and async_semaphore_dec().

+ Here is the caller graph for this function:

◆ arch_alloc_create_sub_alloc()

arch_alloc_s * arch_alloc_create_sub_alloc ( arch_alloc_s * parent)

Create a sub-allocator.

This allocator user the same global bitmap for requesting bulk allocations, but maintains separate metadata from the 'global' allocator.

Use arch_alloc_free(), arch_alloc_allocate() to alloc/free memory.

Returned allocator should be eventually released by calling arch_alloc_exit()

Parameters
parentallocator
Returns
New arch_alloc_s instance.

Definition at line 124 of file tlsf/alloc.c.

References arch_alloc_allocate(), and arch_alloc_inner_s::root.

+ Here is the call graph for this function:

◆ arch_alloc_exit()

void arch_alloc_exit ( arch_alloc_s * alloc)

Release any resources claimed by the alloc arch_alloc_s instance.

Note
The shared memory segment (shm in arch_alloc_init) must be freed by the user.

Definition at line 70 of file tlsf/alloc.c.

References arch_alloc_inner_s::root.

Referenced by arax_pipe_exit().

+ Here is the caller graph for this function:

◆ arch_alloc_get_bitmap()

utils_bitmap_s * arch_alloc_get_bitmap ( )

Definition at line 129 of file tlsf/alloc.c.

References global_alloc.

◆ arch_alloc_init_always()

void arch_alloc_init_always ( arch_alloc_s * alloc)

Perform necessary initialization for every arax application.

Note
This has to be called on new processes, that have not called arch_alloc_init_once
Parameters
alloc

Definition at line 23 of file tlsf/alloc.c.

References global_alloc.

Referenced by arax_pipe_init().

+ Here is the caller graph for this function:

◆ arch_alloc_init_once()

int arch_alloc_init_once ( arch_alloc_s * alloc,
size_t size )

Initialize a arch_alloc_s instance on a mapped shared memory segment.

Note
This only has to be called by the first process, to initialize global state
Parameters
allocPointer to be filled with initialized instance.
sizeThe size of the shared memory segment in bytes.
Returns
0 on success.

Definition at line 11 of file tlsf/alloc.c.

References BIT_ALLOCATOR_BLOCK, BIT_ALLOCATOR_BLOCK_MASK, BITS_PER_PAGE, arch_alloc_inner_s::bmp, global_alloc, arch_alloc_inner_s::lock, arch_alloc_inner_s::root, arch_alloc_inner_s::start, utils_bitmap_init(), and utils_spinlock_init.

Referenced by arax_pipe_init().

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

◆ arch_alloc_inspect()

void arch_alloc_inspect ( arch_alloc_s * _alloc,
void(* inspector )(void *start, void *end, size_t size, void *arg),
void * arg )

Definition at line 105 of file tlsf/alloc.c.

References inspect_walker_state::arg, inspect_walker(), inspect_walker_state::inspector, and arch_alloc_inner_s::root.

+ Here is the call graph for this function:

◆ arch_alloc_stats()

arch_alloc_stats_s arch_alloc_stats ( arch_alloc_s * _alloc)

Definition at line 77 of file tlsf/alloc.c.

References _arch_alloc_mspace_mallinfo(), and arch_alloc_inner_s::root.

+ Here is the call graph for this function:

◆ inspect_walker()

void inspect_walker ( void * ptr,
size_t size,
int used,
void * user )

Definition at line 98 of file tlsf/alloc.c.

References inspect_walker_state::arg, and inspect_walker_state::inspector.

Referenced by arch_alloc_inspect().

+ Here is the caller graph for this function: