From 22a0a7b93a192a07e9a3e5ba9f5adfa64036219e Mon Sep 17 00:00:00 2001 From: David Goldblatt Date: Mon, 9 Mar 2020 12:14:51 -0700 Subject: [PATCH] Move arena_decay_extent to extent module. --- include/jemalloc/internal/arena_inlines_b.h | 23 ------------------ src/extent.c | 26 ++++++++++++++++++++- 2 files changed, 25 insertions(+), 24 deletions(-) diff --git a/include/jemalloc/internal/arena_inlines_b.h b/include/jemalloc/internal/arena_inlines_b.h index fd641754..50223ba7 100644 --- a/include/jemalloc/internal/arena_inlines_b.h +++ b/include/jemalloc/internal/arena_inlines_b.h @@ -140,29 +140,6 @@ arena_decay_tick(tsdn_t *tsdn, arena_t *arena) { arena_decay_ticks(tsdn, arena, 1); } -/* Purge a single extent to retained / unmapped directly. */ -JEMALLOC_ALWAYS_INLINE void -arena_decay_extent(tsdn_t *tsdn,arena_t *arena, ehooks_t *ehooks, - edata_t *edata) { - size_t extent_size = edata_size_get(edata); - extent_dalloc_wrapper(tsdn, arena, ehooks, edata); - if (config_stats) { - /* Update stats accordingly. */ - LOCKEDINT_MTX_LOCK(tsdn, *arena->pa_shard.stats_mtx); - locked_inc_u64(tsdn, - LOCKEDINT_MTX(*arena->pa_shard.stats_mtx), - &arena->pa_shard.stats->decay_dirty.nmadvise, 1); - locked_inc_u64(tsdn, - LOCKEDINT_MTX(*arena->pa_shard.stats_mtx), - &arena->pa_shard.stats->decay_dirty.purged, - extent_size >> LG_PAGE); - locked_dec_zu(tsdn, - LOCKEDINT_MTX(*arena->pa_shard.stats_mtx), - &arena->pa_shard.stats->mapped, extent_size); - LOCKEDINT_MTX_UNLOCK(tsdn, *arena->pa_shard.stats_mtx); - } -} - JEMALLOC_ALWAYS_INLINE void * arena_malloc(tsdn_t *tsdn, arena_t *arena, size_t size, szind_t ind, bool zero, tcache_t *tcache, bool slow_path) { diff --git a/src/extent.c b/src/extent.c index 918738d6..8411e8aa 100644 --- a/src/extent.c +++ b/src/extent.c @@ -954,6 +954,30 @@ extent_try_coalesce_large(tsdn_t *tsdn, edata_cache_t *edata_cache, edata, coalesced, growing_retained, true); } +/* Purge a single extent to retained / unmapped directly. */ +static void +extent_maximally_purge(tsdn_t *tsdn,arena_t *arena, ehooks_t *ehooks, + edata_t *edata) { + size_t extent_size = edata_size_get(edata); + extent_dalloc_wrapper(tsdn, arena, ehooks, edata); + if (config_stats) { + /* Update stats accordingly. */ + LOCKEDINT_MTX_LOCK(tsdn, *arena->pa_shard.stats_mtx); + locked_inc_u64(tsdn, + LOCKEDINT_MTX(*arena->pa_shard.stats_mtx), + &arena->pa_shard.stats->decay_dirty.nmadvise, 1); + locked_inc_u64(tsdn, + LOCKEDINT_MTX(*arena->pa_shard.stats_mtx), + &arena->pa_shard.stats->decay_dirty.purged, + extent_size >> LG_PAGE); + locked_dec_zu(tsdn, + LOCKEDINT_MTX(*arena->pa_shard.stats_mtx), + &arena->pa_shard.stats->mapped, extent_size); + LOCKEDINT_MTX_UNLOCK(tsdn, *arena->pa_shard.stats_mtx); + } +} + + /* * Does the metadata management portions of putting an unused extent into the * given ecache_t (coalesces, deregisters slab interiors, the heap operations). @@ -992,7 +1016,7 @@ extent_record(tsdn_t *tsdn, arena_t *arena, ehooks_t *ehooks, ecache_t *ecache, arena_may_force_decay(arena)) { /* Shortcut to purge the oversize extent eagerly. */ malloc_mutex_unlock(tsdn, &ecache->mtx); - arena_decay_extent(tsdn, arena, ehooks, edata); + extent_maximally_purge(tsdn, arena, ehooks, edata); return; } }