|
FD.io VPP
v21.10.1-2-g0a485f517
Vector Packet Processing
|
Go to the documentation of this file.
27 #define CLIB_MEM_BULK_DEFAULT_MIN_ELTS_PER_CHUNK 32
50 return (
uword)
b->elts_per_chunk *
b->elt_sz +
b->chunk_hdr_sz;
66 if (min_elts_per_chunk == 0)
75 b->elts_per_chunk = min_elts_per_chunk;
78 b->elts_per_chunk += (
b->chunk_align - sz) /
b->elt_sz;
114 return (
u8 *)
c +
b->chunk_hdr_sz +
index *
b->elt_sz;
133 c->next->prev =
c->prev;
135 c->prev->next =
c->next;
147 if (
b->avail_chunks == 0)
154 c->n_free =
b->elts_per_chunk;
157 for (
i = 0;
i <
b->elts_per_chunk - 1;
i++)
163 elt_idx =
c->freelist;
184 u32 elt_idx = (
offset -
b->chunk_hdr_sz) /
b->elt_sz;
186 ASSERT (elt_idx < b->elts_per_chunk);
191 if (
c->n_free ==
b->elts_per_chunk)
208 *(
u32 *) p =
c->freelist;
209 c->freelist = elt_idx;
217 uword n_chunks = 0, n_free_elts = 0, n_elts, chunk_sz;
230 n_free_elts +=
c->n_free;
234 n_elts = n_chunks *
b->elts_per_chunk;
235 chunk_sz =
b->chunk_hdr_sz + (
uword)
b->elts_per_chunk *
b->elt_sz;
237 s =
format (s,
"%u bytes/elt, align %u, chunk-align %u, ",
b->elt_sz,
238 b->align,
b->chunk_align);
239 s =
format (s,
"%u elts-per-chunk, chunk size %lu bytes",
b->elts_per_chunk,
243 return format (s,
"\nempty");
245 s =
format (s,
"\n%lu chunks allocated, ", n_chunks);
246 s =
format (s,
"%lu / %lu free elts (%.1f%%), ", n_free_elts, n_elts,
247 (
f64) n_free_elts * 100 / n_elts);
248 s =
format (s,
"%lu bytes of memory consumed", n_chunks * chunk_sz);
__clib_export void * clib_mem_bulk_alloc(clib_mem_bulk_handle_t h)
static clib_mem_heap_t * clib_mem_get_heap(void)
__clib_export clib_mem_bulk_handle_t clib_mem_bulk_init(u32 elt_sz, u32 align, u32 min_elts_per_chunk)
void * clib_mem_bulk_handle_t
#define CLIB_MEM_POISON(a, s)
DLMALLOC_EXPORT void * mspace_memalign(mspace msp, size_t alignment, size_t bytes)
static void * get_chunk_elt_ptr(clib_mem_bulk_t *b, clib_mem_bulk_chunk_hdr_t *c, u32 index)
static heap_elt_t * first(heap_header_t *h)
struct clib_mem_bulk_chunk_hdr * prev
__clib_export void clib_mem_bulk_free(clib_mem_bulk_handle_t h, void *p)
static uword round_pow2(uword x, uword pow2)
static void add_to_chunk_list(clib_mem_bulk_chunk_hdr_t **first, clib_mem_bulk_chunk_hdr_t *c)
struct clib_bihash_value offset
template key/value backing page structure
struct clib_mem_bulk_chunk_hdr clib_mem_bulk_chunk_hdr_t
static void remove_from_chunk_list(clib_mem_bulk_chunk_hdr_t **first, clib_mem_bulk_chunk_hdr_t *c)
template key/value backing page structure
description fragment has unexpected format
#define CLIB_MEM_UNPOISON(a, s)
clib_memset(h->entries, 0, sizeof(h->entries[0]) *entries)
clib_mem_bulk_chunk_hdr_t * full_chunks
__clib_export u8 * format_clib_mem_bulk(u8 *s, va_list *args)
struct clib_mem_bulk_chunk_hdr * next
static uword max_pow2(uword x)
__clib_export void clib_mem_bulk_destroy(clib_mem_bulk_handle_t h)
DLMALLOC_EXPORT void mspace_free(mspace msp, void *mem)
#define CLIB_MEM_BULK_DEFAULT_MIN_ELTS_PER_CHUNK
static uword bulk_chunk_size(clib_mem_bulk_t *b)