Properly trigger decay on tcache destory.
When destroying tcache, decay may not be triggered since tsd is non-nominal. Explicitly decay to avoid pathological cases.
This commit is contained in:
parent
d66f976628
commit
7ee0b6cc37
18
src/tcache.c
18
src/tcache.c
@ -497,6 +497,7 @@ tcache_flush(tsd_t *tsd) {
|
|||||||
static void
|
static void
|
||||||
tcache_destroy(tsd_t *tsd, tcache_t *tcache, bool tsd_tcache) {
|
tcache_destroy(tsd_t *tsd, tcache_t *tcache, bool tsd_tcache) {
|
||||||
tcache_flush_cache(tsd, tcache);
|
tcache_flush_cache(tsd, tcache);
|
||||||
|
arena_t *arena = tcache->arena;
|
||||||
tcache_arena_dissociate(tsd_tsdn(tsd), tcache);
|
tcache_arena_dissociate(tsd_tsdn(tsd), tcache);
|
||||||
|
|
||||||
if (tsd_tcache) {
|
if (tsd_tcache) {
|
||||||
@ -509,6 +510,23 @@ tcache_destroy(tsd_t *tsd, tcache_t *tcache, bool tsd_tcache) {
|
|||||||
/* Release both the tcache struct and avail array. */
|
/* Release both the tcache struct and avail array. */
|
||||||
idalloctm(tsd_tsdn(tsd), tcache, NULL, NULL, true, true);
|
idalloctm(tsd_tsdn(tsd), tcache, NULL, NULL, true, true);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
* The deallocation and tcache flush above may not trigger decay since
|
||||||
|
* we are on the tcache shutdown path (potentially with non-nominal
|
||||||
|
* tsd). Manually trigger decay to avoid pathological cases. Also
|
||||||
|
* include arena 0 because the tcache array is allocated from it.
|
||||||
|
*/
|
||||||
|
arena_decay(tsd_tsdn(tsd), arena_get(tsd_tsdn(tsd), 0, false),
|
||||||
|
false, false);
|
||||||
|
|
||||||
|
unsigned nthreads = arena_nthreads_get(arena, false);
|
||||||
|
if (nthreads == 0) {
|
||||||
|
/* Force purging when no threads assigned to the arena anymore. */
|
||||||
|
arena_decay(tsd_tsdn(tsd), arena, false, true);
|
||||||
|
} else {
|
||||||
|
arena_decay(tsd_tsdn(tsd), arena, false, false);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/* For auto tcache (embedded in TSD) only. */
|
/* For auto tcache (embedded in TSD) only. */
|
||||||
|
Loading…
Reference in New Issue
Block a user