mirror of
https://github.com/jemalloc/jemalloc.git
synced 2026-06-05 03:34:16 +03:00
Reformat the codebase with the clang-format 18.
This commit is contained in:
parent
a952a3b8b0
commit
6200e8987f
346 changed files with 18286 additions and 17770 deletions
209
src/base.c
209
src/base.c
|
|
@ -12,7 +12,7 @@
|
|||
* of metadata), since more metadata (e.g. rtree nodes) come from a0's base.
|
||||
*/
|
||||
|
||||
#define BASE_AUTO_THP_THRESHOLD 2
|
||||
#define BASE_AUTO_THP_THRESHOLD 2
|
||||
#define BASE_AUTO_THP_THRESHOLD_A0 5
|
||||
|
||||
/******************************************************************************/
|
||||
|
|
@ -22,25 +22,21 @@ static base_t *b0;
|
|||
|
||||
metadata_thp_mode_t opt_metadata_thp = METADATA_THP_DEFAULT;
|
||||
|
||||
const char *const metadata_thp_mode_names[] = {
|
||||
"disabled",
|
||||
"auto",
|
||||
"always"
|
||||
};
|
||||
const char *const metadata_thp_mode_names[] = {"disabled", "auto", "always"};
|
||||
|
||||
/******************************************************************************/
|
||||
|
||||
static inline bool
|
||||
metadata_thp_madvise(void) {
|
||||
return (metadata_thp_enabled() &&
|
||||
(init_system_thp_mode == thp_mode_default));
|
||||
return (metadata_thp_enabled()
|
||||
&& (init_system_thp_mode == thp_mode_default));
|
||||
}
|
||||
|
||||
static void *
|
||||
base_map(tsdn_t *tsdn, ehooks_t *ehooks, unsigned ind, size_t size) {
|
||||
void *addr;
|
||||
bool zero = true;
|
||||
bool commit = true;
|
||||
bool zero = true;
|
||||
bool commit = true;
|
||||
|
||||
/*
|
||||
* Use huge page sizes and alignment when opt_metadata_thp is enabled
|
||||
|
|
@ -56,16 +52,16 @@ base_map(tsdn_t *tsdn, ehooks_t *ehooks, unsigned ind, size_t size) {
|
|||
if (ehooks_are_default(ehooks)) {
|
||||
addr = extent_alloc_mmap(NULL, size, alignment, &zero, &commit);
|
||||
} else {
|
||||
addr = ehooks_alloc(tsdn, ehooks, NULL, size, alignment, &zero,
|
||||
&commit);
|
||||
addr = ehooks_alloc(
|
||||
tsdn, ehooks, NULL, size, alignment, &zero, &commit);
|
||||
}
|
||||
|
||||
return addr;
|
||||
}
|
||||
|
||||
static void
|
||||
base_unmap(tsdn_t *tsdn, ehooks_t *ehooks, unsigned ind, void *addr,
|
||||
size_t size) {
|
||||
base_unmap(
|
||||
tsdn_t *tsdn, ehooks_t *ehooks, unsigned ind, void *addr, size_t size) {
|
||||
/*
|
||||
* Cascade through dalloc, decommit, purge_forced, and purge_lazy,
|
||||
* stopping at first success. This cascade is performed for consistency
|
||||
|
|
@ -109,8 +105,8 @@ base_unmap(tsdn_t *tsdn, ehooks_t *ehooks, unsigned ind, void *addr,
|
|||
label_done:
|
||||
if (metadata_thp_madvise()) {
|
||||
/* Set NOHUGEPAGE after unmap to avoid kernel defrag. */
|
||||
assert(((uintptr_t)addr & HUGEPAGE_MASK) == 0 &&
|
||||
(size & HUGEPAGE_MASK) == 0);
|
||||
assert(((uintptr_t)addr & HUGEPAGE_MASK) == 0
|
||||
&& (size & HUGEPAGE_MASK) == 0);
|
||||
pages_nohuge(addr, size);
|
||||
}
|
||||
}
|
||||
|
|
@ -126,8 +122,8 @@ base_edata_is_reused(edata_t *edata) {
|
|||
}
|
||||
|
||||
static void
|
||||
base_edata_init(size_t *extent_sn_next, edata_t *edata, void *addr,
|
||||
size_t size) {
|
||||
base_edata_init(
|
||||
size_t *extent_sn_next, edata_t *edata, void *addr, size_t size) {
|
||||
size_t sn;
|
||||
|
||||
sn = *extent_sn_next;
|
||||
|
|
@ -174,9 +170,9 @@ huge_arena_auto_thp_switch(tsdn_t *tsdn, pac_thp_t *pac_thp) {
|
|||
|
||||
unsigned cnt = 0;
|
||||
edata_t *edata;
|
||||
ql_foreach(edata, &pending_list->head, ql_link_active) {
|
||||
ql_foreach (edata, &pending_list->head, ql_link_active) {
|
||||
assert(edata != NULL);
|
||||
void *addr = edata_addr_get(edata);
|
||||
void *addr = edata_addr_get(edata);
|
||||
size_t size = edata_size_get(edata);
|
||||
assert(HUGEPAGE_ADDR2BASE(addr) == addr);
|
||||
assert(HUGEPAGE_CEILING(size) == size && size != 0);
|
||||
|
|
@ -196,11 +192,11 @@ base_auto_thp_switch(tsdn_t *tsdn, base_t *base) {
|
|||
/* Called when adding a new block. */
|
||||
bool should_switch;
|
||||
if (base_ind_get(base) != 0) {
|
||||
should_switch = (base_get_num_blocks(base, true) ==
|
||||
BASE_AUTO_THP_THRESHOLD);
|
||||
should_switch = (base_get_num_blocks(base, true)
|
||||
== BASE_AUTO_THP_THRESHOLD);
|
||||
} else {
|
||||
should_switch = (base_get_num_blocks(base, true) ==
|
||||
BASE_AUTO_THP_THRESHOLD_A0);
|
||||
should_switch = (base_get_num_blocks(base, true)
|
||||
== BASE_AUTO_THP_THRESHOLD_A0);
|
||||
}
|
||||
if (!should_switch) {
|
||||
return;
|
||||
|
|
@ -214,8 +210,9 @@ base_auto_thp_switch(tsdn_t *tsdn, base_t *base) {
|
|||
assert((block->size & HUGEPAGE_MASK) == 0);
|
||||
pages_huge(block, block->size);
|
||||
if (config_stats) {
|
||||
base->n_thp += HUGEPAGE_CEILING(block->size -
|
||||
edata_bsize_get(&block->edata)) >> LG_HUGEPAGE;
|
||||
base->n_thp += HUGEPAGE_CEILING(block->size
|
||||
- edata_bsize_get(&block->edata))
|
||||
>> LG_HUGEPAGE;
|
||||
}
|
||||
block = block->next;
|
||||
assert(block == NULL || (base_ind_get(base) == 0));
|
||||
|
|
@ -242,20 +239,22 @@ base_auto_thp_switch(tsdn_t *tsdn, base_t *base) {
|
|||
}
|
||||
|
||||
static void *
|
||||
base_extent_bump_alloc_helper(edata_t *edata, size_t *gap_size, size_t size,
|
||||
size_t alignment) {
|
||||
base_extent_bump_alloc_helper(
|
||||
edata_t *edata, size_t *gap_size, size_t size, size_t alignment) {
|
||||
void *ret;
|
||||
|
||||
assert(alignment == ALIGNMENT_CEILING(alignment, QUANTUM));
|
||||
assert(size == ALIGNMENT_CEILING(size, alignment));
|
||||
|
||||
*gap_size = ALIGNMENT_CEILING((uintptr_t)edata_addr_get(edata),
|
||||
alignment) - (uintptr_t)edata_addr_get(edata);
|
||||
*gap_size = ALIGNMENT_CEILING(
|
||||
(uintptr_t)edata_addr_get(edata), alignment)
|
||||
- (uintptr_t)edata_addr_get(edata);
|
||||
ret = (void *)((byte_t *)edata_addr_get(edata) + *gap_size);
|
||||
assert(edata_bsize_get(edata) >= *gap_size + size);
|
||||
edata_binit(edata, (void *)((byte_t *)edata_addr_get(edata) +
|
||||
*gap_size + size), edata_bsize_get(edata) - *gap_size - size,
|
||||
edata_sn_get(edata), base_edata_is_reused(edata));
|
||||
edata_binit(edata,
|
||||
(void *)((byte_t *)edata_addr_get(edata) + *gap_size + size),
|
||||
edata_bsize_get(edata) - *gap_size - size, edata_sn_get(edata),
|
||||
base_edata_is_reused(edata));
|
||||
return ret;
|
||||
}
|
||||
|
||||
|
|
@ -312,24 +311,26 @@ base_extent_bump_alloc_post(tsdn_t *tsdn, base_t *base, edata_t *edata,
|
|||
* crossed by the new allocation. Adjust n_thp similarly when
|
||||
* metadata_thp is enabled.
|
||||
*/
|
||||
base->resident += PAGE_CEILING((uintptr_t)addr + size) -
|
||||
PAGE_CEILING((uintptr_t)addr - gap_size);
|
||||
base->resident += PAGE_CEILING((uintptr_t)addr + size)
|
||||
- PAGE_CEILING((uintptr_t)addr - gap_size);
|
||||
assert(base->allocated <= base->resident);
|
||||
assert(base->resident <= base->mapped);
|
||||
if (metadata_thp_madvise() && (opt_metadata_thp ==
|
||||
metadata_thp_always || base->auto_thp_switched)) {
|
||||
if (metadata_thp_madvise()
|
||||
&& (opt_metadata_thp == metadata_thp_always
|
||||
|| base->auto_thp_switched)) {
|
||||
base->n_thp += (HUGEPAGE_CEILING((uintptr_t)addr + size)
|
||||
- HUGEPAGE_CEILING((uintptr_t)addr - gap_size)) >>
|
||||
LG_HUGEPAGE;
|
||||
- HUGEPAGE_CEILING(
|
||||
(uintptr_t)addr - gap_size))
|
||||
>> LG_HUGEPAGE;
|
||||
assert(base->mapped >= base->n_thp << LG_HUGEPAGE);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
static void *
|
||||
base_extent_bump_alloc(tsdn_t *tsdn, base_t *base, edata_t *edata, size_t size,
|
||||
size_t alignment) {
|
||||
void *ret;
|
||||
base_extent_bump_alloc(
|
||||
tsdn_t *tsdn, base_t *base, edata_t *edata, size_t size, size_t alignment) {
|
||||
void *ret;
|
||||
size_t gap_size;
|
||||
|
||||
ret = base_extent_bump_alloc_helper(edata, &gap_size, size, alignment);
|
||||
|
|
@ -339,9 +340,9 @@ base_extent_bump_alloc(tsdn_t *tsdn, base_t *base, edata_t *edata, size_t size,
|
|||
|
||||
static size_t
|
||||
base_block_size_ceil(size_t block_size) {
|
||||
return opt_metadata_thp == metadata_thp_disabled ?
|
||||
ALIGNMENT_CEILING(block_size, BASE_BLOCK_MIN_ALIGN) :
|
||||
HUGEPAGE_CEILING(block_size);
|
||||
return opt_metadata_thp == metadata_thp_disabled
|
||||
? ALIGNMENT_CEILING(block_size, BASE_BLOCK_MIN_ALIGN)
|
||||
: HUGEPAGE_CEILING(block_size);
|
||||
}
|
||||
|
||||
/*
|
||||
|
|
@ -356,8 +357,8 @@ base_block_alloc(tsdn_t *tsdn, base_t *base, ehooks_t *ehooks, unsigned ind,
|
|||
alignment = ALIGNMENT_CEILING(alignment, QUANTUM);
|
||||
size_t usize = ALIGNMENT_CEILING(size, alignment);
|
||||
size_t header_size = sizeof(base_block_t);
|
||||
size_t gap_size = ALIGNMENT_CEILING(header_size, alignment) -
|
||||
header_size;
|
||||
size_t gap_size = ALIGNMENT_CEILING(header_size, alignment)
|
||||
- header_size;
|
||||
/*
|
||||
* Create increasingly larger blocks in order to limit the total number
|
||||
* of disjoint virtual memory ranges. Choose the next size in the page
|
||||
|
|
@ -365,27 +366,29 @@ base_block_alloc(tsdn_t *tsdn, base_t *base, ehooks_t *ehooks, unsigned ind,
|
|||
* HUGEPAGE when using metadata_thp), or a size large enough to satisfy
|
||||
* the requested size and alignment, whichever is larger.
|
||||
*/
|
||||
size_t min_block_size = base_block_size_ceil(sz_psz2u(header_size +
|
||||
gap_size + usize));
|
||||
pszind_t pind_next = (*pind_last + 1 < sz_psz2ind(SC_LARGE_MAXCLASS)) ?
|
||||
*pind_last + 1 : *pind_last;
|
||||
size_t next_block_size = base_block_size_ceil(sz_pind2sz(pind_next));
|
||||
size_t block_size = (min_block_size > next_block_size) ? min_block_size
|
||||
: next_block_size;
|
||||
base_block_t *block = (base_block_t *)base_map(tsdn, ehooks, ind,
|
||||
block_size);
|
||||
size_t min_block_size = base_block_size_ceil(
|
||||
sz_psz2u(header_size + gap_size + usize));
|
||||
pszind_t pind_next = (*pind_last + 1 < sz_psz2ind(SC_LARGE_MAXCLASS))
|
||||
? *pind_last + 1
|
||||
: *pind_last;
|
||||
size_t next_block_size = base_block_size_ceil(sz_pind2sz(pind_next));
|
||||
size_t block_size = (min_block_size > next_block_size)
|
||||
? min_block_size
|
||||
: next_block_size;
|
||||
base_block_t *block = (base_block_t *)base_map(
|
||||
tsdn, ehooks, ind, block_size);
|
||||
if (block == NULL) {
|
||||
return NULL;
|
||||
}
|
||||
|
||||
if (metadata_thp_madvise()) {
|
||||
void *addr = (void *)block;
|
||||
assert(((uintptr_t)addr & HUGEPAGE_MASK) == 0 &&
|
||||
(block_size & HUGEPAGE_MASK) == 0);
|
||||
assert(((uintptr_t)addr & HUGEPAGE_MASK) == 0
|
||||
&& (block_size & HUGEPAGE_MASK) == 0);
|
||||
if (opt_metadata_thp == metadata_thp_always) {
|
||||
pages_huge(addr, block_size);
|
||||
} else if (opt_metadata_thp == metadata_thp_auto &&
|
||||
base != NULL) {
|
||||
} else if (opt_metadata_thp == metadata_thp_auto
|
||||
&& base != NULL) {
|
||||
/* base != NULL indicates this is not a new base. */
|
||||
malloc_mutex_lock(tsdn, &base->mtx);
|
||||
base_auto_thp_switch(tsdn, base);
|
||||
|
|
@ -432,12 +435,12 @@ base_extent_alloc(tsdn_t *tsdn, base_t *base, size_t size, size_t alignment) {
|
|||
base->allocated += sizeof(base_block_t);
|
||||
base->resident += PAGE_CEILING(sizeof(base_block_t));
|
||||
base->mapped += block->size;
|
||||
if (metadata_thp_madvise() &&
|
||||
!(opt_metadata_thp == metadata_thp_auto
|
||||
&& !base->auto_thp_switched)) {
|
||||
if (metadata_thp_madvise()
|
||||
&& !(opt_metadata_thp == metadata_thp_auto
|
||||
&& !base->auto_thp_switched)) {
|
||||
assert(base->n_thp > 0);
|
||||
base->n_thp += HUGEPAGE_CEILING(sizeof(base_block_t)) >>
|
||||
LG_HUGEPAGE;
|
||||
base->n_thp += HUGEPAGE_CEILING(sizeof(base_block_t))
|
||||
>> LG_HUGEPAGE;
|
||||
}
|
||||
assert(base->allocated <= base->resident);
|
||||
assert(base->resident <= base->mapped);
|
||||
|
|
@ -455,7 +458,7 @@ base_t *
|
|||
base_new(tsdn_t *tsdn, unsigned ind, const extent_hooks_t *extent_hooks,
|
||||
bool metadata_use_hooks) {
|
||||
pszind_t pind_last = 0;
|
||||
size_t extent_sn_next = 0;
|
||||
size_t extent_sn_next = 0;
|
||||
|
||||
/*
|
||||
* The base will contain the ehooks eventually, but it itself is
|
||||
|
|
@ -463,9 +466,10 @@ base_new(tsdn_t *tsdn, unsigned ind, const extent_hooks_t *extent_hooks,
|
|||
* memory, and then initialize the ehooks within the base_t.
|
||||
*/
|
||||
ehooks_t fake_ehooks;
|
||||
ehooks_init(&fake_ehooks, metadata_use_hooks ?
|
||||
(extent_hooks_t *)extent_hooks :
|
||||
(extent_hooks_t *)&ehooks_default_extent_hooks, ind);
|
||||
ehooks_init(&fake_ehooks,
|
||||
metadata_use_hooks ? (extent_hooks_t *)extent_hooks
|
||||
: (extent_hooks_t *)&ehooks_default_extent_hooks,
|
||||
ind);
|
||||
|
||||
base_block_t *block = base_block_alloc(tsdn, NULL, &fake_ehooks, ind,
|
||||
&pind_last, &extent_sn_next, sizeof(base_t), QUANTUM);
|
||||
|
|
@ -473,17 +477,18 @@ base_new(tsdn_t *tsdn, unsigned ind, const extent_hooks_t *extent_hooks,
|
|||
return NULL;
|
||||
}
|
||||
|
||||
size_t gap_size;
|
||||
size_t base_alignment = CACHELINE;
|
||||
size_t base_size = ALIGNMENT_CEILING(sizeof(base_t), base_alignment);
|
||||
base_t *base = (base_t *)base_extent_bump_alloc_helper(&block->edata,
|
||||
&gap_size, base_size, base_alignment);
|
||||
size_t gap_size;
|
||||
size_t base_alignment = CACHELINE;
|
||||
size_t base_size = ALIGNMENT_CEILING(sizeof(base_t), base_alignment);
|
||||
base_t *base = (base_t *)base_extent_bump_alloc_helper(
|
||||
&block->edata, &gap_size, base_size, base_alignment);
|
||||
ehooks_init(&base->ehooks, (extent_hooks_t *)extent_hooks, ind);
|
||||
ehooks_init(&base->ehooks_base, metadata_use_hooks ?
|
||||
(extent_hooks_t *)extent_hooks :
|
||||
(extent_hooks_t *)&ehooks_default_extent_hooks, ind);
|
||||
ehooks_init(&base->ehooks_base,
|
||||
metadata_use_hooks ? (extent_hooks_t *)extent_hooks
|
||||
: (extent_hooks_t *)&ehooks_default_extent_hooks,
|
||||
ind);
|
||||
if (malloc_mutex_init(&base->mtx, "base", WITNESS_RANK_BASE,
|
||||
malloc_mutex_rank_exclusive)) {
|
||||
malloc_mutex_rank_exclusive)) {
|
||||
base_unmap(tsdn, &fake_ehooks, ind, block, block->size);
|
||||
return NULL;
|
||||
}
|
||||
|
|
@ -502,9 +507,10 @@ base_new(tsdn_t *tsdn, unsigned ind, const extent_hooks_t *extent_hooks,
|
|||
base->allocated = sizeof(base_block_t);
|
||||
base->resident = PAGE_CEILING(sizeof(base_block_t));
|
||||
base->mapped = block->size;
|
||||
base->n_thp = (opt_metadata_thp == metadata_thp_always) &&
|
||||
metadata_thp_madvise() ? HUGEPAGE_CEILING(sizeof(base_block_t))
|
||||
>> LG_HUGEPAGE : 0;
|
||||
base->n_thp = (opt_metadata_thp == metadata_thp_always)
|
||||
&& metadata_thp_madvise()
|
||||
? HUGEPAGE_CEILING(sizeof(base_block_t)) >> LG_HUGEPAGE
|
||||
: 0;
|
||||
assert(base->allocated <= base->resident);
|
||||
assert(base->resident <= base->mapped);
|
||||
assert(base->n_thp << LG_HUGEPAGE <= base->mapped);
|
||||
|
|
@ -512,8 +518,8 @@ base_new(tsdn_t *tsdn, unsigned ind, const extent_hooks_t *extent_hooks,
|
|||
|
||||
/* Locking here is only necessary because of assertions. */
|
||||
malloc_mutex_lock(tsdn, &base->mtx);
|
||||
base_extent_bump_alloc_post(tsdn, base, &block->edata, gap_size, base,
|
||||
base_size);
|
||||
base_extent_bump_alloc_post(
|
||||
tsdn, base, &block->edata, gap_size, base, base_size);
|
||||
malloc_mutex_unlock(tsdn, &base->mtx);
|
||||
|
||||
return base;
|
||||
|
|
@ -521,13 +527,13 @@ base_new(tsdn_t *tsdn, unsigned ind, const extent_hooks_t *extent_hooks,
|
|||
|
||||
void
|
||||
base_delete(tsdn_t *tsdn, base_t *base) {
|
||||
ehooks_t *ehooks = base_ehooks_get_for_metadata(base);
|
||||
ehooks_t *ehooks = base_ehooks_get_for_metadata(base);
|
||||
base_block_t *next = base->blocks;
|
||||
do {
|
||||
base_block_t *block = next;
|
||||
next = block->next;
|
||||
base_unmap(tsdn, ehooks, base_ind_get(base), block,
|
||||
block->size);
|
||||
base_unmap(
|
||||
tsdn, ehooks, base_ind_get(base), block, block->size);
|
||||
} while (next != NULL);
|
||||
}
|
||||
|
||||
|
|
@ -543,8 +549,8 @@ base_ehooks_get_for_metadata(base_t *base) {
|
|||
|
||||
extent_hooks_t *
|
||||
base_extent_hooks_set(base_t *base, extent_hooks_t *extent_hooks) {
|
||||
extent_hooks_t *old_extent_hooks =
|
||||
ehooks_get_extent_hooks_ptr(&base->ehooks);
|
||||
extent_hooks_t *old_extent_hooks = ehooks_get_extent_hooks_ptr(
|
||||
&base->ehooks);
|
||||
ehooks_init(&base->ehooks, extent_hooks, ehooks_ind_get(&base->ehooks));
|
||||
return old_extent_hooks;
|
||||
}
|
||||
|
|
@ -602,9 +608,9 @@ base_alloc(tsdn_t *tsdn, base_t *base, size_t size, size_t alignment) {
|
|||
|
||||
edata_t *
|
||||
base_alloc_edata(tsdn_t *tsdn, base_t *base) {
|
||||
size_t esn, usize;
|
||||
edata_t *edata = base_alloc_impl(tsdn, base, sizeof(edata_t),
|
||||
EDATA_ALIGNMENT, &esn, &usize);
|
||||
size_t esn, usize;
|
||||
edata_t *edata = base_alloc_impl(
|
||||
tsdn, base, sizeof(edata_t), EDATA_ALIGNMENT, &esn, &usize);
|
||||
if (edata == NULL) {
|
||||
return NULL;
|
||||
}
|
||||
|
|
@ -618,8 +624,8 @@ base_alloc_edata(tsdn_t *tsdn, base_t *base) {
|
|||
void *
|
||||
base_alloc_rtree(tsdn_t *tsdn, base_t *base, size_t size) {
|
||||
size_t usize;
|
||||
void *rtree = base_alloc_impl(tsdn, base, size, CACHELINE, NULL,
|
||||
&usize);
|
||||
void *rtree = base_alloc_impl(
|
||||
tsdn, base, size, CACHELINE, NULL, &usize);
|
||||
if (rtree == NULL) {
|
||||
return NULL;
|
||||
}
|
||||
|
|
@ -632,8 +638,8 @@ base_alloc_rtree(tsdn_t *tsdn, base_t *base, size_t size) {
|
|||
static inline void
|
||||
b0_alloc_header_size(size_t *header_size, size_t *alignment) {
|
||||
*alignment = QUANTUM;
|
||||
*header_size = QUANTUM > sizeof(edata_t *) ? QUANTUM :
|
||||
sizeof(edata_t *);
|
||||
*header_size = QUANTUM > sizeof(edata_t *) ? QUANTUM
|
||||
: sizeof(edata_t *);
|
||||
}
|
||||
|
||||
/*
|
||||
|
|
@ -645,7 +651,7 @@ b0_alloc_header_size(size_t *header_size, size_t *alignment) {
|
|||
*/
|
||||
void *
|
||||
b0_alloc_tcache_stack(tsdn_t *tsdn, size_t stack_size) {
|
||||
base_t *base = b0get();
|
||||
base_t *base = b0get();
|
||||
edata_t *edata = base_alloc_base_edata(tsdn, base);
|
||||
if (edata == NULL) {
|
||||
return NULL;
|
||||
|
|
@ -662,8 +668,8 @@ b0_alloc_tcache_stack(tsdn_t *tsdn, size_t stack_size) {
|
|||
b0_alloc_header_size(&header_size, &alignment);
|
||||
|
||||
size_t alloc_size = sz_s2u(stack_size + header_size);
|
||||
void *addr = base_alloc_impl(tsdn, base, alloc_size, alignment, &esn,
|
||||
NULL);
|
||||
void *addr = base_alloc_impl(
|
||||
tsdn, base, alloc_size, alignment, &esn, NULL);
|
||||
if (addr == NULL) {
|
||||
edata_avail_insert(&base->edata_avail, edata);
|
||||
return NULL;
|
||||
|
|
@ -683,8 +689,8 @@ b0_dalloc_tcache_stack(tsdn_t *tsdn, void *tcache_stack) {
|
|||
b0_alloc_header_size(&header_size, &alignment);
|
||||
|
||||
edata_t *edata = *(edata_t **)((byte_t *)tcache_stack - header_size);
|
||||
void *addr = edata_addr_get(edata);
|
||||
size_t bsize = edata_bsize_get(edata);
|
||||
void *addr = edata_addr_get(edata);
|
||||
size_t bsize = edata_bsize_get(edata);
|
||||
/* Marked as "reused" to avoid double counting stats. */
|
||||
assert(base_edata_is_reused(edata));
|
||||
assert(addr != NULL && bsize > 0);
|
||||
|
|
@ -707,7 +713,8 @@ base_stats_get(tsdn_t *tsdn, base_t *base, size_t *allocated,
|
|||
malloc_mutex_lock(tsdn, &base->mtx);
|
||||
assert(base->allocated <= base->resident);
|
||||
assert(base->resident <= base->mapped);
|
||||
assert(base->edata_allocated + base->rtree_allocated <= base->allocated);
|
||||
assert(
|
||||
base->edata_allocated + base->rtree_allocated <= base->allocated);
|
||||
*allocated = base->allocated;
|
||||
*edata_allocated = base->edata_allocated;
|
||||
*rtree_allocated = base->rtree_allocated;
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue