Extent -> Ehooks: Move split hook.
This commit is contained in:
parent
a5b42a1a10
commit
1fff4d2ee3
@ -39,6 +39,9 @@ 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,
|
bool ehooks_default_purge_forced(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);
|
||||||
#endif
|
#endif
|
||||||
|
bool ehooks_default_split_impl();
|
||||||
|
bool ehooks_default_split(extent_hooks_t *extent_hooks, void *addr, size_t size,
|
||||||
|
size_t size_a, size_t size_b, bool committed, unsigned arena_ind);
|
||||||
|
|
||||||
static inline void
|
static inline void
|
||||||
ehooks_pre_reentrancy(tsdn_t *tsdn) {
|
ehooks_pre_reentrancy(tsdn_t *tsdn) {
|
||||||
@ -218,14 +221,20 @@ ehooks_purge_forced(tsdn_t *tsdn, ehooks_t *ehooks, void *addr, size_t size,
|
|||||||
}
|
}
|
||||||
|
|
||||||
static inline bool
|
static inline bool
|
||||||
ehooks_split(ehooks_t *ehooks, void *addr, size_t size, size_t size_a,
|
ehooks_split(tsdn_t *tsdn, ehooks_t *ehooks, void *addr, size_t size,
|
||||||
size_t size_b, bool committed, unsigned arena_ind) {
|
size_t size_a, size_t size_b, 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->split == NULL) {
|
if (ehooks_are_default(ehooks)) {
|
||||||
|
return ehooks_default_split_impl();
|
||||||
|
} else if (extent_hooks->split == NULL) {
|
||||||
return true;
|
return true;
|
||||||
|
} else {
|
||||||
|
ehooks_pre_reentrancy(tsdn);
|
||||||
|
bool err = extent_hooks->split(extent_hooks, addr, size, size_a,
|
||||||
|
size_b, committed, arena_ind);
|
||||||
|
ehooks_post_reentrancy(tsdn);
|
||||||
|
return err;
|
||||||
}
|
}
|
||||||
return extent_hooks->split(extent_hooks, addr, size, size_a, size_b,
|
|
||||||
committed, arena_ind);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static inline bool
|
static inline bool
|
||||||
|
20
src/ehooks.c
20
src/ehooks.c
@ -162,3 +162,23 @@ ehooks_default_purge_forced(extent_hooks_t *extent_hooks, void *addr,
|
|||||||
return ehooks_default_purge_forced_impl(addr, offset, length);
|
return ehooks_default_purge_forced_impl(addr, offset, length);
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
bool
|
||||||
|
ehooks_default_split_impl() {
|
||||||
|
if (!maps_coalesce) {
|
||||||
|
/*
|
||||||
|
* Without retain, only whole regions can be purged (required by
|
||||||
|
* MEM_RELEASE on Windows) -- therefore disallow splitting. See
|
||||||
|
* comments in extent_head_no_merge().
|
||||||
|
*/
|
||||||
|
return !opt_retain;
|
||||||
|
}
|
||||||
|
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
bool
|
||||||
|
ehooks_default_split(extent_hooks_t *extent_hooks, void *addr, size_t size,
|
||||||
|
size_t size_a, size_t size_b, bool committed, unsigned arena_ind) {
|
||||||
|
return ehooks_default_split_impl();
|
||||||
|
}
|
||||||
|
29
src/extent.c
29
src/extent.c
@ -27,9 +27,6 @@ static bool extent_purge_lazy_impl(tsdn_t *tsdn, arena_t *arena,
|
|||||||
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);
|
||||||
static bool extent_split_default(extent_hooks_t *extent_hooks, void *addr,
|
|
||||||
size_t size, size_t size_a, size_t size_b, bool committed,
|
|
||||||
unsigned arena_ind);
|
|
||||||
static extent_t *extent_split_impl(tsdn_t *tsdn, arena_t *arena,
|
static extent_t *extent_split_impl(tsdn_t *tsdn, arena_t *arena,
|
||||||
ehooks_t *ehooks, extent_t *extent, size_t size_a, szind_t szind_a,
|
ehooks_t *ehooks, 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,
|
bool slab_a, size_t size_b, szind_t szind_b, bool slab_b,
|
||||||
@ -56,7 +53,7 @@ const extent_hooks_t extent_hooks_default = {
|
|||||||
#else
|
#else
|
||||||
NULL,
|
NULL,
|
||||||
#endif
|
#endif
|
||||||
extent_split_default,
|
ehooks_default_split,
|
||||||
extent_merge_default
|
extent_merge_default
|
||||||
};
|
};
|
||||||
|
|
||||||
@ -1487,21 +1484,6 @@ extent_purge_forced_wrapper(tsdn_t *tsdn, arena_t *arena, ehooks_t *ehooks,
|
|||||||
offset, length, false);
|
offset, length, false);
|
||||||
}
|
}
|
||||||
|
|
||||||
static bool
|
|
||||||
extent_split_default(extent_hooks_t *extent_hooks, void *addr, size_t size,
|
|
||||||
size_t size_a, size_t size_b, bool committed, unsigned arena_ind) {
|
|
||||||
if (!maps_coalesce) {
|
|
||||||
/*
|
|
||||||
* Without retain, only whole regions can be purged (required by
|
|
||||||
* MEM_RELEASE on Windows) -- therefore disallow splitting. See
|
|
||||||
* comments in extent_head_no_merge().
|
|
||||||
*/
|
|
||||||
return !opt_retain;
|
|
||||||
}
|
|
||||||
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Accepts the extent to split, and the characteristics of each side of the
|
* Accepts the extent to split, and the characteristics of each side of the
|
||||||
* split. The 'a' parameters go with the 'lead' of the resulting pair of
|
* split. The 'a' parameters go with the 'lead' of the resulting pair of
|
||||||
@ -1559,15 +1541,10 @@ extent_split_impl(tsdn_t *tsdn, arena_t *arena, ehooks_t *ehooks,
|
|||||||
|
|
||||||
extent_lock2(tsdn, extent, trail);
|
extent_lock2(tsdn, extent, trail);
|
||||||
|
|
||||||
if (!ehooks_are_default(ehooks)) {
|
bool err = ehooks_split(tsdn, ehooks, extent_base_get(extent),
|
||||||
extent_hook_pre_reentrancy(tsdn, arena);
|
|
||||||
}
|
|
||||||
bool err = ehooks_split(ehooks, extent_base_get(extent),
|
|
||||||
size_a + size_b, size_a, size_b, extent_committed_get(extent),
|
size_a + size_b, size_a, size_b, extent_committed_get(extent),
|
||||||
arena_ind_get(arena));
|
arena_ind_get(arena));
|
||||||
if (!ehooks_are_default(ehooks)) {
|
|
||||||
extent_hook_post_reentrancy(tsdn);
|
|
||||||
}
|
|
||||||
if (err) {
|
if (err) {
|
||||||
goto label_error_c;
|
goto label_error_c;
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user