diff options
author | Jason Evans <jasone@canonware.com> | 2016-04-22 21:34:14 (GMT) |
---|---|---|
committer | Jason Evans <jasone@canonware.com> | 2016-04-22 22:19:59 (GMT) |
commit | 66cd953514a18477eb49732e40d5c2ab5f1b12c5 (patch) | |
tree | 0e684f2cacc80f4bd2f7056622b36c71a568dee2 /src/tcache.c | |
parent | c9a4bf91702b351e73e2cd7cf9125afd076d59fe (diff) | |
download | jemalloc-66cd953514a18477eb49732e40d5c2ab5f1b12c5.zip jemalloc-66cd953514a18477eb49732e40d5c2ab5f1b12c5.tar.gz jemalloc-66cd953514a18477eb49732e40d5c2ab5f1b12c5.tar.bz2 |
Do not allocate metadata via non-auto arenas, nor tcaches.
This assures that all internally allocated metadata come from the
first opt_narenas arenas, i.e. the automatically multiplexed arenas.
Diffstat (limited to 'src/tcache.c')
-rw-r--r-- | src/tcache.c | 20 |
1 files changed, 12 insertions, 8 deletions
diff --git a/src/tcache.c b/src/tcache.c index a9539f6..ca867c7 100644 --- a/src/tcache.c +++ b/src/tcache.c @@ -97,7 +97,7 @@ tcache_bin_flush_small(tsd_t *tsd, tcache_t *tcache, tcache_bin_t *tbin, assert(binind < NBINS); assert(rem <= tbin->ncached); - arena = arena_choose(tsd, NULL); + arena = arena_choose(tsd, NULL, false); assert(arena != NULL); for (nflush = tbin->ncached - rem; nflush > 0; nflush = ndeferred) { /* Lock the arena bin associated with the first object. */ @@ -179,7 +179,7 @@ tcache_bin_flush_large(tsd_t *tsd, tcache_bin_t *tbin, szind_t binind, assert(binind < nhbins); assert(rem <= tbin->ncached); - arena = arena_choose(tsd, NULL); + arena = arena_choose(tsd, NULL, false); assert(arena != NULL); for (nflush = tbin->ncached - rem; nflush > 0; nflush = ndeferred) { /* Lock the arena associated with the first object. */ @@ -307,7 +307,7 @@ tcache_get_hard(tsd_t *tsd) tcache_enabled_set(false); /* Memoize. */ return (NULL); } - arena = arena_choose(tsd, NULL); + arena = arena_choose(tsd, NULL, false); if (unlikely(arena == NULL)) return (NULL); return (tcache_create(tsd, arena)); @@ -328,8 +328,8 @@ tcache_create(tsd_t *tsd, arena_t *arena) /* Avoid false cacheline sharing. */ size = sa2u(size, CACHELINE); - tcache = ipallocztm(tsd, size, CACHELINE, true, false, true, - arena_get(tsd, 0, false)); + tcache = ipallocztm(tsd, size, CACHELINE, true, NULL, true, + arena_get(NULL, 0, true)); if (tcache == NULL) return (NULL); @@ -359,7 +359,7 @@ tcache_destroy(tsd_t *tsd, tcache_t *tcache) arena_t *arena; unsigned i; - arena = arena_choose(tsd, NULL); + arena = arena_choose(tsd, NULL, false); tcache_arena_dissociate(tsd, tcache, arena); for (i = 0; i < NBINS; i++) { @@ -391,7 +391,7 @@ tcache_destroy(tsd_t *tsd, tcache_t *tcache) arena_prof_accum(tsd, arena, tcache->prof_accumbytes)) prof_idump(tsd); - idalloctm(tsd, tcache, false, true, true); + idalloctm(tsd, tcache, NULL, true, true); } void @@ -446,6 +446,7 @@ tcache_stats_merge(tsd_t *tsd, tcache_t *tcache, arena_t *arena) bool tcaches_create(tsd_t *tsd, unsigned *r_ind) { + arena_t *arena; tcache_t *tcache; tcaches_t *elm; @@ -458,7 +459,10 @@ tcaches_create(tsd_t *tsd, unsigned *r_ind) if (tcaches_avail == NULL && tcaches_past > MALLOCX_TCACHE_MAX) return (true); - tcache = tcache_create(tsd, arena_get(tsd, 0, false)); + arena = arena_choose(tsd, NULL, true); + if (unlikely(arena == NULL)) + return (true); + tcache = tcache_create(tsd, arena); if (tcache == NULL) return (true); |