From e77f47a85a5e48894065852cbafef3d78724acef Mon Sep 17 00:00:00 2001 From: David Goldblatt Date: Tue, 10 Mar 2020 11:04:02 -0700 Subject: [PATCH] Move arena decay getters to PA. --- include/jemalloc/internal/arena_inlines_b.h | 6 ------ include/jemalloc/internal/pa.h | 15 +++++++++++++++ src/arena.c | 4 ++-- src/extent.c | 2 +- 4 files changed, 18 insertions(+), 9 deletions(-) diff --git a/include/jemalloc/internal/arena_inlines_b.h b/include/jemalloc/internal/arena_inlines_b.h index 8b77a335..565e2262 100644 --- a/include/jemalloc/internal/arena_inlines_b.h +++ b/include/jemalloc/internal/arena_inlines_b.h @@ -108,12 +108,6 @@ arena_prof_info_set(tsd_t *tsd, edata_t *edata, prof_tctx_t *tctx) { large_prof_info_set(edata, tctx); } -JEMALLOC_ALWAYS_INLINE bool -arena_may_force_decay(arena_t *arena) { - return !(arena_dirty_decay_ms_get(arena) == -1 - || arena_muzzy_decay_ms_get(arena) == -1); -} - JEMALLOC_ALWAYS_INLINE void arena_decay_ticks(tsdn_t *tsdn, arena_t *arena, unsigned nticks) { tsd_t *tsd; diff --git a/include/jemalloc/internal/pa.h b/include/jemalloc/internal/pa.h index d686652a..655e46b4 100644 --- a/include/jemalloc/internal/pa.h +++ b/include/jemalloc/internal/pa.h @@ -90,6 +90,21 @@ pa_shard_stats_mapped_add(tsdn_t *tsdn, pa_shard_t *shard, size_t size) { LOCKEDINT_MTX_UNLOCK(tsdn, *shard->stats_mtx); } +static inline ssize_t +pa_shard_dirty_decay_ms_get(pa_shard_t *shard) { + return decay_ms_read(&shard->decay_dirty); +} +static inline ssize_t +pa_shard_muzzy_decay_ms_get(pa_shard_t *shard) { + return decay_ms_read(&shard->decay_muzzy); +} + +static inline bool +pa_shard_may_force_decay(pa_shard_t *shard) { + return !(pa_shard_dirty_decay_ms_get(shard) == -1 + || pa_shard_muzzy_decay_ms_get(shard) == -1); +} + /* Returns true on error. */ bool pa_shard_init(tsdn_t *tsdn, pa_shard_t *shard, base_t *base, unsigned ind, pa_shard_stats_t *stats, malloc_mutex_t *stats_mtx); diff --git a/src/arena.c b/src/arena.c index 16be6b1e..f1ee25a7 100644 --- a/src/arena.c +++ b/src/arena.c @@ -595,12 +595,12 @@ arena_maybe_decay(tsdn_t *tsdn, arena_t *arena, decay_t *decay, ssize_t arena_dirty_decay_ms_get(arena_t *arena) { - return decay_ms_read(&arena->pa_shard.decay_dirty); + return pa_shard_dirty_decay_ms_get(&arena->pa_shard); } ssize_t arena_muzzy_decay_ms_get(arena_t *arena) { - return decay_ms_read(&arena->pa_shard.decay_muzzy); + return pa_shard_muzzy_decay_ms_get(&arena->pa_shard); } static bool diff --git a/src/extent.c b/src/extent.c index 0162494e..3d8af3d6 100644 --- a/src/extent.c +++ b/src/extent.c @@ -1013,7 +1013,7 @@ extent_record(tsdn_t *tsdn, arena_t *arena, ehooks_t *ehooks, ecache_t *ecache, &coalesced, growing_retained); } while (coalesced); if (edata_size_get(edata) >= oversize_threshold && - arena_may_force_decay(arena)) { + pa_shard_may_force_decay(&arena->pa_shard)) { /* Shortcut to purge the oversize extent eagerly. */ malloc_mutex_unlock(tsdn, &ecache->mtx); extent_maximally_purge(tsdn, arena, ehooks, edata);