Header refactoring: unify and de-catchall witness code.
This commit is contained in:
committed by
David Goldblatt
parent
36195c8f4d
commit
9f822a1fd7
18
src/arena.c
18
src/arena.c
@@ -361,7 +361,8 @@ arena_stats_merge(tsdn_t *tsdn, arena_t *arena, unsigned *nthreads,
|
||||
void
|
||||
arena_extents_dirty_dalloc(tsdn_t *tsdn, arena_t *arena,
|
||||
extent_hooks_t **r_extent_hooks, extent_t *extent) {
|
||||
witness_assert_depth_to_rank(tsdn, WITNESS_RANK_CORE, 0);
|
||||
witness_assert_depth_to_rank(tsdn_witness_tsdp_get(tsdn),
|
||||
WITNESS_RANK_CORE, 0);
|
||||
|
||||
extents_dalloc(tsdn, arena, r_extent_hooks, &arena->extents_dirty,
|
||||
extent);
|
||||
@@ -497,7 +498,8 @@ arena_extent_alloc_large(tsdn_t *tsdn, arena_t *arena, size_t usize,
|
||||
size_t alignment, bool *zero) {
|
||||
extent_hooks_t *extent_hooks = EXTENT_HOOKS_INITIALIZER;
|
||||
|
||||
witness_assert_depth_to_rank(tsdn, WITNESS_RANK_CORE, 0);
|
||||
witness_assert_depth_to_rank(tsdn_witness_tsdp_get(tsdn),
|
||||
WITNESS_RANK_CORE, 0);
|
||||
|
||||
szind_t szind = size2index(usize);
|
||||
size_t mapped_add;
|
||||
@@ -892,7 +894,8 @@ static size_t
|
||||
arena_stash_decayed(tsdn_t *tsdn, arena_t *arena,
|
||||
extent_hooks_t **r_extent_hooks, extents_t *extents, size_t npages_limit,
|
||||
extent_list_t *decay_extents) {
|
||||
witness_assert_depth_to_rank(tsdn, WITNESS_RANK_CORE, 0);
|
||||
witness_assert_depth_to_rank(tsdn_witness_tsdp_get(tsdn),
|
||||
WITNESS_RANK_CORE, 0);
|
||||
|
||||
/* Stash extents according to npages_limit. */
|
||||
size_t nstashed = 0;
|
||||
@@ -978,7 +981,8 @@ arena_decay_stashed(tsdn_t *tsdn, arena_t *arena,
|
||||
static void
|
||||
arena_decay_to_limit(tsdn_t *tsdn, arena_t *arena, arena_decay_t *decay,
|
||||
extents_t *extents, bool all, size_t npages_limit) {
|
||||
witness_assert_depth_to_rank(tsdn, WITNESS_RANK_CORE, 1);
|
||||
witness_assert_depth_to_rank(tsdn_witness_tsdp_get(tsdn),
|
||||
WITNESS_RANK_CORE, 1);
|
||||
malloc_mutex_assert_owner(tsdn, &decay->mtx);
|
||||
|
||||
if (decay->purging) {
|
||||
@@ -1253,7 +1257,8 @@ arena_slab_alloc_hard(tsdn_t *tsdn, arena_t *arena,
|
||||
extent_t *slab;
|
||||
bool zero, commit;
|
||||
|
||||
witness_assert_depth_to_rank(tsdn, WITNESS_RANK_CORE, 0);
|
||||
witness_assert_depth_to_rank(tsdn_witness_tsdp_get(tsdn),
|
||||
WITNESS_RANK_CORE, 0);
|
||||
|
||||
zero = false;
|
||||
commit = true;
|
||||
@@ -1271,7 +1276,8 @@ arena_slab_alloc_hard(tsdn_t *tsdn, arena_t *arena,
|
||||
static extent_t *
|
||||
arena_slab_alloc(tsdn_t *tsdn, arena_t *arena, szind_t binind,
|
||||
const arena_bin_info_t *bin_info) {
|
||||
witness_assert_depth_to_rank(tsdn, WITNESS_RANK_CORE, 0);
|
||||
witness_assert_depth_to_rank(tsdn_witness_tsdp_get(tsdn),
|
||||
WITNESS_RANK_CORE, 0);
|
||||
|
||||
extent_hooks_t *extent_hooks = EXTENT_HOOKS_INITIALIZER;
|
||||
szind_t szind = size2index(bin_info->reg_size);
|
||||
|
54
src/extent.c
54
src/extent.c
@@ -149,7 +149,8 @@ extent_lock_from_addr(tsdn_t *tsdn, rtree_ctx_t *rtree_ctx, void *addr) {
|
||||
|
||||
extent_t *
|
||||
extent_alloc(tsdn_t *tsdn, arena_t *arena) {
|
||||
witness_assert_depth_to_rank(tsdn, WITNESS_RANK_CORE, 0);
|
||||
witness_assert_depth_to_rank(tsdn_witness_tsdp_get(tsdn),
|
||||
WITNESS_RANK_CORE, 0);
|
||||
|
||||
malloc_mutex_lock(tsdn, &arena->extent_avail_mtx);
|
||||
extent_t *extent = extent_avail_first(&arena->extent_avail);
|
||||
@@ -164,7 +165,8 @@ extent_alloc(tsdn_t *tsdn, arena_t *arena) {
|
||||
|
||||
void
|
||||
extent_dalloc(tsdn_t *tsdn, arena_t *arena, extent_t *extent) {
|
||||
witness_assert_depth_to_rank(tsdn, WITNESS_RANK_CORE, 0);
|
||||
witness_assert_depth_to_rank(tsdn_witness_tsdp_get(tsdn),
|
||||
WITNESS_RANK_CORE, 0);
|
||||
|
||||
malloc_mutex_lock(tsdn, &arena->extent_avail_mtx);
|
||||
extent_avail_insert(&arena->extent_avail, extent);
|
||||
@@ -415,7 +417,8 @@ extents_alloc(tsdn_t *tsdn, arena_t *arena, extent_hooks_t **r_extent_hooks,
|
||||
size_t alignment, bool slab, szind_t szind, bool *zero, bool *commit) {
|
||||
assert(size + pad != 0);
|
||||
assert(alignment != 0);
|
||||
witness_assert_depth_to_rank(tsdn, WITNESS_RANK_CORE, 0);
|
||||
witness_assert_depth_to_rank(tsdn_witness_tsdp_get(tsdn),
|
||||
WITNESS_RANK_CORE, 0);
|
||||
|
||||
return extent_recycle(tsdn, arena, r_extent_hooks, extents, new_addr,
|
||||
size, pad, alignment, slab, szind, zero, commit);
|
||||
@@ -426,7 +429,8 @@ extents_dalloc(tsdn_t *tsdn, arena_t *arena, extent_hooks_t **r_extent_hooks,
|
||||
extents_t *extents, extent_t *extent) {
|
||||
assert(extent_base_get(extent) != NULL);
|
||||
assert(extent_size_get(extent) != 0);
|
||||
witness_assert_depth_to_rank(tsdn, WITNESS_RANK_CORE, 0);
|
||||
witness_assert_depth_to_rank(tsdn_witness_tsdp_get(tsdn),
|
||||
WITNESS_RANK_CORE, 0);
|
||||
|
||||
extent_addr_set(extent, extent_base_get(extent));
|
||||
extent_zeroed_set(extent, false);
|
||||
@@ -607,7 +611,8 @@ static void
|
||||
extent_gdump_add(tsdn_t *tsdn, const extent_t *extent) {
|
||||
cassert(config_prof);
|
||||
/* prof_gdump() requirement. */
|
||||
witness_assert_depth_to_rank(tsdn, WITNESS_RANK_CORE, 0);
|
||||
witness_assert_depth_to_rank(tsdn_witness_tsdp_get(tsdn),
|
||||
WITNESS_RANK_CORE, 0);
|
||||
|
||||
if (opt_prof && extent_state_get(extent) == extent_state_active) {
|
||||
size_t nadd = extent_size_get(extent) >> LG_PAGE;
|
||||
@@ -730,7 +735,8 @@ extent_recycle_extract(tsdn_t *tsdn, arena_t *arena,
|
||||
extent_hooks_t **r_extent_hooks, rtree_ctx_t *rtree_ctx, extents_t *extents,
|
||||
bool locked, void *new_addr, size_t size, size_t pad, size_t alignment,
|
||||
bool slab, bool *zero, bool *commit) {
|
||||
witness_assert_depth_to_rank(tsdn, WITNESS_RANK_CORE, locked ? 1 : 0);
|
||||
witness_assert_depth_to_rank(tsdn_witness_tsdp_get(tsdn),
|
||||
WITNESS_RANK_CORE, locked ? 1 : 0);
|
||||
if (locked) {
|
||||
malloc_mutex_assert_owner(tsdn, &extents->mtx);
|
||||
}
|
||||
@@ -869,7 +875,8 @@ static extent_t *
|
||||
extent_recycle(tsdn_t *tsdn, arena_t *arena, extent_hooks_t **r_extent_hooks,
|
||||
extents_t *extents, void *new_addr, size_t size, size_t pad,
|
||||
size_t alignment, bool slab, szind_t szind, bool *zero, bool *commit) {
|
||||
witness_assert_depth_to_rank(tsdn, WITNESS_RANK_CORE, 0);
|
||||
witness_assert_depth_to_rank(tsdn_witness_tsdp_get(tsdn),
|
||||
WITNESS_RANK_CORE, 0);
|
||||
assert(new_addr == NULL || !slab);
|
||||
assert(pad == 0 || !slab);
|
||||
assert(!*zero || !slab);
|
||||
@@ -1219,7 +1226,8 @@ extent_t *
|
||||
extent_alloc_wrapper(tsdn_t *tsdn, arena_t *arena,
|
||||
extent_hooks_t **r_extent_hooks, void *new_addr, size_t size, size_t pad,
|
||||
size_t alignment, bool slab, szind_t szind, bool *zero, bool *commit) {
|
||||
witness_assert_depth_to_rank(tsdn, WITNESS_RANK_CORE, 0);
|
||||
witness_assert_depth_to_rank(tsdn_witness_tsdp_get(tsdn),
|
||||
WITNESS_RANK_CORE, 0);
|
||||
|
||||
extent_hooks_assure_initialized(arena, r_extent_hooks);
|
||||
|
||||
@@ -1385,7 +1393,8 @@ void
|
||||
extent_dalloc_gap(tsdn_t *tsdn, arena_t *arena, extent_t *extent) {
|
||||
extent_hooks_t *extent_hooks = EXTENT_HOOKS_INITIALIZER;
|
||||
|
||||
witness_assert_depth_to_rank(tsdn, WITNESS_RANK_CORE, 0);
|
||||
witness_assert_depth_to_rank(tsdn_witness_tsdp_get(tsdn),
|
||||
WITNESS_RANK_CORE, 0);
|
||||
|
||||
if (extent_register(tsdn, extent)) {
|
||||
extents_leak(tsdn, arena, &extent_hooks,
|
||||
@@ -1418,7 +1427,8 @@ extent_dalloc_wrapper_try(tsdn_t *tsdn, arena_t *arena,
|
||||
|
||||
assert(extent_base_get(extent) != NULL);
|
||||
assert(extent_size_get(extent) != 0);
|
||||
witness_assert_depth_to_rank(tsdn, WITNESS_RANK_CORE, 0);
|
||||
witness_assert_depth_to_rank(tsdn_witness_tsdp_get(tsdn),
|
||||
WITNESS_RANK_CORE, 0);
|
||||
|
||||
extent_addr_set(extent, extent_base_get(extent));
|
||||
|
||||
@@ -1445,7 +1455,8 @@ extent_dalloc_wrapper_try(tsdn_t *tsdn, arena_t *arena,
|
||||
void
|
||||
extent_dalloc_wrapper(tsdn_t *tsdn, arena_t *arena,
|
||||
extent_hooks_t **r_extent_hooks, extent_t *extent) {
|
||||
witness_assert_depth_to_rank(tsdn, WITNESS_RANK_CORE, 0);
|
||||
witness_assert_depth_to_rank(tsdn_witness_tsdp_get(tsdn),
|
||||
WITNESS_RANK_CORE, 0);
|
||||
|
||||
/*
|
||||
* Deregister first to avoid a race with other allocating threads, and
|
||||
@@ -1508,7 +1519,8 @@ extent_destroy_wrapper(tsdn_t *tsdn, arena_t *arena,
|
||||
extent_hooks_t **r_extent_hooks, extent_t *extent) {
|
||||
assert(extent_base_get(extent) != NULL);
|
||||
assert(extent_size_get(extent) != 0);
|
||||
witness_assert_depth_to_rank(tsdn, WITNESS_RANK_CORE, 0);
|
||||
witness_assert_depth_to_rank(tsdn_witness_tsdp_get(tsdn),
|
||||
WITNESS_RANK_CORE, 0);
|
||||
|
||||
/* Deregister first to avoid a race with other allocating threads. */
|
||||
extent_deregister(tsdn, extent);
|
||||
@@ -1543,7 +1555,8 @@ bool
|
||||
extent_commit_wrapper(tsdn_t *tsdn, arena_t *arena,
|
||||
extent_hooks_t **r_extent_hooks, extent_t *extent, size_t offset,
|
||||
size_t length) {
|
||||
witness_assert_depth_to_rank(tsdn, WITNESS_RANK_CORE, 0);
|
||||
witness_assert_depth_to_rank(tsdn_witness_tsdp_get(tsdn),
|
||||
WITNESS_RANK_CORE, 0);
|
||||
|
||||
extent_hooks_assure_initialized(arena, r_extent_hooks);
|
||||
bool err = ((*r_extent_hooks)->commit == NULL ||
|
||||
@@ -1566,7 +1579,8 @@ bool
|
||||
extent_decommit_wrapper(tsdn_t *tsdn, arena_t *arena,
|
||||
extent_hooks_t **r_extent_hooks, extent_t *extent, size_t offset,
|
||||
size_t length) {
|
||||
witness_assert_depth_to_rank(tsdn, WITNESS_RANK_CORE, 0);
|
||||
witness_assert_depth_to_rank(tsdn_witness_tsdp_get(tsdn),
|
||||
WITNESS_RANK_CORE, 0);
|
||||
|
||||
extent_hooks_assure_initialized(arena, r_extent_hooks);
|
||||
|
||||
@@ -1597,7 +1611,8 @@ bool
|
||||
extent_purge_lazy_wrapper(tsdn_t *tsdn, arena_t *arena,
|
||||
extent_hooks_t **r_extent_hooks, extent_t *extent, size_t offset,
|
||||
size_t length) {
|
||||
witness_assert_depth_to_rank(tsdn, WITNESS_RANK_CORE, 0);
|
||||
witness_assert_depth_to_rank(tsdn_witness_tsdp_get(tsdn),
|
||||
WITNESS_RANK_CORE, 0);
|
||||
|
||||
extent_hooks_assure_initialized(arena, r_extent_hooks);
|
||||
return ((*r_extent_hooks)->purge_lazy == NULL ||
|
||||
@@ -1625,7 +1640,8 @@ bool
|
||||
extent_purge_forced_wrapper(tsdn_t *tsdn, arena_t *arena,
|
||||
extent_hooks_t **r_extent_hooks, extent_t *extent, size_t offset,
|
||||
size_t length) {
|
||||
witness_assert_depth_to_rank(tsdn, WITNESS_RANK_CORE, 0);
|
||||
witness_assert_depth_to_rank(tsdn_witness_tsdp_get(tsdn),
|
||||
WITNESS_RANK_CORE, 0);
|
||||
|
||||
extent_hooks_assure_initialized(arena, r_extent_hooks);
|
||||
return ((*r_extent_hooks)->purge_forced == NULL ||
|
||||
@@ -1649,7 +1665,8 @@ extent_split_wrapper(tsdn_t *tsdn, arena_t *arena,
|
||||
extent_hooks_t **r_extent_hooks, extent_t *extent, size_t size_a,
|
||||
szind_t szind_a, bool slab_a, size_t size_b, szind_t szind_b, bool slab_b) {
|
||||
assert(extent_size_get(extent) == size_a + size_b);
|
||||
witness_assert_depth_to_rank(tsdn, WITNESS_RANK_CORE, 0);
|
||||
witness_assert_depth_to_rank(tsdn_witness_tsdp_get(tsdn),
|
||||
WITNESS_RANK_CORE, 0);
|
||||
|
||||
extent_hooks_assure_initialized(arena, r_extent_hooks);
|
||||
|
||||
@@ -1742,7 +1759,8 @@ extent_merge_default(extent_hooks_t *extent_hooks, void *addr_a, size_t size_a,
|
||||
bool
|
||||
extent_merge_wrapper(tsdn_t *tsdn, arena_t *arena,
|
||||
extent_hooks_t **r_extent_hooks, extent_t *a, extent_t *b) {
|
||||
witness_assert_depth_to_rank(tsdn, WITNESS_RANK_CORE, 0);
|
||||
witness_assert_depth_to_rank(tsdn_witness_tsdp_get(tsdn),
|
||||
WITNESS_RANK_CORE, 0);
|
||||
|
||||
extent_hooks_assure_initialized(arena, r_extent_hooks);
|
||||
|
||||
|
@@ -1755,7 +1755,7 @@ imalloc_body(static_opts_t *sopts, dynamic_opts_t *dopts, tsd_t *tsd) {
|
||||
*/
|
||||
reentrancy_level = tsd_reentrancy_level_get(tsd);
|
||||
if (reentrancy_level == 0) {
|
||||
witness_assert_lockless(tsd_tsdn(tsd));
|
||||
witness_assert_lockless(tsdn_witness_tsdp_get(tsd_tsdn(tsd)));
|
||||
}
|
||||
if (sopts->slow && unlikely(reentrancy_level > 0)) {
|
||||
/*
|
||||
@@ -1832,7 +1832,7 @@ imalloc_body(static_opts_t *sopts, dynamic_opts_t *dopts, tsd_t *tsd) {
|
||||
|
||||
/* Success! */
|
||||
if (reentrancy_level == 0) {
|
||||
witness_assert_lockless(tsd_tsdn(tsd));
|
||||
witness_assert_lockless(tsdn_witness_tsdp_get(tsd_tsdn(tsd)));
|
||||
}
|
||||
*dopts->result = allocation;
|
||||
return 0;
|
||||
@@ -1847,7 +1847,7 @@ label_oom:
|
||||
UTRACE(NULL, size, NULL);
|
||||
}
|
||||
|
||||
witness_assert_lockless(tsd_tsdn(tsd));
|
||||
witness_assert_lockless(tsdn_witness_tsdp_get(tsd_tsdn(tsd)));
|
||||
|
||||
if (sopts->set_errno_on_error) {
|
||||
set_errno(ENOMEM);
|
||||
@@ -1878,7 +1878,7 @@ label_invalid_alignment:
|
||||
UTRACE(NULL, size, NULL);
|
||||
}
|
||||
|
||||
witness_assert_lockless(tsd_tsdn(tsd));
|
||||
witness_assert_lockless(tsdn_witness_tsdp_get(tsd_tsdn(tsd)));
|
||||
|
||||
if (sopts->null_out_result_on_error) {
|
||||
*dopts->result = NULL;
|
||||
@@ -2080,7 +2080,7 @@ ifree(tsd_t *tsd, void *ptr, tcache_t *tcache, bool slow_path) {
|
||||
tsd_assert_fast(tsd);
|
||||
}
|
||||
if (tsd_reentrancy_level_get(tsd) == 0) {
|
||||
witness_assert_lockless(tsd_tsdn(tsd));
|
||||
witness_assert_lockless(tsdn_witness_tsdp_get(tsd_tsdn(tsd)));
|
||||
} else {
|
||||
assert(slow_path);
|
||||
}
|
||||
@@ -2120,7 +2120,7 @@ isfree(tsd_t *tsd, void *ptr, size_t usize, tcache_t *tcache, bool slow_path) {
|
||||
tsd_assert_fast(tsd);
|
||||
}
|
||||
if (tsd_reentrancy_level_get(tsd) == 0) {
|
||||
witness_assert_lockless(tsd_tsdn(tsd));
|
||||
witness_assert_lockless(tsdn_witness_tsdp_get(tsd_tsdn(tsd)));
|
||||
} else {
|
||||
assert(slow_path);
|
||||
}
|
||||
@@ -2181,7 +2181,7 @@ je_realloc(void *ptr, size_t size) {
|
||||
assert(malloc_initialized() || IS_INITIALIZER);
|
||||
tsd_t *tsd = tsd_fetch();
|
||||
|
||||
witness_assert_lockless(tsd_tsdn(tsd));
|
||||
witness_assert_lockless(tsdn_witness_tsdp_get(tsd_tsdn(tsd)));
|
||||
|
||||
alloc_ctx_t alloc_ctx;
|
||||
rtree_ctx_t *rtree_ctx = tsd_rtree_ctx(tsd);
|
||||
@@ -2224,7 +2224,7 @@ je_realloc(void *ptr, size_t size) {
|
||||
*tsd_thread_deallocatedp_get(tsd) += old_usize;
|
||||
}
|
||||
UTRACE(ptr, size, ret);
|
||||
witness_assert_lockless(tsdn);
|
||||
witness_assert_lockless(tsdn_witness_tsdp_get(tsdn));
|
||||
return ret;
|
||||
}
|
||||
|
||||
@@ -2234,7 +2234,8 @@ je_free(void *ptr) {
|
||||
if (likely(ptr != NULL)) {
|
||||
tsd_t *tsd = tsd_fetch();
|
||||
if (tsd_reentrancy_level_get(tsd) == 0) {
|
||||
witness_assert_lockless(tsd_tsdn(tsd));
|
||||
witness_assert_lockless(tsdn_witness_tsdp_get(tsd_tsdn(
|
||||
tsd)));
|
||||
}
|
||||
|
||||
tcache_t *tcache;
|
||||
@@ -2252,7 +2253,8 @@ je_free(void *ptr) {
|
||||
ifree(tsd, ptr, tcache, true);
|
||||
}
|
||||
if (tsd_reentrancy_level_get(tsd) == 0) {
|
||||
witness_assert_lockless(tsd_tsdn(tsd));
|
||||
witness_assert_lockless(tsdn_witness_tsdp_get(tsd_tsdn(
|
||||
tsd)));
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -2513,7 +2515,7 @@ je_rallocx(void *ptr, size_t size, int flags) {
|
||||
assert(size != 0);
|
||||
assert(malloc_initialized() || IS_INITIALIZER);
|
||||
tsd = tsd_fetch();
|
||||
witness_assert_lockless(tsd_tsdn(tsd));
|
||||
witness_assert_lockless(tsdn_witness_tsdp_get(tsd_tsdn(tsd)));
|
||||
|
||||
if (unlikely((flags & MALLOCX_ARENA_MASK) != 0)) {
|
||||
unsigned arena_ind = MALLOCX_ARENA_GET(flags);
|
||||
@@ -2569,7 +2571,7 @@ je_rallocx(void *ptr, size_t size, int flags) {
|
||||
*tsd_thread_deallocatedp_get(tsd) += old_usize;
|
||||
}
|
||||
UTRACE(ptr, size, p);
|
||||
witness_assert_lockless(tsd_tsdn(tsd));
|
||||
witness_assert_lockless(tsdn_witness_tsdp_get(tsd_tsdn(tsd)));
|
||||
return p;
|
||||
label_oom:
|
||||
if (config_xmalloc && unlikely(opt_xmalloc)) {
|
||||
@@ -2577,7 +2579,7 @@ label_oom:
|
||||
abort();
|
||||
}
|
||||
UTRACE(ptr, size, 0);
|
||||
witness_assert_lockless(tsd_tsdn(tsd));
|
||||
witness_assert_lockless(tsdn_witness_tsdp_get(tsd_tsdn(tsd)));
|
||||
return NULL;
|
||||
}
|
||||
|
||||
@@ -2669,7 +2671,7 @@ je_xallocx(void *ptr, size_t size, size_t extra, int flags) {
|
||||
assert(SIZE_T_MAX - size >= extra);
|
||||
assert(malloc_initialized() || IS_INITIALIZER);
|
||||
tsd = tsd_fetch();
|
||||
witness_assert_lockless(tsd_tsdn(tsd));
|
||||
witness_assert_lockless(tsdn_witness_tsdp_get(tsd_tsdn(tsd)));
|
||||
|
||||
alloc_ctx_t alloc_ctx;
|
||||
rtree_ctx_t *rtree_ctx = tsd_rtree_ctx(tsd);
|
||||
@@ -2712,7 +2714,7 @@ je_xallocx(void *ptr, size_t size, size_t extra, int flags) {
|
||||
}
|
||||
label_not_resized:
|
||||
UTRACE(ptr, size, ptr);
|
||||
witness_assert_lockless(tsd_tsdn(tsd));
|
||||
witness_assert_lockless(tsdn_witness_tsdp_get(tsd_tsdn(tsd)));
|
||||
return usize;
|
||||
}
|
||||
|
||||
@@ -2726,7 +2728,7 @@ je_sallocx(const void *ptr, int flags) {
|
||||
assert(ptr != NULL);
|
||||
|
||||
tsdn = tsdn_fetch();
|
||||
witness_assert_lockless(tsdn);
|
||||
witness_assert_lockless(tsdn_witness_tsdp_get(tsdn));
|
||||
|
||||
if (config_debug || force_ivsalloc) {
|
||||
usize = ivsalloc(tsdn, ptr);
|
||||
@@ -2735,7 +2737,7 @@ je_sallocx(const void *ptr, int flags) {
|
||||
usize = isalloc(tsdn, ptr);
|
||||
}
|
||||
|
||||
witness_assert_lockless(tsdn);
|
||||
witness_assert_lockless(tsdn_witness_tsdp_get(tsdn));
|
||||
return usize;
|
||||
}
|
||||
|
||||
@@ -2746,7 +2748,7 @@ je_dallocx(void *ptr, int flags) {
|
||||
|
||||
tsd_t *tsd = tsd_fetch();
|
||||
bool fast = tsd_fast(tsd);
|
||||
witness_assert_lockless(tsd_tsdn(tsd));
|
||||
witness_assert_lockless(tsdn_witness_tsdp_get(tsd_tsdn(tsd)));
|
||||
|
||||
tcache_t *tcache;
|
||||
if (unlikely((flags & MALLOCX_TCACHE_MASK) != 0)) {
|
||||
@@ -2777,12 +2779,12 @@ je_dallocx(void *ptr, int flags) {
|
||||
} else {
|
||||
ifree(tsd, ptr, tcache, true);
|
||||
}
|
||||
witness_assert_lockless(tsd_tsdn(tsd));
|
||||
witness_assert_lockless(tsdn_witness_tsdp_get(tsd_tsdn(tsd)));
|
||||
}
|
||||
|
||||
JEMALLOC_ALWAYS_INLINE size_t
|
||||
inallocx(tsdn_t *tsdn, size_t size, int flags) {
|
||||
witness_assert_lockless(tsdn);
|
||||
witness_assert_lockless(tsdn_witness_tsdp_get(tsdn));
|
||||
|
||||
size_t usize;
|
||||
if (likely((flags & MALLOCX_LG_ALIGN_MASK) == 0)) {
|
||||
@@ -2790,7 +2792,7 @@ inallocx(tsdn_t *tsdn, size_t size, int flags) {
|
||||
} else {
|
||||
usize = sa2u(size, MALLOCX_ALIGN_GET_SPECIFIED(flags));
|
||||
}
|
||||
witness_assert_lockless(tsdn);
|
||||
witness_assert_lockless(tsdn_witness_tsdp_get(tsdn));
|
||||
return usize;
|
||||
}
|
||||
|
||||
@@ -2803,7 +2805,7 @@ je_sdallocx(void *ptr, size_t size, int flags) {
|
||||
bool fast = tsd_fast(tsd);
|
||||
size_t usize = inallocx(tsd_tsdn(tsd), size, flags);
|
||||
assert(usize == isalloc(tsd_tsdn(tsd), ptr));
|
||||
witness_assert_lockless(tsd_tsdn(tsd));
|
||||
witness_assert_lockless(tsdn_witness_tsdp_get(tsd_tsdn(tsd)));
|
||||
|
||||
tcache_t *tcache;
|
||||
if (unlikely((flags & MALLOCX_TCACHE_MASK) != 0)) {
|
||||
@@ -2834,7 +2836,7 @@ je_sdallocx(void *ptr, size_t size, int flags) {
|
||||
} else {
|
||||
isfree(tsd, ptr, usize, tcache, true);
|
||||
}
|
||||
witness_assert_lockless(tsd_tsdn(tsd));
|
||||
witness_assert_lockless(tsdn_witness_tsdp_get(tsd_tsdn(tsd)));
|
||||
}
|
||||
|
||||
JEMALLOC_EXPORT size_t JEMALLOC_NOTHROW
|
||||
@@ -2850,14 +2852,14 @@ je_nallocx(size_t size, int flags) {
|
||||
}
|
||||
|
||||
tsdn = tsdn_fetch();
|
||||
witness_assert_lockless(tsdn);
|
||||
witness_assert_lockless(tsdn_witness_tsdp_get(tsdn));
|
||||
|
||||
usize = inallocx(tsdn, size, flags);
|
||||
if (unlikely(usize > LARGE_MAXCLASS)) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
witness_assert_lockless(tsdn);
|
||||
witness_assert_lockless(tsdn_witness_tsdp_get(tsdn));
|
||||
return usize;
|
||||
}
|
||||
|
||||
@@ -2872,9 +2874,9 @@ je_mallctl(const char *name, void *oldp, size_t *oldlenp, void *newp,
|
||||
}
|
||||
|
||||
tsd = tsd_fetch();
|
||||
witness_assert_lockless(tsd_tsdn(tsd));
|
||||
witness_assert_lockless(tsdn_witness_tsdp_get(tsd_tsdn(tsd)));
|
||||
ret = ctl_byname(tsd, name, oldp, oldlenp, newp, newlen);
|
||||
witness_assert_lockless(tsd_tsdn(tsd));
|
||||
witness_assert_lockless(tsdn_witness_tsdp_get(tsd_tsdn(tsd)));
|
||||
return ret;
|
||||
}
|
||||
|
||||
@@ -2888,9 +2890,9 @@ je_mallctlnametomib(const char *name, size_t *mibp, size_t *miblenp) {
|
||||
}
|
||||
|
||||
tsdn = tsdn_fetch();
|
||||
witness_assert_lockless(tsdn);
|
||||
witness_assert_lockless(tsdn_witness_tsdp_get(tsdn));
|
||||
ret = ctl_nametomib(tsdn, name, mibp, miblenp);
|
||||
witness_assert_lockless(tsdn);
|
||||
witness_assert_lockless(tsdn_witness_tsdp_get(tsdn));
|
||||
return ret;
|
||||
}
|
||||
|
||||
@@ -2905,9 +2907,9 @@ je_mallctlbymib(const size_t *mib, size_t miblen, void *oldp, size_t *oldlenp,
|
||||
}
|
||||
|
||||
tsd = tsd_fetch();
|
||||
witness_assert_lockless(tsd_tsdn(tsd));
|
||||
witness_assert_lockless(tsdn_witness_tsdp_get(tsd_tsdn(tsd)));
|
||||
ret = ctl_bymib(tsd, mib, miblen, oldp, oldlenp, newp, newlen);
|
||||
witness_assert_lockless(tsd_tsdn(tsd));
|
||||
witness_assert_lockless(tsdn_witness_tsdp_get(tsd_tsdn(tsd)));
|
||||
return ret;
|
||||
}
|
||||
|
||||
@@ -2917,9 +2919,9 @@ je_malloc_stats_print(void (*write_cb)(void *, const char *), void *cbopaque,
|
||||
tsdn_t *tsdn;
|
||||
|
||||
tsdn = tsdn_fetch();
|
||||
witness_assert_lockless(tsdn);
|
||||
witness_assert_lockless(tsdn_witness_tsdp_get(tsdn));
|
||||
stats_print(write_cb, cbopaque, opts);
|
||||
witness_assert_lockless(tsdn);
|
||||
witness_assert_lockless(tsdn_witness_tsdp_get(tsdn));
|
||||
}
|
||||
|
||||
JEMALLOC_EXPORT size_t JEMALLOC_NOTHROW
|
||||
@@ -2930,7 +2932,7 @@ je_malloc_usable_size(JEMALLOC_USABLE_SIZE_CONST void *ptr) {
|
||||
assert(malloc_initialized() || IS_INITIALIZER);
|
||||
|
||||
tsdn = tsdn_fetch();
|
||||
witness_assert_lockless(tsdn);
|
||||
witness_assert_lockless(tsdn_witness_tsdp_get(tsdn));
|
||||
|
||||
if (unlikely(ptr == NULL)) {
|
||||
ret = 0;
|
||||
@@ -2943,7 +2945,7 @@ je_malloc_usable_size(JEMALLOC_USABLE_SIZE_CONST void *ptr) {
|
||||
}
|
||||
}
|
||||
|
||||
witness_assert_lockless(tsdn);
|
||||
witness_assert_lockless(tsdn_witness_tsdp_get(tsdn));
|
||||
return ret;
|
||||
}
|
||||
|
||||
@@ -3000,7 +3002,7 @@ _malloc_prefork(void)
|
||||
|
||||
narenas = narenas_total_get();
|
||||
|
||||
witness_prefork(tsd);
|
||||
witness_prefork(tsd_witness_tsdp_get(tsd));
|
||||
/* Acquire all mutexes in a safe order. */
|
||||
ctl_prefork(tsd_tsdn(tsd));
|
||||
tcache_prefork(tsd_tsdn(tsd));
|
||||
@@ -3067,7 +3069,7 @@ _malloc_postfork(void)
|
||||
|
||||
tsd = tsd_fetch();
|
||||
|
||||
witness_postfork_parent(tsd);
|
||||
witness_postfork_parent(tsd_witness_tsdp_get(tsd));
|
||||
/* Release all mutexes, now that fork() has completed. */
|
||||
for (i = 0, narenas = narenas_total_get(); i < narenas; i++) {
|
||||
arena_t *arena;
|
||||
@@ -3094,7 +3096,7 @@ jemalloc_postfork_child(void) {
|
||||
|
||||
tsd = tsd_fetch();
|
||||
|
||||
witness_postfork_child(tsd);
|
||||
witness_postfork_child(tsd_witness_tsdp_get(tsd));
|
||||
/* Release all mutexes, now that fork() has completed. */
|
||||
for (i = 0, narenas = narenas_total_get(); i < narenas; i++) {
|
||||
arena_t *arena;
|
||||
|
@@ -568,7 +568,7 @@ label_return:
|
||||
|
||||
bool
|
||||
tcaches_create(tsd_t *tsd, unsigned *r_ind) {
|
||||
witness_assert_depth(tsd_tsdn(tsd), 0);
|
||||
witness_assert_depth(tsdn_witness_tsdp_get(tsd_tsdn(tsd)), 0);
|
||||
|
||||
bool err;
|
||||
|
||||
@@ -600,7 +600,7 @@ tcaches_create(tsd_t *tsd, unsigned *r_ind) {
|
||||
|
||||
err = false;
|
||||
label_return:
|
||||
witness_assert_depth(tsd_tsdn(tsd), 0);
|
||||
witness_assert_depth(tsdn_witness_tsdp_get(tsd_tsdn(tsd)), 0);
|
||||
return err;
|
||||
}
|
||||
|
||||
|
@@ -140,7 +140,7 @@ tsd_do_data_cleanup(tsd_t *tsd) {
|
||||
arena_cleanup(tsd);
|
||||
arenas_tdata_cleanup(tsd);
|
||||
tcache_cleanup(tsd);
|
||||
witnesses_cleanup(tsd);
|
||||
witnesses_cleanup(tsd_witness_tsdp_get_unsafe(tsd));
|
||||
}
|
||||
|
||||
void
|
||||
|
@@ -63,38 +63,38 @@ witness_depth_error_t *JET_MUTABLE witness_depth_error =
|
||||
witness_depth_error_impl;
|
||||
|
||||
void
|
||||
witnesses_cleanup(tsd_t *tsd) {
|
||||
witness_assert_lockless(tsd_tsdn(tsd));
|
||||
witnesses_cleanup(witness_tsd_t *witness_tsd) {
|
||||
witness_assert_lockless(witness_tsd_tsdn(witness_tsd));
|
||||
|
||||
/* Do nothing. */
|
||||
}
|
||||
|
||||
void
|
||||
witness_prefork(tsd_t *tsd) {
|
||||
witness_prefork(witness_tsd_t *witness_tsd) {
|
||||
if (!config_debug) {
|
||||
return;
|
||||
}
|
||||
tsd_witness_fork_set(tsd, true);
|
||||
witness_tsd->forking = true;
|
||||
}
|
||||
|
||||
void
|
||||
witness_postfork_parent(tsd_t *tsd) {
|
||||
witness_postfork_parent(witness_tsd_t *witness_tsd) {
|
||||
if (!config_debug) {
|
||||
return;
|
||||
}
|
||||
tsd_witness_fork_set(tsd, false);
|
||||
witness_tsd->forking = false;
|
||||
}
|
||||
|
||||
void
|
||||
witness_postfork_child(tsd_t *tsd) {
|
||||
witness_postfork_child(witness_tsd_t *witness_tsd) {
|
||||
if (!config_debug) {
|
||||
return;
|
||||
}
|
||||
#ifndef JEMALLOC_MUTEX_INIT_CB
|
||||
witness_list_t *witnesses;
|
||||
|
||||
witnesses = tsd_witnessesp_get(tsd);
|
||||
witnesses = &witness_tsd->witnesses;
|
||||
ql_new(witnesses);
|
||||
#endif
|
||||
tsd_witness_fork_set(tsd, false);
|
||||
witness_tsd->forking = false;
|
||||
}
|
||||
|
Reference in New Issue
Block a user