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

Function ctl_init

app/redis-6.2.6/deps/jemalloc/src/ctl.c:998–1072  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

996}
997
998static bool
999ctl_init(tsd_t *tsd) {
1000 bool ret;
1001 tsdn_t *tsdn = tsd_tsdn(tsd);
1002
1003 malloc_mutex_lock(tsdn, &ctl_mtx);
1004 if (!ctl_initialized) {
1005 ctl_arena_t *ctl_sarena, *ctl_darena;
1006 unsigned i;
1007
1008 /*
1009 * Allocate demand-zeroed space for pointers to the full
1010 * range of supported arena indices.
1011 */
1012 if (ctl_arenas == NULL) {
1013 ctl_arenas = (ctl_arenas_t *)base_alloc(tsdn,
1014 b0get(), sizeof(ctl_arenas_t), QUANTUM);
1015 if (ctl_arenas == NULL) {
1016 ret = true;
1017 goto label_return;
1018 }
1019 }
1020
1021 if (config_stats && ctl_stats == NULL) {
1022 ctl_stats = (ctl_stats_t *)base_alloc(tsdn, b0get(),
1023 sizeof(ctl_stats_t), QUANTUM);
1024 if (ctl_stats == NULL) {
1025 ret = true;
1026 goto label_return;
1027 }
1028 }
1029
1030 /*
1031 * Allocate space for the current full range of arenas
1032 * here rather than doing it lazily elsewhere, in order
1033 * to limit when OOM-caused errors can occur.
1034 */
1035 if ((ctl_sarena = arenas_i_impl(tsd, MALLCTL_ARENAS_ALL, false,
1036 true)) == NULL) {
1037 ret = true;
1038 goto label_return;
1039 }
1040 ctl_sarena->initialized = true;
1041
1042 if ((ctl_darena = arenas_i_impl(tsd, MALLCTL_ARENAS_DESTROYED,
1043 false, true)) == NULL) {
1044 ret = true;
1045 goto label_return;
1046 }
1047 ctl_arena_clear(ctl_darena);
1048 /*
1049 * Don't toggle ctl_darena to initialized until an arena is
1050 * actually destroyed, so that arena.<i>.initialized can be used
1051 * to query whether the stats are relevant.
1052 */
1053
1054 ctl_arenas->narenas = narenas_total_get();
1055 for (i = 0; i < ctl_arenas->narenas; i++) {

Callers 3

ctl_bynameFunction · 0.85
ctl_nametomibFunction · 0.85
ctl_bymibFunction · 0.85

Calls 9

tsd_tsdnFunction · 0.85
malloc_mutex_lockFunction · 0.85
base_allocFunction · 0.85
b0getFunction · 0.85
arenas_i_implFunction · 0.85
ctl_arena_clearFunction · 0.85
narenas_total_getFunction · 0.85
ctl_refreshFunction · 0.85
malloc_mutex_unlockFunction · 0.85

Tested by

no test coverage detected