MCPcopy Create free account
hub / github.com/F-Stack/f-stack / jemalloc_prefork

Function jemalloc_prefork

app/redis-6.2.6/deps/jemalloc/src/jemalloc.c:3189–3259  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

3187
3188#ifndef JEMALLOC_MUTEX_INIT_CB
3189void
3190jemalloc_prefork(void)
3191#else
3192JEMALLOC_EXPORT void
3193_malloc_prefork(void)
3194#endif
3195{
3196 tsd_t *tsd;
3197 unsigned i, j, narenas;
3198 arena_t *arena;
3199
3200#ifdef JEMALLOC_MUTEX_INIT_CB
3201 if (!malloc_initialized()) {
3202 return;
3203 }
3204#endif
3205 assert(malloc_initialized());
3206
3207 tsd = tsd_fetch();
3208
3209 narenas = narenas_total_get();
3210
3211 witness_prefork(tsd_witness_tsdp_get(tsd));
3212 /* Acquire all mutexes in a safe order. */
3213 ctl_prefork(tsd_tsdn(tsd));
3214 tcache_prefork(tsd_tsdn(tsd));
3215 malloc_mutex_prefork(tsd_tsdn(tsd), &arenas_lock);
3216 if (have_background_thread) {
3217 background_thread_prefork0(tsd_tsdn(tsd));
3218 }
3219 prof_prefork0(tsd_tsdn(tsd));
3220 if (have_background_thread) {
3221 background_thread_prefork1(tsd_tsdn(tsd));
3222 }
3223 /* Break arena prefork into stages to preserve lock order. */
3224 for (i = 0; i < 8; i++) {
3225 for (j = 0; j < narenas; j++) {
3226 if ((arena = arena_get(tsd_tsdn(tsd), j, false)) !=
3227 NULL) {
3228 switch (i) {
3229 case 0:
3230 arena_prefork0(tsd_tsdn(tsd), arena);
3231 break;
3232 case 1:
3233 arena_prefork1(tsd_tsdn(tsd), arena);
3234 break;
3235 case 2:
3236 arena_prefork2(tsd_tsdn(tsd), arena);
3237 break;
3238 case 3:
3239 arena_prefork3(tsd_tsdn(tsd), arena);
3240 break;
3241 case 4:
3242 arena_prefork4(tsd_tsdn(tsd), arena);
3243 break;
3244 case 5:
3245 arena_prefork5(tsd_tsdn(tsd), arena);
3246 break;

Callers 1

zone_force_lockFunction · 0.85

Calls 15

malloc_initializedFunction · 0.85
tsd_fetchFunction · 0.85
narenas_total_getFunction · 0.85
witness_preforkFunction · 0.85
ctl_preforkFunction · 0.85
tsd_tsdnFunction · 0.85
tcache_preforkFunction · 0.85
malloc_mutex_preforkFunction · 0.85
prof_prefork0Function · 0.85
arena_getFunction · 0.85

Tested by

no test coverage detected