Move extent hook getters/setters to arena.c
This is where they're logically scoped; they access arena data.
This commit is contained in:
parent
9226e1f0d8
commit
4278f84603
@ -72,6 +72,9 @@ void *arena_ralloc(tsdn_t *tsdn, arena_t *arena, void *ptr, size_t oldsize,
|
||||
size_t size, size_t alignment, bool zero, tcache_t *tcache,
|
||||
hook_ralloc_args_t *hook_args);
|
||||
dss_prec_t arena_dss_prec_get(arena_t *arena);
|
||||
extent_hooks_t *arena_get_extent_hooks(arena_t *arena);
|
||||
extent_hooks_t *arena_set_extent_hooks(tsd_t *tsd, arena_t *arena,
|
||||
extent_hooks_t *extent_hooks);
|
||||
bool arena_dss_prec_set(arena_t *arena, dss_prec_t dss_prec);
|
||||
ssize_t arena_dirty_decay_ms_default_get(void);
|
||||
bool arena_dirty_decay_ms_default_set(ssize_t decay_ms);
|
||||
|
@ -16,7 +16,7 @@ arena_get_from_extent(extent_t *extent) {
|
||||
|
||||
JEMALLOC_ALWAYS_INLINE bool
|
||||
arena_has_default_hooks(arena_t *arena) {
|
||||
return (extent_hooks_get(arena) == &extent_hooks_default);
|
||||
return (arena_get_extent_hooks(arena) == &extent_hooks_default);
|
||||
}
|
||||
|
||||
JEMALLOC_ALWAYS_INLINE arena_t *
|
||||
|
@ -15,10 +15,6 @@ extern mutex_pool_t extent_mutex_pool;
|
||||
extent_t *extent_alloc(tsdn_t *tsdn, arena_t *arena);
|
||||
void extent_dalloc(tsdn_t *tsdn, arena_t *arena, extent_t *extent);
|
||||
|
||||
extent_hooks_t *extent_hooks_get(arena_t *arena);
|
||||
extent_hooks_t *extent_hooks_set(tsd_t *tsd, arena_t *arena,
|
||||
extent_hooks_t *extent_hooks);
|
||||
|
||||
ph_proto(, extent_avail_, extent_tree_t, extent_t)
|
||||
ph_proto(, extent_heap_, extent_heap_t, extent_t)
|
||||
|
||||
|
26
src/arena.c
26
src/arena.c
@ -923,7 +923,7 @@ arena_decay_to_limit(tsdn_t *tsdn, arena_t *arena, arena_decay_t *decay,
|
||||
decay->purging = true;
|
||||
malloc_mutex_unlock(tsdn, &decay->mtx);
|
||||
|
||||
extent_hooks_t *extent_hooks = extent_hooks_get(arena);
|
||||
extent_hooks_t *extent_hooks = arena_get_extent_hooks(arena);
|
||||
|
||||
extent_list_t decay_extents;
|
||||
extent_list_init(&decay_extents);
|
||||
@ -1159,7 +1159,7 @@ arena_destroy_retained(tsdn_t *tsdn, arena_t *arena) {
|
||||
* destroyed, or provide custom extent hooks that track retained
|
||||
* dss-based extents for later reuse.
|
||||
*/
|
||||
extent_hooks_t *extent_hooks = extent_hooks_get(arena);
|
||||
extent_hooks_t *extent_hooks = arena_get_extent_hooks(arena);
|
||||
extent_t *extent;
|
||||
while ((extent = extents_evict(tsdn, arena, &extent_hooks,
|
||||
&arena->eset_retained, 0)) != NULL) {
|
||||
@ -1846,6 +1846,28 @@ arena_ralloc(tsdn_t *tsdn, arena_t *arena, void *ptr, size_t oldsize,
|
||||
return ret;
|
||||
}
|
||||
|
||||
extent_hooks_t *
|
||||
arena_get_extent_hooks(arena_t *arena) {
|
||||
return base_extent_hooks_get(arena->base);
|
||||
}
|
||||
|
||||
extent_hooks_t *
|
||||
arena_set_extent_hooks(tsd_t *tsd, arena_t *arena,
|
||||
extent_hooks_t *extent_hooks) {
|
||||
background_thread_info_t *info;
|
||||
if (have_background_thread) {
|
||||
info = arena_background_thread_info_get(arena);
|
||||
malloc_mutex_lock(tsd_tsdn(tsd), &info->mtx);
|
||||
}
|
||||
extent_hooks_t *ret = base_extent_hooks_set(arena->base, extent_hooks);
|
||||
if (have_background_thread) {
|
||||
malloc_mutex_unlock(tsd_tsdn(tsd), &info->mtx);
|
||||
}
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
|
||||
dss_prec_t
|
||||
arena_dss_prec_get(arena_t *arena) {
|
||||
return (dss_prec_t)atomic_load_u(&arena->dss_prec, ATOMIC_ACQUIRE);
|
||||
|
@ -2396,11 +2396,12 @@ arena_i_extent_hooks_ctl(tsd_t *tsd, const size_t *mib, size_t miblen,
|
||||
extent_hooks_t *new_extent_hooks
|
||||
JEMALLOC_CC_SILENCE_INIT(NULL);
|
||||
WRITE(new_extent_hooks, extent_hooks_t *);
|
||||
old_extent_hooks = extent_hooks_set(tsd, arena,
|
||||
new_extent_hooks);
|
||||
old_extent_hooks = arena_set_extent_hooks(tsd,
|
||||
arena, new_extent_hooks);
|
||||
READ(old_extent_hooks, extent_hooks_t *);
|
||||
} else {
|
||||
old_extent_hooks = extent_hooks_get(arena);
|
||||
old_extent_hooks = arena_get_extent_hooks(
|
||||
arena);
|
||||
READ(old_extent_hooks, extent_hooks_t *);
|
||||
}
|
||||
}
|
||||
|
22
src/extent.c
22
src/extent.c
@ -221,31 +221,11 @@ extent_dalloc(tsdn_t *tsdn, arena_t *arena, extent_t *extent) {
|
||||
malloc_mutex_unlock(tsdn, &arena->extent_avail_mtx);
|
||||
}
|
||||
|
||||
extent_hooks_t *
|
||||
extent_hooks_get(arena_t *arena) {
|
||||
return base_extent_hooks_get(arena->base);
|
||||
}
|
||||
|
||||
extent_hooks_t *
|
||||
extent_hooks_set(tsd_t *tsd, arena_t *arena, extent_hooks_t *extent_hooks) {
|
||||
background_thread_info_t *info;
|
||||
if (have_background_thread) {
|
||||
info = arena_background_thread_info_get(arena);
|
||||
malloc_mutex_lock(tsd_tsdn(tsd), &info->mtx);
|
||||
}
|
||||
extent_hooks_t *ret = base_extent_hooks_set(arena->base, extent_hooks);
|
||||
if (have_background_thread) {
|
||||
malloc_mutex_unlock(tsd_tsdn(tsd), &info->mtx);
|
||||
}
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
static void
|
||||
extent_hooks_assure_initialized(arena_t *arena,
|
||||
extent_hooks_t **r_extent_hooks) {
|
||||
if (*r_extent_hooks == EXTENT_HOOKS_INITIALIZER) {
|
||||
*r_extent_hooks = extent_hooks_get(arena);
|
||||
*r_extent_hooks = arena_get_extent_hooks(arena);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -93,7 +93,7 @@ static bool
|
||||
large_ralloc_no_move_shrink(tsdn_t *tsdn, extent_t *extent, size_t usize) {
|
||||
arena_t *arena = arena_get_from_extent(extent);
|
||||
size_t oldusize = extent_usize_get(extent);
|
||||
extent_hooks_t *extent_hooks = extent_hooks_get(arena);
|
||||
extent_hooks_t *extent_hooks = arena_get_extent_hooks(arena);
|
||||
size_t diff = extent_size_get(extent) - (usize + sz_large_pad);
|
||||
|
||||
assert(oldusize > usize);
|
||||
@ -129,7 +129,7 @@ large_ralloc_no_move_expand(tsdn_t *tsdn, extent_t *extent, size_t usize,
|
||||
bool zero) {
|
||||
arena_t *arena = arena_get_from_extent(extent);
|
||||
size_t oldusize = extent_usize_get(extent);
|
||||
extent_hooks_t *extent_hooks = extent_hooks_get(arena);
|
||||
extent_hooks_t *extent_hooks = arena_get_extent_hooks(arena);
|
||||
size_t trailsize = usize - oldusize;
|
||||
|
||||
if (extent_hooks->merge == NULL) {
|
||||
|
Loading…
Reference in New Issue
Block a user