From d05b61db4a4ac9ba498d2a478f65035935d776ba Mon Sep 17 00:00:00 2001 From: David Goldblatt Date: Thu, 30 Jan 2020 12:40:07 -0800 Subject: [PATCH] Emap: Move extent boundary registration in. --- include/jemalloc/internal/emap.h | 8 ++++++++ src/emap.c | 13 +++++++++++++ src/extent.c | 12 +++++------- 3 files changed, 26 insertions(+), 7 deletions(-) diff --git a/include/jemalloc/internal/emap.h b/include/jemalloc/internal/emap.h index b9624d18..93fa472a 100644 --- a/include/jemalloc/internal/emap.h +++ b/include/jemalloc/internal/emap.h @@ -35,4 +35,12 @@ void emap_rtree_write_acquired(tsdn_t *tsdn, emap_t *emap, rtree_leaf_elm_t *elm_a, rtree_leaf_elm_t *elm_b, edata_t *edata, szind_t szind, bool slab); +/* + * Associate the given edata with its beginning and end address, setting the + * szind and slab info appropriately. + * Returns true on error (i.e. resource exhaustion). + */ +bool emap_register_boundary(tsdn_t *tsdn, emap_t *emap, rtree_ctx_t *rtree_ctx, + edata_t *edata, szind_t szind, bool slab); + #endif /* JEMALLOC_INTERNAL_EMAP_H */ diff --git a/src/emap.c b/src/emap.c index 4ed9ff11..4371c4a2 100644 --- a/src/emap.c +++ b/src/emap.c @@ -135,3 +135,16 @@ emap_rtree_write_acquired(tsdn_t *tsdn, emap_t *emap, rtree_leaf_elm_t *elm_a, slab); } } + +bool +emap_register_boundary(tsdn_t *tsdn, emap_t *emap, rtree_ctx_t *rtree_ctx, + edata_t *edata, szind_t szind, bool slab) { + rtree_leaf_elm_t *elm_a, *elm_b; + bool err = emap_rtree_leaf_elms_lookup(tsdn, emap, rtree_ctx, edata, + false, true, &elm_a, &elm_b); + if (err) { + return true; + } + emap_rtree_write_acquired(tsdn, emap, elm_a, elm_b, edata, szind, slab); + return false; +} diff --git a/src/extent.c b/src/extent.c index fc449254..4c4e16a2 100644 --- a/src/extent.c +++ b/src/extent.c @@ -324,7 +324,6 @@ static bool extent_register_impl(tsdn_t *tsdn, edata_t *edata, bool gdump_add) { rtree_ctx_t rtree_ctx_fallback; rtree_ctx_t *rtree_ctx = tsdn_rtree_ctx(tsdn, &rtree_ctx_fallback); - rtree_leaf_elm_t *elm_a, *elm_b; /* * We need to hold the lock to protect against a concurrent coalesce @@ -332,16 +331,15 @@ extent_register_impl(tsdn_t *tsdn, edata_t *edata, bool gdump_add) { */ emap_lock_edata(tsdn, &emap_global, edata); - if (emap_rtree_leaf_elms_lookup(tsdn, &emap_global, rtree_ctx, edata, - false, true, &elm_a, &elm_b)) { + szind_t szind = edata_szind_get_maybe_invalid(edata); + bool slab = edata_slab_get(edata); + + if (emap_register_boundary(tsdn, &emap_global, rtree_ctx, edata, szind, + slab)) { emap_unlock_edata(tsdn, &emap_global, edata); return true; } - szind_t szind = edata_szind_get_maybe_invalid(edata); - bool slab = edata_slab_get(edata); - emap_rtree_write_acquired(tsdn, &emap_global, elm_a, elm_b, edata, - szind, slab); if (slab) { extent_interior_register(tsdn, rtree_ctx, edata, szind); }