Extent -> Ehooks: Move destroy hook.

This commit is contained in:
David Goldblatt 2019-12-03 12:05:18 -08:00 committed by David Goldblatt
parent bac8e2e5a6
commit 5459ec9dae
3 changed files with 31 additions and 32 deletions

View File

@ -17,10 +17,12 @@ void *ehooks_default_alloc_impl(tsdn_t *tsdn, void *new_addr, size_t size,
void *ehooks_default_alloc(extent_hooks_t *extent_hooks, void *new_addr,
size_t size, size_t alignment, bool *zero, bool *commit,
unsigned arena_ind);
bool ehooks_default_dalloc_impl(void *addr, size_t size);
bool ehooks_default_dalloc(extent_hooks_t *extent_hooks, void *addr,
size_t size, bool committed, unsigned arena_ind);
void ehooks_default_destroy_impl(void *addr, size_t size);
void ehooks_default_destroy(extent_hooks_t *extent_hooks, void *addr,
size_t size, bool committed, unsigned arena_ind);
static inline void
ehooks_pre_reentrancy(tsdn_t *tsdn) {
@ -110,13 +112,19 @@ ehooks_dalloc(tsdn_t *tsdn, ehooks_t *ehooks, void *addr, size_t size,
}
static inline void
ehooks_destroy(ehooks_t *ehooks, void *addr, size_t size, bool committed,
unsigned arena_ind) {
ehooks_destroy(tsdn_t *tsdn, ehooks_t *ehooks, void *addr, size_t size,
bool committed, unsigned arena_ind) {
extent_hooks_t *extent_hooks = ehooks_get_extent_hooks_ptr(ehooks);
if (extent_hooks->destroy == NULL) {
if (extent_hooks == &extent_hooks_default) {
return ehooks_default_destroy_impl(addr, size);
} else if (extent_hooks->destroy == NULL) {
return;
} else {
ehooks_pre_reentrancy(tsdn);
extent_hooks->destroy(extent_hooks, addr, size, committed,
arena_ind);
ehooks_post_reentrancy(tsdn);
}
extent_hooks->destroy(extent_hooks, addr, size, committed, arena_ind);
}
static inline bool

View File

@ -89,3 +89,17 @@ ehooks_default_dalloc(extent_hooks_t *extent_hooks, void *addr, size_t size,
bool committed, unsigned arena_ind) {
return ehooks_default_dalloc_impl(addr, size);
}
void
ehooks_default_destroy_impl(void *addr, size_t size) {
if (!have_dss || !extent_in_dss(addr)) {
pages_unmap(addr, size);
}
}
void
ehooks_default_destroy(extent_hooks_t *extent_hooks, void *addr, size_t size,
bool committed, unsigned arena_ind) {
ehooks_default_destroy_impl(addr, size);
}

View File

@ -19,8 +19,6 @@ mutex_pool_t extent_mutex_pool;
size_t opt_lg_extent_max_active_fit = LG_EXTENT_MAX_ACTIVE_FIT_DEFAULT;
static void extent_destroy_default(extent_hooks_t *extent_hooks, void *addr,
size_t size, bool committed, unsigned arena_ind);
static bool extent_commit_default(extent_hooks_t *extent_hooks, void *addr,
size_t size, size_t offset, size_t length, unsigned arena_ind);
static bool extent_commit_impl(tsdn_t *tsdn, arena_t *arena, ehooks_t *ehooks,
@ -57,7 +55,7 @@ static bool extent_merge_impl(tsdn_t *tsdn, arena_t *arena, ehooks_t *ehooks,
const extent_hooks_t extent_hooks_default = {
ehooks_default_alloc,
ehooks_default_dalloc,
extent_destroy_default,
ehooks_default_destroy,
extent_commit_default,
extent_decommit_default
#ifdef PAGES_CAN_PURGE_LAZY
@ -1421,19 +1419,6 @@ extent_dalloc_wrapper(tsdn_t *tsdn, arena_t *arena, ehooks_t *ehooks,
false);
}
static void
extent_destroy_default_impl(void *addr, size_t size) {
if (!have_dss || !extent_in_dss(addr)) {
pages_unmap(addr, size);
}
}
static void
extent_destroy_default(extent_hooks_t *extent_hooks, void *addr, size_t size,
bool committed, unsigned arena_ind) {
extent_destroy_default_impl(addr, size);
}
void
extent_destroy_wrapper(tsdn_t *tsdn, arena_t *arena, ehooks_t *ehooks,
extent_t *extent) {
@ -1448,17 +1433,9 @@ extent_destroy_wrapper(tsdn_t *tsdn, arena_t *arena, ehooks_t *ehooks,
extent_addr_set(extent, extent_base_get(extent));
/* Try to destroy; silently fail otherwise. */
if (ehooks_are_default(ehooks)) {
/* Call directly to propagate tsdn. */
extent_destroy_default_impl(extent_base_get(extent),
extent_size_get(extent));
} else if (!ehooks_destroy_is_noop(ehooks)) {
extent_hook_pre_reentrancy(tsdn, arena);
ehooks_destroy(ehooks, extent_base_get(extent),
extent_size_get(extent), extent_committed_get(extent),
arena_ind_get(arena));
extent_hook_post_reentrancy(tsdn);
}
ehooks_destroy(tsdn, ehooks, extent_base_get(extent),
extent_size_get(extent), extent_committed_get(extent),
arena_ind_get(arena));
extent_dalloc(tsdn, arena, extent);
}