PA: Have large expands use it.

This commit is contained in:
David Goldblatt 2020-03-10 14:38:55 -07:00 committed by David Goldblatt
parent 7be3dea82c
commit 0880c2ab97
3 changed files with 57 additions and 43 deletions

View file

@ -94,3 +94,43 @@ pa_alloc(tsdn_t *tsdn, pa_shard_t *shard, size_t size, size_t alignment,
}
return edata;
}
bool
pa_expand(tsdn_t *tsdn, pa_shard_t *shard, edata_t *edata, size_t new_usize,
bool *zero, size_t *mapped_add) {
ehooks_t *ehooks = pa_shard_ehooks_get(shard);
size_t old_usize = edata_usize_get(edata);
size_t trail_size = new_usize - old_usize;
void *trail_begin = edata_past_get(edata);
*mapped_add = 0;
if (ehooks_merge_will_fail(ehooks)) {
return true;
}
edata_t *trail = ecache_alloc(tsdn, shard, ehooks, &shard->ecache_dirty,
trail_begin, trail_size, PAGE, /* slab */ false, SC_NSIZES, zero);
if (trail == NULL) {
trail = ecache_alloc(tsdn, shard, ehooks, &shard->ecache_muzzy,
trail_begin, trail_size, PAGE, /* slab */ false, SC_NSIZES,
zero);
}
if (trail == NULL) {
trail = ecache_alloc_grow(tsdn, shard, ehooks,
&shard->ecache_retained, trail_begin, trail_size, PAGE,
/* slab */ false, SC_NSIZES, zero);
*mapped_add = trail_size;
}
if (trail == NULL) {
*mapped_add = 0;
return true;
}
if (extent_merge_wrapper(tsdn, ehooks, &shard->edata_cache, edata,
trail)) {
extent_dalloc_wrapper(tsdn, shard, ehooks, trail);
*mapped_add = 0;
return true;
}
szind_t szind = sz_size2index(new_usize);
emap_remap(tsdn, &emap_global, edata, szind, /* slab */ false);
return false;
}