MCPcopy Create free account
hub / github.com/Snapchat/KeyDB / malloc_init_hard

Function malloc_init_hard

deps/memkind/src/jemalloc/src/jemalloc.c:1445–1514  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

1443}
1444
1445static bool
1446malloc_init_hard(void) {
1447 tsd_t *tsd;
1448
1449#if defined(_WIN32) && _WIN32_WINNT < 0x0600
1450 _init_init_lock();
1451#endif
1452 malloc_mutex_lock(TSDN_NULL, &init_lock);
1453
1454#define UNLOCK_RETURN(tsdn, ret, reentrancy) \
1455 malloc_init_hard_cleanup(tsdn, reentrancy); \
1456 return ret;
1457
1458 if (!malloc_init_hard_needed()) {
1459 UNLOCK_RETURN(TSDN_NULL, false, false)
1460 }
1461
1462 if (malloc_init_state != malloc_init_a0_initialized &&
1463 malloc_init_hard_a0_locked()) {
1464 UNLOCK_RETURN(TSDN_NULL, true, false)
1465 }
1466
1467 malloc_mutex_unlock(TSDN_NULL, &init_lock);
1468 /* Recursive allocation relies on functional tsd. */
1469 tsd = malloc_tsd_boot0();
1470 if (tsd == NULL) {
1471 return true;
1472 }
1473 if (malloc_init_hard_recursible()) {
1474 return true;
1475 }
1476
1477 malloc_mutex_lock(tsd_tsdn(tsd), &init_lock);
1478 /* Set reentrancy level to 1 during init. */
1479 pre_reentrancy(tsd);
1480 /* Initialize narenas before prof_boot2 (for allocation). */
1481 if (malloc_init_narenas() || background_thread_boot1(tsd_tsdn(tsd))) {
1482 UNLOCK_RETURN(tsd_tsdn(tsd), true, true)
1483 }
1484 if (config_prof && prof_boot2(tsd)) {
1485 UNLOCK_RETURN(tsd_tsdn(tsd), true, true)
1486 }
1487
1488 malloc_init_percpu();
1489
1490 if (malloc_init_hard_finish()) {
1491 UNLOCK_RETURN(tsd_tsdn(tsd), true, true)
1492 }
1493 post_reentrancy(tsd);
1494 malloc_mutex_unlock(tsd_tsdn(tsd), &init_lock);
1495
1496 malloc_tsd_boot1();
1497 /* Update TSD after tsd_boot1. */
1498 tsd = tsd_fetch();
1499 if (opt_background_thread) {
1500 assert(have_background_thread);
1501 /*
1502 * Need to finish init & unlock first before creating background

Callers 1

malloc_initFunction · 0.70

Calls 15

_init_init_lockFunction · 0.70
malloc_init_hard_neededFunction · 0.70
malloc_tsd_boot0Function · 0.70
malloc_init_narenasFunction · 0.70
background_thread_boot1Function · 0.70
prof_boot2Function · 0.70
malloc_init_percpuFunction · 0.70
malloc_init_hard_finishFunction · 0.70
malloc_tsd_boot1Function · 0.70
background_thread_createFunction · 0.70

Tested by

no test coverage detected