Emap: Move extent boundary registration in.

This commit is contained in:
David Goldblatt 2020-01-30 12:40:07 -08:00 committed by David Goldblatt
parent ca21ce4071
commit d05b61db4a
3 changed files with 26 additions and 7 deletions

View File

@ -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 */

View File

@ -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;
}

View File

@ -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);
}