mirror of
https://github.com/jemalloc/jemalloc.git
synced 2026-08-24 16:13:38 +03:00
Refactor arenas array (fixes deadlock).
Refactor the arenas array, which contains pointers to all extant arenas, such that it starts out as a sparse array of maximum size, and use double-checked atomics-based reads as the basis for fast and simple arena_get(). Additionally, reduce arenas_lock's role such that it only protects against arena initalization races. These changes remove the possibility for arena lookups to trigger locking, which resolves at least one known (fork-related) deadlock. This resolves #315.
This commit is contained in:
parent
3812729167
commit
767d85061a
9 changed files with 162 additions and 214 deletions
|
|
@ -325,7 +325,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, a0get());
|
||||
tcache = ipallocztm(tsd, size, CACHELINE, true, false, true,
|
||||
arena_get(0, false));
|
||||
if (tcache == NULL)
|
||||
return (NULL);
|
||||
|
||||
|
|
@ -453,7 +454,7 @@ tcaches_create(tsd_t *tsd, unsigned *r_ind)
|
|||
|
||||
if (tcaches_avail == NULL && tcaches_past > MALLOCX_TCACHE_MAX)
|
||||
return (true);
|
||||
tcache = tcache_create(tsd, a0get());
|
||||
tcache = tcache_create(tsd, arena_get(0, false));
|
||||
if (tcache == NULL)
|
||||
return (true);
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue