PA -> PAC: Move in destruction functions.
This commit is contained in:
parent
cbf096b05e
commit
6041aaba97
@ -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
|
* decaying all active, dirty, and muzzy extents to the retained state, as the
|
||||||
* last step in destroying the shard.
|
* 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. */
|
/* Gets an edata for the given allocation. */
|
||||||
edata_t *pa_alloc(tsdn_t *tsdn, pa_shard_t *shard, size_t size,
|
edata_t *pa_alloc(tsdn_t *tsdn, pa_shard_t *shard, size_t size,
|
||||||
|
@ -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,
|
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 decay_ms, pac_purge_eagerness_t eagerness);
|
||||||
ssize_t pac_decay_ms_get(pac_t *pac, extent_state_t state);
|
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 */
|
#endif /* JEMALLOC_INTERNAL_PAC_H */
|
||||||
|
@ -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
|
* extents, so only retained extents may remain and it's safe to call
|
||||||
* pa_shard_destroy_retained.
|
* 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
|
* Remove the arena pointer from the arenas array. We rely on the fact
|
||||||
|
20
src/pa.c
20
src/pa.c
@ -58,24 +58,8 @@ pa_shard_reset(pa_shard_t *shard) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
pa_shard_destroy_retained(tsdn_t *tsdn, pa_shard_t *shard) {
|
pa_shard_destroy(tsdn_t *tsdn, pa_shard_t *shard) {
|
||||||
assert(ecache_npages_get(&shard->pac.ecache_dirty) == 0);
|
pac_destroy(tsdn, &shard->pac);
|
||||||
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);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static inline bool
|
static inline bool
|
||||||
|
31
src/pac.c
31
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);
|
pac_decay_data_get(pac, state, &decay, &decay_stats, &ecache);
|
||||||
return decay_ms_read(decay);
|
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);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user