diff --git a/include/jemalloc/internal/pa.h b/include/jemalloc/internal/pa.h index 4bdd8ac1..b3fc8e2b 100644 --- a/include/jemalloc/internal/pa.h +++ b/include/jemalloc/internal/pa.h @@ -113,7 +113,7 @@ void pa_shard_reset(pa_shard_t *shard); * decaying all active, dirty, and muzzy extents to the retained state, as the * last step in destroying the shard. */ -void pa_shard_destroy_retained(tsdn_t *tsdn, pa_shard_t *shard); +void pa_shard_destroy(tsdn_t *tsdn, pa_shard_t *shard); /* Gets an edata for the given allocation. */ edata_t *pa_alloc(tsdn_t *tsdn, pa_shard_t *shard, size_t size, diff --git a/include/jemalloc/internal/pac.h b/include/jemalloc/internal/pac.h index de01c519..302ac078 100644 --- a/include/jemalloc/internal/pac.h +++ b/include/jemalloc/internal/pac.h @@ -153,4 +153,8 @@ bool pac_retain_grow_limit_get_set(tsdn_t *tsdn, pac_t *pac, size_t *old_limit, bool pac_decay_ms_set(tsdn_t *tsdn, pac_t *pac, extent_state_t state, ssize_t decay_ms, pac_purge_eagerness_t eagerness); ssize_t pac_decay_ms_get(pac_t *pac, extent_state_t state); + +void pac_reset(tsdn_t *tsdn, pac_t *pac); +void pac_destroy(tsdn_t *tsdn, pac_t *pac); + #endif /* JEMALLOC_INTERNAL_PAC_H */ diff --git a/src/arena.c b/src/arena.c index 2bf02de6..46da3859 100644 --- a/src/arena.c +++ b/src/arena.c @@ -645,7 +645,7 @@ arena_destroy(tsd_t *tsd, arena_t *arena) { * extents, so only retained extents may remain and it's safe to call * pa_shard_destroy_retained. */ - pa_shard_destroy_retained(tsd_tsdn(tsd), &arena->pa_shard); + pa_shard_destroy(tsd_tsdn(tsd), &arena->pa_shard); /* * Remove the arena pointer from the arenas array. We rely on the fact diff --git a/src/pa.c b/src/pa.c index 444ea5be..6a3db3c6 100644 --- a/src/pa.c +++ b/src/pa.c @@ -58,24 +58,8 @@ pa_shard_reset(pa_shard_t *shard) { } void -pa_shard_destroy_retained(tsdn_t *tsdn, pa_shard_t *shard) { - assert(ecache_npages_get(&shard->pac.ecache_dirty) == 0); - assert(ecache_npages_get(&shard->pac.ecache_muzzy) == 0); - /* - * Iterate over the retained extents and destroy them. This gives the - * extent allocator underlying the extent hooks an opportunity to unmap - * all retained memory without having to keep its own metadata - * structures. In practice, virtual memory for dss-allocated extents is - * leaked here, so best practice is to avoid dss for arenas to be - * destroyed, or provide custom extent hooks that track retained - * dss-based extents for later reuse. - */ - ehooks_t *ehooks = pa_shard_ehooks_get(shard); - edata_t *edata; - while ((edata = ecache_evict(tsdn, &shard->pac, ehooks, - &shard->pac.ecache_retained, 0)) != NULL) { - extent_destroy_wrapper(tsdn, &shard->pac, ehooks, edata); - } +pa_shard_destroy(tsdn_t *tsdn, pa_shard_t *shard) { + pac_destroy(tsdn, &shard->pac); } static inline bool diff --git a/src/pac.c b/src/pac.c index bc9f7433..ed17a2f5 100644 --- a/src/pac.c +++ b/src/pac.c @@ -321,3 +321,34 @@ pac_decay_ms_get(pac_t *pac, extent_state_t state) { pac_decay_data_get(pac, state, &decay, &decay_stats, &ecache); return decay_ms_read(decay); } + +void +pac_reset(tsdn_t *tsdn, pac_t *pac) { + /* + * No-op for now; purging is still done at the arena-level. It should + * get moved in here, though. + */ + (void)tsdn; + (void)pac; +} + +void +pac_destroy(tsdn_t *tsdn, pac_t *pac) { + assert(ecache_npages_get(&pac->ecache_dirty) == 0); + assert(ecache_npages_get(&pac->ecache_muzzy) == 0); + /* + * Iterate over the retained extents and destroy them. This gives the + * extent allocator underlying the extent hooks an opportunity to unmap + * all retained memory without having to keep its own metadata + * structures. In practice, virtual memory for dss-allocated extents is + * leaked here, so best practice is to avoid dss for arenas to be + * destroyed, or provide custom extent hooks that track retained + * dss-based extents for later reuse. + */ + ehooks_t *ehooks = pac_ehooks_get(pac); + edata_t *edata; + while ((edata = ecache_evict(tsdn, pac, ehooks, + &pac->ecache_retained, 0)) != NULL) { + extent_destroy_wrapper(tsdn, pac, ehooks, edata); + } +}