Lines Matching refs:gctx
556 prof_gctx_t *gctx = (prof_gctx_t *)iallocztm(tsdn, size, in prof_gctx_create() local
559 if (gctx == NULL) in prof_gctx_create()
561 gctx->lock = prof_gctx_mutex_choose(); in prof_gctx_create()
566 gctx->nlimbo = 1; in prof_gctx_create()
567 tctx_tree_new(&gctx->tctxs); in prof_gctx_create()
569 memcpy(gctx->vec, bt->vec, bt->len * sizeof(void *)); in prof_gctx_create()
570 gctx->bt.vec = gctx->vec; in prof_gctx_create()
571 gctx->bt.len = bt->len; in prof_gctx_create()
572 return (gctx); in prof_gctx_create()
576 prof_gctx_try_destroy(tsd_t *tsd, prof_tdata_t *tdata_self, prof_gctx_t *gctx, in prof_gctx_try_destroy() argument
590 malloc_mutex_lock(tsd_tsdn(tsd), gctx->lock); in prof_gctx_try_destroy()
591 assert(gctx->nlimbo != 0); in prof_gctx_try_destroy()
592 if (tctx_tree_empty(&gctx->tctxs) && gctx->nlimbo == 1) { in prof_gctx_try_destroy()
594 if (ckh_remove(tsd, &bt2gctx, &gctx->bt, NULL, NULL)) in prof_gctx_try_destroy()
598 malloc_mutex_unlock(tsd_tsdn(tsd), gctx->lock); in prof_gctx_try_destroy()
599 idalloctm(tsd_tsdn(tsd), gctx, NULL, true, true); in prof_gctx_try_destroy()
605 gctx->nlimbo--; in prof_gctx_try_destroy()
606 malloc_mutex_unlock(tsd_tsdn(tsd), gctx->lock); in prof_gctx_try_destroy()
627 prof_gctx_should_destroy(prof_gctx_t *gctx) in prof_gctx_should_destroy() argument
632 if (!tctx_tree_empty(&gctx->tctxs)) in prof_gctx_should_destroy()
634 if (gctx->nlimbo != 0) in prof_gctx_should_destroy()
643 prof_gctx_t *gctx = tctx->gctx; in prof_tctx_destroy() local
654 ckh_remove(tsd, &tdata->bt2tctx, &gctx->bt, NULL, NULL); in prof_tctx_destroy()
658 malloc_mutex_lock(tsd_tsdn(tsd), gctx->lock); in prof_tctx_destroy()
661 tctx_tree_remove(&gctx->tctxs, tctx); in prof_tctx_destroy()
663 if (prof_gctx_should_destroy(gctx)) { in prof_tctx_destroy()
678 gctx->nlimbo++; in prof_tctx_destroy()
698 malloc_mutex_unlock(tsd_tsdn(tsd), gctx->lock); in prof_tctx_destroy()
700 prof_gctx_try_destroy(tsd, prof_tdata_get(tsd, false), gctx, in prof_tctx_destroy()
720 } gctx; in prof_lookup_global() local
728 if (ckh_search(&bt2gctx, bt, &btkey.v, &gctx.v)) { in prof_lookup_global()
730 gctx.p = prof_gctx_create(tsd_tsdn(tsd), bt); in prof_lookup_global()
731 if (gctx.v == NULL) { in prof_lookup_global()
735 btkey.p = &gctx.p->bt; in prof_lookup_global()
736 if (ckh_insert(tsd, &bt2gctx, btkey.v, gctx.v)) { in prof_lookup_global()
739 idalloctm(tsd_tsdn(tsd), gctx.v, NULL, true, true); in prof_lookup_global()
748 malloc_mutex_lock(tsd_tsdn(tsd), gctx.p->lock); in prof_lookup_global()
749 gctx.p->nlimbo++; in prof_lookup_global()
750 malloc_mutex_unlock(tsd_tsdn(tsd), gctx.p->lock); in prof_lookup_global()
756 *p_gctx = gctx.p; in prof_lookup_global()
784 prof_gctx_t *gctx; in prof_lookup() local
791 if (prof_lookup_global(tsd, bt, tdata, &btkey, &gctx, in prof_lookup()
801 prof_gctx_try_destroy(tsd, tdata, gctx, tdata); in prof_lookup()
808 ret.p->gctx = gctx; in prof_lookup()
817 prof_gctx_try_destroy(tsd, tdata, gctx, tdata); in prof_lookup()
821 malloc_mutex_lock(tsd_tsdn(tsd), gctx->lock); in prof_lookup()
823 tctx_tree_insert(&gctx->tctxs, ret.p); in prof_lookup()
824 gctx->nlimbo--; in prof_lookup()
825 malloc_mutex_unlock(tsd_tsdn(tsd), gctx->lock); in prof_lookup()
1046 malloc_mutex_lock(tsdn, tctx->gctx->lock); in prof_tctx_merge_tdata()
1050 malloc_mutex_unlock(tsdn, tctx->gctx->lock); in prof_tctx_merge_tdata()
1054 malloc_mutex_unlock(tsdn, tctx->gctx->lock); in prof_tctx_merge_tdata()
1074 prof_tctx_merge_gctx(tsdn_t *tsdn, prof_tctx_t *tctx, prof_gctx_t *gctx) in prof_tctx_merge_gctx() argument
1077 malloc_mutex_assert_owner(tsdn, gctx->lock); in prof_tctx_merge_gctx()
1079 gctx->cnt_summed.curobjs += tctx->dump_cnts.curobjs; in prof_tctx_merge_gctx()
1080 gctx->cnt_summed.curbytes += tctx->dump_cnts.curbytes; in prof_tctx_merge_gctx()
1082 gctx->cnt_summed.accumobjs += tctx->dump_cnts.accumobjs; in prof_tctx_merge_gctx()
1083 gctx->cnt_summed.accumbytes += tctx->dump_cnts.accumbytes; in prof_tctx_merge_gctx()
1092 malloc_mutex_assert_owner(tsdn, tctx->gctx->lock); in prof_tctx_merge_iter()
1100 prof_tctx_merge_gctx(tsdn, tctx, tctx->gctx); in prof_tctx_merge_iter()
1120 malloc_mutex_assert_owner(arg->tsdn, tctx->gctx->lock); in prof_tctx_dump_iter()
1148 malloc_mutex_assert_owner(tsdn, tctx->gctx->lock); in prof_tctx_finish_iter()
1170 prof_dump_gctx_prep(tsdn_t *tsdn, prof_gctx_t *gctx, prof_gctx_tree_t *gctxs) in prof_dump_gctx_prep() argument
1175 malloc_mutex_lock(tsdn, gctx->lock); in prof_dump_gctx_prep()
1182 gctx->nlimbo++; in prof_dump_gctx_prep()
1183 gctx_tree_insert(gctxs, gctx); in prof_dump_gctx_prep()
1185 memset(&gctx->cnt_summed, 0, sizeof(prof_cnt_t)); in prof_dump_gctx_prep()
1187 malloc_mutex_unlock(tsdn, gctx->lock); in prof_dump_gctx_prep()
1196 prof_gctx_merge_iter(prof_gctx_tree_t *gctxs, prof_gctx_t *gctx, void *opaque) in prof_gctx_merge_iter() argument
1201 malloc_mutex_lock(arg->tsdn, gctx->lock); in prof_gctx_merge_iter()
1202 tctx_tree_iter(&gctx->tctxs, NULL, prof_tctx_merge_iter, in prof_gctx_merge_iter()
1204 if (gctx->cnt_summed.curobjs != 0) in prof_gctx_merge_iter()
1206 malloc_mutex_unlock(arg->tsdn, gctx->lock); in prof_gctx_merge_iter()
1215 prof_gctx_t *gctx; in prof_gctx_finish() local
1223 while ((gctx = gctx_tree_first(gctxs)) != NULL) { in prof_gctx_finish()
1224 gctx_tree_remove(gctxs, gctx); in prof_gctx_finish()
1225 malloc_mutex_lock(tsd_tsdn(tsd), gctx->lock); in prof_gctx_finish()
1232 tctx_tree_iter(&gctx->tctxs, next, in prof_gctx_finish()
1236 next = tctx_tree_next(&gctx->tctxs, in prof_gctx_finish()
1238 tctx_tree_remove(&gctx->tctxs, in prof_gctx_finish()
1246 gctx->nlimbo--; in prof_gctx_finish()
1247 if (prof_gctx_should_destroy(gctx)) { in prof_gctx_finish()
1248 gctx->nlimbo++; in prof_gctx_finish()
1249 malloc_mutex_unlock(tsd_tsdn(tsd), gctx->lock); in prof_gctx_finish()
1250 prof_gctx_try_destroy(tsd, tdata, gctx, tdata); in prof_gctx_finish()
1252 malloc_mutex_unlock(tsd_tsdn(tsd), gctx->lock); in prof_gctx_finish()
1343 prof_dump_gctx(tsdn_t *tsdn, bool propagate_err, prof_gctx_t *gctx, in prof_dump_gctx() argument
1351 malloc_mutex_assert_owner(tsdn, gctx->lock); in prof_dump_gctx()
1354 if ((!opt_prof_accum && gctx->cnt_summed.curobjs == 0) || in prof_dump_gctx()
1355 (opt_prof_accum && gctx->cnt_summed.accumobjs == 0)) { in prof_dump_gctx()
1356 assert(gctx->cnt_summed.curobjs == 0); in prof_dump_gctx()
1357 assert(gctx->cnt_summed.curbytes == 0); in prof_dump_gctx()
1358 assert(gctx->cnt_summed.accumobjs == 0); in prof_dump_gctx()
1359 assert(gctx->cnt_summed.accumbytes == 0); in prof_dump_gctx()
1379 gctx->cnt_summed.curobjs, gctx->cnt_summed.curbytes, in prof_dump_gctx()
1380 gctx->cnt_summed.accumobjs, gctx->cnt_summed.accumbytes)) { in prof_dump_gctx()
1387 if (tctx_tree_iter(&gctx->tctxs, NULL, prof_tctx_dump_iter, in prof_dump_gctx()
1524 prof_gctx_dump_iter(prof_gctx_tree_t *gctxs, prof_gctx_t *gctx, void *opaque) in prof_gctx_dump_iter() argument
1530 malloc_mutex_lock(arg->tsdn, gctx->lock); in prof_gctx_dump_iter()
1532 if (prof_dump_gctx(arg->tsdn, arg->propagate_err, gctx, &gctx->bt, in prof_gctx_dump_iter()
1534 ret = gctx; in prof_gctx_dump_iter()
1540 malloc_mutex_unlock(arg->tsdn, gctx->lock); in prof_gctx_dump_iter()
1553 } gctx; in prof_dump() local
1572 for (tabind = 0; !ckh_iter(&bt2gctx, &tabind, NULL, &gctx.v);) in prof_dump()
1573 prof_dump_gctx_prep(tsd_tsdn(tsd), gctx.p, &gctxs); in prof_dump()