Fixed Size Allocation
include/mem/fixed_size_alloc.h View source View on GitHubStructs
Section titled “Structs”fixed_size_node
Section titled “fixed_size_node” struct fixed_size_node (1 field) source
fixed_size_page_hdr
Section titled “fixed_size_page_hdr” struct fixed_size_page_hdr (4 fields) source
fixed_size_range_attributes
Section titled “fixed_size_range_attributes” struct fixed_size_range_attributes (5 fields) source
fixed_size_range
Section titled “fixed_size_range” struct fixed_size_range (8 fields) source
§
struct fixed_size_range_attributes attrs §
size_t empty_pages §
size_t full_node_size node size + object size
§
struct fixed_size_range **perdomain_fsrs §
domain_id_t domain Functions
Section titled “Functions”fixed_size_alloc
Section titled “fixed_size_alloc”void * fixed_size_alloc(struct fixed_size_range *fsr) source fixed_size_free
Section titled “fixed_size_free”void fixed_size_free(struct fixed_size_range *fsr, void *obj) source fixed_size_reclaim_freelist_pages
Section titled “fixed_size_reclaim_freelist_pages”void fixed_size_reclaim_freelist_pages(struct fixed_size_range *fsr) source fixed_size_range_create
Section titled “fixed_size_range_create”struct fixed_size_range * fixed_size_range_create(struct fixed_size_range_attributes *attrs) source fixed_size_range_init
Section titled “fixed_size_range_init”void fixed_size_range_init(
struct fixed_size_range *fsr,
struct fixed_size_range_attributes *attrs
) source fixed_size_page_of
Section titled “fixed_size_page_of”struct fixed_size_page_hdr * fixed_size_page_of(void *o) source Macros
Section titled “Macros”FIXED_SIZE_KEEP_EMPTY_PAGES
Section titled “FIXED_SIZE_KEEP_EMPTY_PAGES”#define FIXED_SIZE_KEEP_EMPTY_PAGES 1 source Number of fully-empty freelist backing pages to keep cached per local tree before reclaiming on free
Provides hysteresis so a workload that oscillates across a page boundary does not pmm_alloc/pmm_free on every transition
FIXED_SIZE_RANGE_PERDOMAIN_DEFINE
Section titled “FIXED_SIZE_RANGE_PERDOMAIN_DEFINE”#define FIXED_SIZE_RANGE_PERDOMAIN_DEFINE(name, ...) source Expansion
#define FIXED_SIZE_RANGE_PERDOMAIN_DEFINE(name, ...) \
static cc_unused bool __fsr_##name##_enabled = false; \
static void __##name##_fsr_init(struct fixed_size_range *fsr_, \
size_t domain_) { \
static struct fixed_size_range **__perdomain_fsrs_##name = NULL; \
if (!__perdomain_fsrs_##name) \
__perdomain_fsrs_##name = \
nofail_vnews(__perdomain_fsrs_##name, global.domain_count); \
\
struct fixed_size_range_attributes __fsr_attrs = {__VA_ARGS__}; \
fixed_size_range_init(fsr_, &__fsr_attrs); \
__perdomain_fsrs_##name[domain_] = fsr_; \
fsr_->perdomain_fsrs = __perdomain_fsrs_##name; \
fsr_->domain = domain_; \
if (domain_ == global.domain_count - 1) \
__fsr_##name##_enabled = true; \
} \
PERDOMAIN_DEFINE(struct fixed_size_range, __##name##_fsr, \
__##name##_fsr_init) FSR_PERDOMAIN_ENABLED
Section titled “FSR_PERDOMAIN_ENABLED”#define FSR_PERDOMAIN_ENABLED(name) source Expansion
#define FSR_PERDOMAIN_ENABLED(name) __fsr_##name##_enabled FSR_PERDOMAIN
Section titled “FSR_PERDOMAIN”#define FSR_PERDOMAIN(name) source Expansion
#define FSR_PERDOMAIN(name) PERDOMAIN(__##name##_fsr) FSR_PERDOMAIN_THIS
Section titled “FSR_PERDOMAIN_THIS”#define FSR_PERDOMAIN_THIS(name) source _NONE here: domains are an optimization anyways
Expansion
#define FSR_PERDOMAIN_THIS(name) PERDOMAIN_PTR(TOPC_NONE, __##name##_fsr) FSR_PERDOMAIN_ALLOC
Section titled “FSR_PERDOMAIN_ALLOC”#define FSR_PERDOMAIN_ALLOC(name) source Expansion
#define FSR_PERDOMAIN_ALLOC(name) fixed_size_alloc(FSR_PERDOMAIN_THIS(name)) FSR_PERDOMAIN_FREE
Section titled “FSR_PERDOMAIN_FREE”#define FSR_PERDOMAIN_FREE(name, obj) source Expansion
#define FSR_PERDOMAIN_FREE(name, obj) \
fixed_size_free(FSR_PERDOMAIN_THIS(name), (obj))