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

Function malloc_init_hard

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

Source from the content-addressed store, hash-verified

1497}
1498
1499static bool
1500malloc_init_hard(void) {
1501 tsd_t *tsd;
1502
1503#if defined(_WIN32) && _WIN32_WINNT < 0x0600
1504 _init_init_lock();
1505#endif
1506 malloc_mutex_lock(TSDN_NULL, &init_lock);
1507
1508#define UNLOCK_RETURN(tsdn, ret, reentrancy) \
1509 malloc_init_hard_cleanup(tsdn, reentrancy); \
1510 return ret;
1511
1512 if (!malloc_init_hard_needed()) {
1513 UNLOCK_RETURN(TSDN_NULL, false, false)
1514 }
1515
1516 if (malloc_init_state != malloc_init_a0_initialized &&
1517 malloc_init_hard_a0_locked()) {
1518 UNLOCK_RETURN(TSDN_NULL, true, false)
1519 }
1520
1521 malloc_mutex_unlock(TSDN_NULL, &init_lock);
1522 /* Recursive allocation relies on functional tsd. */
1523 tsd = malloc_tsd_boot0();
1524 if (tsd == NULL) {
1525 return true;
1526 }
1527 if (malloc_init_hard_recursible()) {
1528 return true;
1529 }
1530
1531 malloc_mutex_lock(tsd_tsdn(tsd), &init_lock);
1532 /* Set reentrancy level to 1 during init. */
1533 pre_reentrancy(tsd, NULL);
1534 /* Initialize narenas before prof_boot2 (for allocation). */
1535 if (malloc_init_narenas() || background_thread_boot1(tsd_tsdn(tsd))) {
1536 UNLOCK_RETURN(tsd_tsdn(tsd), true, true)
1537 }
1538 if (config_prof && prof_boot2(tsd)) {
1539 UNLOCK_RETURN(tsd_tsdn(tsd), true, true)
1540 }
1541
1542 malloc_init_percpu();
1543
1544 if (malloc_init_hard_finish()) {
1545 UNLOCK_RETURN(tsd_tsdn(tsd), true, true)
1546 }
1547 post_reentrancy(tsd);
1548 malloc_mutex_unlock(tsd_tsdn(tsd), &init_lock);
1549
1550 witness_assert_lockless(witness_tsd_tsdn(
1551 tsd_witness_tsdp_get_unsafe(tsd)));
1552 malloc_tsd_boot1();
1553 /* Update TSD after tsd_boot1. */
1554 tsd = tsd_fetch();
1555 if (opt_background_thread) {
1556 assert(have_background_thread);

Callers 1

malloc_initFunction · 0.85

Calls 15

_init_init_lockFunction · 0.85
malloc_mutex_lockFunction · 0.85
malloc_init_hard_neededFunction · 0.85
malloc_mutex_unlockFunction · 0.85
malloc_tsd_boot0Function · 0.85
tsd_tsdnFunction · 0.85
pre_reentrancyFunction · 0.85
malloc_init_narenasFunction · 0.85
background_thread_boot1Function · 0.85
prof_boot2Function · 0.85

Tested by

no test coverage detected