From 09475bf8acfef36924df787deb0247a7b0456c66 Mon Sep 17 00:00:00 2001 From: David Goldblatt Date: Wed, 11 Dec 2019 13:35:43 -0800 Subject: [PATCH] extent_may_dalloc -> ehooks_dalloc_will_fail --- include/jemalloc/internal/ehooks.h | 10 ++++++++++ src/extent2.c | 8 +------- 2 files changed, 11 insertions(+), 7 deletions(-) diff --git a/include/jemalloc/internal/ehooks.h b/include/jemalloc/internal/ehooks.h index c046cd13..711a534b 100644 --- a/include/jemalloc/internal/ehooks.h +++ b/include/jemalloc/internal/ehooks.h @@ -9,6 +9,7 @@ */ #include "jemalloc/internal/atomic.h" +#include "jemalloc/internal/extent_mmap.h" extern const extent_hooks_t ehooks_default_extent_hooks; @@ -96,6 +97,15 @@ ehooks_are_default(ehooks_t *ehooks) { * a hook. If that hook is doomed to fail, this is wasteful. We therefore * include some checks for such cases. */ +static inline bool +ehooks_dalloc_will_fail(ehooks_t *ehooks) { + if (ehooks_are_default(ehooks)) { + return opt_retain; + } else { + return ehooks_get_extent_hooks_ptr(ehooks)->dalloc == NULL; + } +} + static inline bool ehooks_split_will_fail(ehooks_t *ehooks) { return ehooks_get_extent_hooks_ptr(ehooks)->split == NULL; diff --git a/src/extent2.c b/src/extent2.c index b77e4b89..148c3283 100644 --- a/src/extent2.c +++ b/src/extent2.c @@ -1243,12 +1243,6 @@ extent_dalloc_gap(tsdn_t *tsdn, arena_t *arena, edata_t *edata) { extent_dalloc_wrapper(tsdn, arena, ehooks, edata); } -static bool -extent_may_dalloc(void) { - /* With retain enabled, the default dalloc always fails. */ - return !opt_retain; -} - static bool extent_dalloc_wrapper_try(tsdn_t *tsdn, arena_t *arena, ehooks_t *ehooks, edata_t *edata) { @@ -1281,7 +1275,7 @@ extent_dalloc_wrapper(tsdn_t *tsdn, arena_t *arena, ehooks_t *ehooks, WITNESS_RANK_CORE, 0); /* Avoid calling the default extent_dalloc unless have to. */ - if (!ehooks_are_default(ehooks) || extent_may_dalloc()) { + if (!ehooks_dalloc_will_fail(ehooks)) { /* * Deregister first to avoid a race with other allocating * threads, and reregister if deallocation fails.