PA: Move in retain growth limit setting.

This commit is contained in:
David Goldblatt 2020-03-12 15:51:13 -07:00 committed by David Goldblatt
parent daefde88fe
commit 45671e4a27
3 changed files with 38 additions and 20 deletions

View File

@ -230,6 +230,18 @@ bool pa_maybe_decay_purge(tsdn_t *tsdn, pa_shard_t *shard, decay_t *decay,
pa_shard_decay_stats_t *decay_stats, ecache_t *ecache,
pa_decay_purge_setting_t decay_purge_setting);
/*
* Gets / sets the maximum amount that we'll grow an arena down the
* grow-retained pathways (unless forced to by an allocaction request).
*
* Set new_limit to NULL if it's just a query, or old_limit to NULL if you don't
* care about the previous value.
*
* Returns true on error (if the new limit is not valid).
*/
bool pa_shard_retain_grow_limit_get_set(tsdn_t *tsdn, pa_shard_t *shard,
size_t *old_limit, size_t *new_limit);
/******************************************************************************/
/*
* Various bits of "boring" functionality that are still part of this module,

View File

@ -1411,26 +1411,8 @@ bool
arena_retain_grow_limit_get_set(tsd_t *tsd, arena_t *arena, size_t *old_limit,
size_t *new_limit) {
assert(opt_retain);
pszind_t new_ind JEMALLOC_CC_SILENCE_INIT(0);
if (new_limit != NULL) {
size_t limit = *new_limit;
/* Grow no more than the new limit. */
if ((new_ind = sz_psz2ind(limit + 1) - 1) >= SC_NPSIZES) {
return true;
}
}
malloc_mutex_lock(tsd_tsdn(tsd), &arena->pa_shard.ecache_grow.mtx);
if (old_limit != NULL) {
*old_limit = sz_pind2sz(arena->pa_shard.ecache_grow.limit);
}
if (new_limit != NULL) {
arena->pa_shard.ecache_grow.limit = new_ind;
}
malloc_mutex_unlock(tsd_tsdn(tsd), &arena->pa_shard.ecache_grow.mtx);
return false;
return pa_shard_retain_grow_limit_get_set(tsd_tsdn(tsd),
&arena->pa_shard, old_limit, new_limit);
}
unsigned

View File

@ -395,3 +395,27 @@ pa_maybe_decay_purge(tsdn_t *tsdn, pa_shard_t *shard, decay_t *decay,
return epoch_advanced;
}
bool
pa_shard_retain_grow_limit_get_set(tsdn_t *tsdn, pa_shard_t *shard,
size_t *old_limit, size_t *new_limit) {
pszind_t new_ind JEMALLOC_CC_SILENCE_INIT(0);
if (new_limit != NULL) {
size_t limit = *new_limit;
/* Grow no more than the new limit. */
if ((new_ind = sz_psz2ind(limit + 1) - 1) >= SC_NPSIZES) {
return true;
}
}
malloc_mutex_lock(tsdn, &shard->ecache_grow.mtx);
if (old_limit != NULL) {
*old_limit = sz_pind2sz(shard->ecache_grow.limit);
}
if (new_limit != NULL) {
shard->ecache_grow.limit = new_ind;
}
malloc_mutex_unlock(tsdn, &shard->ecache_grow.mtx);
return false;
}