Extent -> Ehooks: Move destroy hook.
This commit is contained in:
parent
bac8e2e5a6
commit
5459ec9dae
@ -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,
|
void *ehooks_default_alloc(extent_hooks_t *extent_hooks, void *new_addr,
|
||||||
size_t size, size_t alignment, bool *zero, bool *commit,
|
size_t size, size_t alignment, bool *zero, bool *commit,
|
||||||
unsigned arena_ind);
|
unsigned arena_ind);
|
||||||
|
|
||||||
bool ehooks_default_dalloc_impl(void *addr, size_t size);
|
bool ehooks_default_dalloc_impl(void *addr, size_t size);
|
||||||
bool ehooks_default_dalloc(extent_hooks_t *extent_hooks, void *addr,
|
bool ehooks_default_dalloc(extent_hooks_t *extent_hooks, void *addr,
|
||||||
size_t size, bool committed, unsigned arena_ind);
|
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
|
static inline void
|
||||||
ehooks_pre_reentrancy(tsdn_t *tsdn) {
|
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
|
static inline void
|
||||||
ehooks_destroy(ehooks_t *ehooks, void *addr, size_t size, bool committed,
|
ehooks_destroy(tsdn_t *tsdn, ehooks_t *ehooks, void *addr, size_t size,
|
||||||
unsigned arena_ind) {
|
bool committed, unsigned arena_ind) {
|
||||||
extent_hooks_t *extent_hooks = ehooks_get_extent_hooks_ptr(ehooks);
|
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;
|
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
|
static inline bool
|
||||||
|
14
src/ehooks.c
14
src/ehooks.c
@ -89,3 +89,17 @@ ehooks_default_dalloc(extent_hooks_t *extent_hooks, void *addr, size_t size,
|
|||||||
bool committed, unsigned arena_ind) {
|
bool committed, unsigned arena_ind) {
|
||||||
return ehooks_default_dalloc_impl(addr, size);
|
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);
|
||||||
|
}
|
||||||
|
|
||||||
|
31
src/extent.c
31
src/extent.c
@ -19,8 +19,6 @@ mutex_pool_t extent_mutex_pool;
|
|||||||
|
|
||||||
size_t opt_lg_extent_max_active_fit = LG_EXTENT_MAX_ACTIVE_FIT_DEFAULT;
|
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,
|
static bool extent_commit_default(extent_hooks_t *extent_hooks, void *addr,
|
||||||
size_t size, size_t offset, size_t length, unsigned arena_ind);
|
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,
|
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 = {
|
const extent_hooks_t extent_hooks_default = {
|
||||||
ehooks_default_alloc,
|
ehooks_default_alloc,
|
||||||
ehooks_default_dalloc,
|
ehooks_default_dalloc,
|
||||||
extent_destroy_default,
|
ehooks_default_destroy,
|
||||||
extent_commit_default,
|
extent_commit_default,
|
||||||
extent_decommit_default
|
extent_decommit_default
|
||||||
#ifdef PAGES_CAN_PURGE_LAZY
|
#ifdef PAGES_CAN_PURGE_LAZY
|
||||||
@ -1421,19 +1419,6 @@ extent_dalloc_wrapper(tsdn_t *tsdn, arena_t *arena, ehooks_t *ehooks,
|
|||||||
false);
|
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
|
void
|
||||||
extent_destroy_wrapper(tsdn_t *tsdn, arena_t *arena, ehooks_t *ehooks,
|
extent_destroy_wrapper(tsdn_t *tsdn, arena_t *arena, ehooks_t *ehooks,
|
||||||
extent_t *extent) {
|
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));
|
extent_addr_set(extent, extent_base_get(extent));
|
||||||
|
|
||||||
/* Try to destroy; silently fail otherwise. */
|
/* Try to destroy; silently fail otherwise. */
|
||||||
if (ehooks_are_default(ehooks)) {
|
ehooks_destroy(tsdn, ehooks, extent_base_get(extent),
|
||||||
/* Call directly to propagate tsdn. */
|
extent_size_get(extent), extent_committed_get(extent),
|
||||||
extent_destroy_default_impl(extent_base_get(extent),
|
arena_ind_get(arena));
|
||||||
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);
|
|
||||||
}
|
|
||||||
|
|
||||||
extent_dalloc(tsdn, arena, extent);
|
extent_dalloc(tsdn, arena, extent);
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user