From 38a5bfc8169b018b5b71cc72daad14c3b2f5b206 Mon Sep 17 00:00:00 2001 From: Jason Evans Date: Tue, 7 Mar 2017 19:52:57 -0800 Subject: [PATCH] Move arena_t's purging field into arena_decay_t. --- include/jemalloc/internal/arena_structs_b.h | 12 +++++------- src/arena.c | 9 ++++----- 2 files changed, 9 insertions(+), 12 deletions(-) diff --git a/include/jemalloc/internal/arena_structs_b.h b/include/jemalloc/internal/arena_structs_b.h index 369b4cd2..612b4e7d 100644 --- a/include/jemalloc/internal/arena_structs_b.h +++ b/include/jemalloc/internal/arena_structs_b.h @@ -39,6 +39,11 @@ struct arena_bin_info_s { struct arena_decay_s { /* Synchronizes all non-atomic fields. */ malloc_mutex_t mtx; + /* + * True if a thread is currently purging the extents associated with + * this decay structure. + */ + bool purging; /* * Approximate time in seconds from the creation of a set of unused * dirty pages until an equivalent set of unused dirty pages is purged @@ -199,13 +204,6 @@ struct arena_s { */ arena_decay_t decay; - /* - * True if a thread is currently executing arena_purge_to_limit(). - * - * Synchronization: decay.mtx. - */ - bool purging; - /* * Next extent size class in a growing series to use when satisfying a * request via the extent hooks (only if !config_munmap). This limits diff --git a/src/arena.c b/src/arena.c index ea8e6a55..c253760b 100644 --- a/src/arena.c +++ b/src/arena.c @@ -663,6 +663,7 @@ arena_decay_init(arena_decay_t *decay, extents_t *extents, ssize_t decay_time) { if (malloc_mutex_init(&decay->mtx, "decay", WITNESS_RANK_DECAY)) { return true; } + decay->purging = false; arena_decay_reinit(decay, extents, decay_time); return false; } @@ -812,10 +813,10 @@ arena_purge_to_limit(tsdn_t *tsdn, arena_t *arena, arena_decay_t *decay, witness_assert_depth_to_rank(tsdn, WITNESS_RANK_CORE, 1); malloc_mutex_assert_owner(tsdn, &decay->mtx); - if (arena->purging) { + if (decay->purging) { return; } - arena->purging = true; + decay->purging = true; extent_hooks_t *extent_hooks = extent_hooks_get(arena); size_t npurge, npurged; @@ -845,7 +846,7 @@ arena_purge_to_limit(tsdn_t *tsdn, arena_t *arena, arena_decay_t *decay, } label_return: - arena->purging = false; + decay->purging = false; } void @@ -1747,8 +1748,6 @@ arena_new(tsdn_t *tsdn, unsigned ind, extent_hooks_t *extent_hooks) { goto label_error; } - arena->purging = false; - if (!config_munmap) { arena->extent_grow_next = psz2ind(HUGEPAGE); }