diff --git a/jemalloc/src/internal/prof.h b/jemalloc/src/internal/prof.h index 1721ad8b..1d562071 100644 --- a/jemalloc/src/internal/prof.h +++ b/jemalloc/src/internal/prof.h @@ -135,6 +135,7 @@ void prof_mdump(void); void prof_udump(void); void prof_boot0(void); bool prof_boot1(void); +void prof_boot2(void); #endif /* JEMALLOC_H_EXTERNS */ /******************************************************************************/ diff --git a/jemalloc/src/jemalloc.c b/jemalloc/src/jemalloc.c index f035d23d..6a3f53e5 100644 --- a/jemalloc/src/jemalloc.c +++ b/jemalloc/src/jemalloc.c @@ -636,10 +636,6 @@ MALLOC_OUT: } } -#ifdef JEMALLOC_PROF - prof_boot0(); -#endif - /* Register fork handlers. */ if (pthread_atfork(jemalloc_prefork, jemalloc_postfork, jemalloc_postfork) != 0) { @@ -682,6 +678,10 @@ MALLOC_OUT: return (true); } +#ifdef JEMALLOC_PROF + prof_boot0(); +#endif + if (arena_boot()) { malloc_mutex_unlock(&init_lock); return (true); @@ -725,6 +725,13 @@ MALLOC_OUT: malloc_mutex_init(&arenas_lock); +#ifdef JEMALLOC_PROF + if (prof_boot1()) { + malloc_mutex_unlock(&init_lock); + return (true); + } +#endif + /* Get number of CPUs. */ malloc_initializer = pthread_self(); malloc_mutex_unlock(&init_lock); @@ -816,10 +823,7 @@ MALLOC_OUT: #endif #ifdef JEMALLOC_PROF - if (prof_boot1()) { - malloc_mutex_unlock(&init_lock); - return (true); - } + prof_boot2(); #endif /* Allocate and initialize arenas. */ diff --git a/jemalloc/src/prof.c b/jemalloc/src/prof.c index db56659b..85b70203 100644 --- a/jemalloc/src/prof.c +++ b/jemalloc/src/prof.c @@ -1043,11 +1043,6 @@ prof_boot1(void) { if (opt_prof) { - /* - * Finish initializing prof_interval, now that narenas is set. - */ - prof_interval /= narenas; - if (ckh_new(&bt2ctx, PROF_CKH_MINITEMS, prof_bt_hash, prof_bt_keycomp)) return (true); @@ -1090,5 +1085,17 @@ prof_boot1(void) return (false); } +void +prof_boot2(void) +{ + + if (opt_prof) { + /* + * Finish initializing prof_interval, now that narenas is set. + */ + prof_interval /= narenas; + } +} + /******************************************************************************/ #endif /* JEMALLOC_PROF */