Extent -> Ehooks: Move purge_forced hook.
This commit is contained in:
parent
368baa42ef
commit
a5b42a1a10
@ -34,6 +34,11 @@ bool ehooks_default_purge_lazy_impl(void *addr, size_t offset, size_t length);
|
|||||||
bool ehooks_default_purge_lazy(extent_hooks_t *extent_hooks, void *addr, size_t size,
|
bool ehooks_default_purge_lazy(extent_hooks_t *extent_hooks, void *addr, size_t size,
|
||||||
size_t offset, size_t length, unsigned arena_ind);
|
size_t offset, size_t length, unsigned arena_ind);
|
||||||
#endif
|
#endif
|
||||||
|
#ifdef PAGES_CAN_PURGE_FORCED
|
||||||
|
bool ehooks_default_purge_forced_impl(void *addr, size_t offset, size_t length);
|
||||||
|
bool ehooks_default_purge_forced(extent_hooks_t *extent_hooks, void *addr,
|
||||||
|
size_t size, size_t offset, size_t length, unsigned arena_ind);
|
||||||
|
#endif
|
||||||
|
|
||||||
static inline void
|
static inline void
|
||||||
ehooks_pre_reentrancy(tsdn_t *tsdn) {
|
ehooks_pre_reentrancy(tsdn_t *tsdn) {
|
||||||
@ -193,14 +198,23 @@ ehooks_purge_lazy(tsdn_t *tsdn, ehooks_t *ehooks, void *addr, size_t size,
|
|||||||
}
|
}
|
||||||
|
|
||||||
static inline bool
|
static inline bool
|
||||||
ehooks_purge_forced(ehooks_t *ehooks, void *addr, size_t size, size_t offset,
|
ehooks_purge_forced(tsdn_t *tsdn, ehooks_t *ehooks, void *addr, size_t size,
|
||||||
size_t length, unsigned arena_ind) {
|
size_t offset, size_t length, 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);
|
||||||
|
#ifdef PAGES_CAN_PURGE_FORCED
|
||||||
|
if (extent_hooks == &extent_hooks_default) {
|
||||||
|
return ehooks_default_purge_forced_impl(addr, offset, length);
|
||||||
|
}
|
||||||
|
#endif
|
||||||
if (extent_hooks->purge_forced == NULL) {
|
if (extent_hooks->purge_forced == NULL) {
|
||||||
return true;
|
return true;
|
||||||
|
} else {
|
||||||
|
ehooks_pre_reentrancy(tsdn);
|
||||||
|
bool err = extent_hooks->purge_forced(extent_hooks, addr, size,
|
||||||
|
offset, length, arena_ind);
|
||||||
|
ehooks_post_reentrancy(tsdn);
|
||||||
|
return err;
|
||||||
}
|
}
|
||||||
return extent_hooks->purge_forced(extent_hooks, addr, size, offset,
|
|
||||||
length, arena_ind);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static inline bool
|
static inline bool
|
||||||
|
@ -87,7 +87,8 @@ base_unmap(tsdn_t *tsdn, ehooks_t *ehooks, unsigned ind, void *addr,
|
|||||||
if (!ehooks_decommit(tsdn, ehooks, addr, size, 0, size, ind)) {
|
if (!ehooks_decommit(tsdn, ehooks, addr, size, 0, size, ind)) {
|
||||||
goto label_post_reentrancy;
|
goto label_post_reentrancy;
|
||||||
}
|
}
|
||||||
if (!ehooks_purge_forced(ehooks, addr, size, 0, size, ind)) {
|
if (!ehooks_purge_forced(tsdn, ehooks, addr, size, 0, size,
|
||||||
|
ind)) {
|
||||||
goto label_post_reentrancy;
|
goto label_post_reentrancy;
|
||||||
}
|
}
|
||||||
if (!ehooks_purge_lazy(tsdn, ehooks, addr, size, 0, size,
|
if (!ehooks_purge_lazy(tsdn, ehooks, addr, size, 0, size,
|
||||||
|
18
src/ehooks.c
18
src/ehooks.c
@ -144,3 +144,21 @@ ehooks_default_purge_lazy(extent_hooks_t *extent_hooks, void *addr, size_t size,
|
|||||||
return ehooks_default_purge_lazy_impl(addr, offset, length);
|
return ehooks_default_purge_lazy_impl(addr, offset, length);
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
#ifdef PAGES_CAN_PURGE_FORCED
|
||||||
|
bool
|
||||||
|
ehooks_default_purge_forced_impl(void *addr, size_t offset, size_t length) {
|
||||||
|
return pages_purge_forced((void *)((uintptr_t)addr +
|
||||||
|
(uintptr_t)offset), length);
|
||||||
|
}
|
||||||
|
|
||||||
|
bool
|
||||||
|
ehooks_default_purge_forced(extent_hooks_t *extent_hooks, void *addr,
|
||||||
|
size_t size, size_t offset, size_t length, unsigned arena_ind) {
|
||||||
|
assert(addr != NULL);
|
||||||
|
assert((offset & PAGE_MASK) == 0);
|
||||||
|
assert(length != 0);
|
||||||
|
assert((length & PAGE_MASK) == 0);
|
||||||
|
return ehooks_default_purge_forced_impl(addr, offset, length);
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
34
src/extent.c
34
src/extent.c
@ -24,10 +24,6 @@ static bool extent_commit_impl(tsdn_t *tsdn, arena_t *arena, ehooks_t *ehooks,
|
|||||||
static bool extent_purge_lazy_impl(tsdn_t *tsdn, arena_t *arena,
|
static bool extent_purge_lazy_impl(tsdn_t *tsdn, arena_t *arena,
|
||||||
ehooks_t *ehooks, extent_t *extent, size_t offset, size_t length,
|
ehooks_t *ehooks, extent_t *extent, size_t offset, size_t length,
|
||||||
bool growing_retained);
|
bool growing_retained);
|
||||||
#ifdef PAGES_CAN_PURGE_FORCED
|
|
||||||
static bool extent_purge_forced_default(extent_hooks_t *extent_hooks,
|
|
||||||
void *addr, size_t size, size_t offset, size_t length, unsigned arena_ind);
|
|
||||||
#endif
|
|
||||||
static bool extent_purge_forced_impl(tsdn_t *tsdn, arena_t *arena,
|
static bool extent_purge_forced_impl(tsdn_t *tsdn, arena_t *arena,
|
||||||
ehooks_t *ehooks, extent_t *extent, size_t offset, size_t length,
|
ehooks_t *ehooks, extent_t *extent, size_t offset, size_t length,
|
||||||
bool growing_retained);
|
bool growing_retained);
|
||||||
@ -56,7 +52,7 @@ const extent_hooks_t extent_hooks_default = {
|
|||||||
NULL,
|
NULL,
|
||||||
#endif
|
#endif
|
||||||
#ifdef PAGES_CAN_PURGE_FORCED
|
#ifdef PAGES_CAN_PURGE_FORCED
|
||||||
extent_purge_forced_default,
|
ehooks_default_purge_forced,
|
||||||
#else
|
#else
|
||||||
NULL,
|
NULL,
|
||||||
#endif
|
#endif
|
||||||
@ -1381,7 +1377,7 @@ extent_dalloc_wrapper(tsdn_t *tsdn, arena_t *arena, ehooks_t *ehooks,
|
|||||||
} else if (!extent_decommit_wrapper(tsdn, arena, ehooks, extent, 0,
|
} else if (!extent_decommit_wrapper(tsdn, arena, ehooks, extent, 0,
|
||||||
extent_size_get(extent))) {
|
extent_size_get(extent))) {
|
||||||
zeroed = true;
|
zeroed = true;
|
||||||
} else if (!ehooks_purge_forced(ehooks, extent_base_get(extent),
|
} else if (!ehooks_purge_forced(tsdn, ehooks, extent_base_get(extent),
|
||||||
extent_size_get(extent), 0, extent_size_get(extent),
|
extent_size_get(extent), 0, extent_size_get(extent),
|
||||||
arena_ind_get(arena))) {
|
arena_ind_get(arena))) {
|
||||||
zeroed = true;
|
zeroed = true;
|
||||||
@ -1474,37 +1470,13 @@ extent_purge_lazy_wrapper(tsdn_t *tsdn, arena_t *arena, ehooks_t *ehooks,
|
|||||||
length, false);
|
length, false);
|
||||||
}
|
}
|
||||||
|
|
||||||
#ifdef PAGES_CAN_PURGE_FORCED
|
|
||||||
static bool
|
|
||||||
extent_purge_forced_default(extent_hooks_t *extent_hooks, void *addr,
|
|
||||||
size_t size, size_t offset, size_t length, unsigned arena_ind) {
|
|
||||||
assert(addr != NULL);
|
|
||||||
assert((offset & PAGE_MASK) == 0);
|
|
||||||
assert(length != 0);
|
|
||||||
assert((length & PAGE_MASK) == 0);
|
|
||||||
|
|
||||||
return pages_purge_forced((void *)((uintptr_t)addr +
|
|
||||||
(uintptr_t)offset), length);
|
|
||||||
}
|
|
||||||
#endif
|
|
||||||
|
|
||||||
static bool
|
static bool
|
||||||
extent_purge_forced_impl(tsdn_t *tsdn, arena_t *arena, ehooks_t *ehooks,
|
extent_purge_forced_impl(tsdn_t *tsdn, arena_t *arena, ehooks_t *ehooks,
|
||||||
extent_t *extent, size_t offset, size_t length, bool growing_retained) {
|
extent_t *extent, size_t offset, size_t length, bool growing_retained) {
|
||||||
witness_assert_depth_to_rank(tsdn_witness_tsdp_get(tsdn),
|
witness_assert_depth_to_rank(tsdn_witness_tsdp_get(tsdn),
|
||||||
WITNESS_RANK_CORE, growing_retained ? 1 : 0);
|
WITNESS_RANK_CORE, growing_retained ? 1 : 0);
|
||||||
|
bool err = ehooks_purge_forced(tsdn, ehooks, extent_base_get(extent),
|
||||||
if (ehooks_purge_forced_will_fail(ehooks)) {
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
if (!ehooks_are_default(ehooks)) {
|
|
||||||
extent_hook_pre_reentrancy(tsdn, arena);
|
|
||||||
}
|
|
||||||
bool err = ehooks_purge_forced(ehooks, extent_base_get(extent),
|
|
||||||
extent_size_get(extent), offset, length, arena_ind_get(arena));
|
extent_size_get(extent), offset, length, arena_ind_get(arena));
|
||||||
if (!ehooks_are_default(ehooks)) {
|
|
||||||
extent_hook_post_reentrancy(tsdn);
|
|
||||||
}
|
|
||||||
return err;
|
return err;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user