d27f29b468
Refactor arena and extent locking protocols such that arena and
extent locks are never held when calling into the extent_*_wrapper()
API. This requires extra care during purging since the arena lock no
longer protects the inner purging logic. It also requires extra care to
protect extents from being merged with adjacent extents.
Convert extent_t's 'active' flag to an enumerated 'state', so that
retained extents are explicitly marked as such, rather than depending on
ring linkage state.
Refactor the extent collections (and their synchronization) for cached
and retained extents into extents_t. Incorporate LRU functionality to
support purging. Incorporate page count accounting, which replaces
arena->ndirty and arena->stats.retained.
Assert that no core locks are held when entering any internal
[de]allocation functions. This is in addition to existing assertions
that no locks are held when entering external [de]allocation functions.
Audit and document synchronization protocols for all arena_t fields.
This fixes a potential deadlock due to recursive allocation during
gdump, in a similar fashion to b49c649bc1
(Fix lock order reversal during gdump.), but with a necessarily much
broader code impact.
33 lines
901 B
C
33 lines
901 B
C
#include "test/jemalloc_test.h"
|
|
|
|
TEST_BEGIN(test_arena_slab_regind) {
|
|
szind_t binind;
|
|
|
|
for (binind = 0; binind < NBINS; binind++) {
|
|
size_t regind;
|
|
extent_t slab;
|
|
const arena_bin_info_t *bin_info = &arena_bin_info[binind];
|
|
extent_init(&slab, NULL, mallocx(bin_info->slab_size,
|
|
MALLOCX_LG_ALIGN(LG_PAGE)), bin_info->slab_size, 0, 0,
|
|
extent_state_active, false, true, true);
|
|
assert_ptr_not_null(extent_addr_get(&slab),
|
|
"Unexpected malloc() failure");
|
|
for (regind = 0; regind < bin_info->nregs; regind++) {
|
|
void *reg = (void *)((uintptr_t)extent_addr_get(&slab) +
|
|
(bin_info->reg_size * regind));
|
|
assert_zu_eq(arena_slab_regind(&slab, binind, reg),
|
|
regind,
|
|
"Incorrect region index computed for size %zu",
|
|
bin_info->reg_size);
|
|
}
|
|
free(extent_addr_get(&slab));
|
|
}
|
|
}
|
|
TEST_END
|
|
|
|
int
|
|
main(void) {
|
|
return test(
|
|
test_arena_slab_regind);
|
|
}
|