mirror of
https://github.com/jemalloc/jemalloc.git
synced 2026-08-25 00:23:33 +03:00
Add basic reentrancy-checking support, and allow arena_new to reenter.
This checks whether or not we're reentrant using thread-local data, and, if we are, moves certain internal allocations to use arena 0 (which should be properly initialized after bootstrapping). The immediate thing this allows is spinning up threads in arena_new, which will enable spinning up background threads there.
This commit is contained in:
parent
0a0fcd3e6a
commit
b407a65401
10 changed files with 170 additions and 47 deletions
13
src/arena.c
13
src/arena.c
|
|
@ -1952,6 +1952,19 @@ arena_new(tsdn_t *tsdn, unsigned ind, extent_hooks_t *extent_hooks) {
|
|||
|
||||
arena->base = base;
|
||||
|
||||
/* We don't support reetrancy for arena 0 bootstrapping. */
|
||||
if (ind != 0 && hooks_arena_new_hook) {
|
||||
/*
|
||||
* If we're here, then arena 0 already exists, so bootstrapping
|
||||
* is done enough that we should have tsd.
|
||||
*/
|
||||
int *reentrancy_level = tsd_reentrancy_levelp_get(tsdn_tsd(
|
||||
tsdn));
|
||||
++*reentrancy_level;
|
||||
hooks_arena_new_hook();
|
||||
--*reentrancy_level;
|
||||
}
|
||||
|
||||
return arena;
|
||||
label_error:
|
||||
if (ind != 0) {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue