From faec7219b23303ec812e9aee6fc35352f936d10b Mon Sep 17 00:00:00 2001 From: David Goldblatt Date: Thu, 12 Mar 2020 16:06:40 -0700 Subject: [PATCH] PA: Move in decay initialization. --- include/jemalloc/internal/pa.h | 3 ++- src/arena.c | 14 +++----------- src/pa.c | 10 +++++++++- 3 files changed, 14 insertions(+), 13 deletions(-) diff --git a/include/jemalloc/internal/pa.h b/include/jemalloc/internal/pa.h index ec6c8048..82676ee4 100644 --- a/include/jemalloc/internal/pa.h +++ b/include/jemalloc/internal/pa.h @@ -172,7 +172,8 @@ pa_shard_ehooks_get(pa_shard_t *shard) { /* 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); + pa_shard_stats_t *stats, malloc_mutex_t *stats_mtx, nstime_t *cur_time, + ssize_t dirty_decay_ms, ssize_t muzzy_decay_ms); /* * This does the PA-specific parts of arena reset (i.e. freeing all active * allocations). diff --git a/src/arena.c b/src/arena.c index 178cc9a9..fd19e770 100644 --- a/src/arena.c +++ b/src/arena.c @@ -1487,19 +1487,11 @@ arena_new(tsdn_t *tsdn, unsigned ind, extent_hooks_t *extent_hooks) { goto label_error; } - if (pa_shard_init(tsdn, &arena->pa_shard, base, ind, - &arena->stats.pa_shard_stats, LOCKEDINT_MTX(arena->stats.mtx))) { - goto label_error; - } - nstime_t cur_time; nstime_init_update(&cur_time); - - if (decay_init(&arena->pa_shard.decay_dirty, &cur_time, - arena_dirty_decay_ms_default_get())) { - goto label_error; - } - if (decay_init(&arena->pa_shard.decay_muzzy, &cur_time, + if (pa_shard_init(tsdn, &arena->pa_shard, base, ind, + &arena->stats.pa_shard_stats, LOCKEDINT_MTX(arena->stats.mtx), + &cur_time, arena_dirty_decay_ms_default_get(), arena_muzzy_decay_ms_default_get())) { goto label_error; } diff --git a/src/pa.c b/src/pa.c index d4949f5e..a1063b9e 100644 --- a/src/pa.c +++ b/src/pa.c @@ -14,7 +14,8 @@ pa_nactive_sub(pa_shard_t *shard, size_t sub_pages) { 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) { + pa_shard_stats_t *stats, malloc_mutex_t *stats_mtx, nstime_t *cur_time, + ssize_t dirty_decay_ms, ssize_t muzzy_decay_ms) { /* This will change eventually, but for now it should hold. */ assert(base_ind_get(base) == ind); /* @@ -53,6 +54,13 @@ pa_shard_init(tsdn_t *tsdn, pa_shard_t *shard, base_t *base, unsigned ind, return true; } + if (decay_init(&shard->decay_dirty, cur_time, dirty_decay_ms)) { + return true; + } + if (decay_init(&shard->decay_muzzy, cur_time, muzzy_decay_ms)) { + return true; + } + atomic_store_zu(&shard->extent_sn_next, 0, ATOMIC_RELAXED); atomic_store_zu(&shard->nactive, 0, ATOMIC_RELAXED);