diff options
author | Qi Wang <interwq@gwu.edu> | 2017-10-04 23:39:33 (GMT) |
---|---|---|
committer | Qi Wang <interwq@gmail.com> | 2017-10-06 05:57:56 (GMT) |
commit | a2e6eb2c226ff63397220517883e13717f97da05 (patch) | |
tree | 83128a7f701d10cecf990e6bd9ee593cfe5b8868 /src/jemalloc.c | |
parent | 79e83451ff262fbc4bf66059eae672286b5eb9f0 (diff) | |
download | jemalloc-a2e6eb2c226ff63397220517883e13717f97da05.zip jemalloc-a2e6eb2c226ff63397220517883e13717f97da05.tar.gz jemalloc-a2e6eb2c226ff63397220517883e13717f97da05.tar.bz2 |
Delay background_thread_ctl_init to right before thread creation.
ctl_init sets isthreaded, which means it should be done without holding any
locks.
Diffstat (limited to 'src/jemalloc.c')
-rw-r--r-- | src/jemalloc.c | 7 |
1 files changed, 6 insertions, 1 deletions
diff --git a/src/jemalloc.c b/src/jemalloc.c index 28e604b..f29fc7d 100644 --- a/src/jemalloc.c +++ b/src/jemalloc.c @@ -1522,6 +1522,8 @@ malloc_init_hard(void) { post_reentrancy(tsd); malloc_mutex_unlock(tsd_tsdn(tsd), &init_lock); + witness_assert_lockless(witness_tsd_tsdn( + tsd_witness_tsdp_get_unsafe(tsd))); malloc_tsd_boot1(); /* Update TSD after tsd_boot1. */ tsd = tsd_fetch(); @@ -1529,8 +1531,11 @@ malloc_init_hard(void) { assert(have_background_thread); /* * Need to finish init & unlock first before creating background - * threads (pthread_create depends on malloc). + * threads (pthread_create depends on malloc). ctl_init (which + * sets isthreaded) needs to be called without holding any lock. */ + background_thread_ctl_init(tsd_tsdn(tsd)); + malloc_mutex_lock(tsd_tsdn(tsd), &background_thread_lock); bool err = background_thread_create(tsd, 0); malloc_mutex_unlock(tsd_tsdn(tsd), &background_thread_lock); |