Lines Matching refs:gctx
547 prof_gctx_t *gctx = (prof_gctx_t *)iallocztm(tsd, offsetof(prof_gctx_t, in prof_gctx_create() local
550 if (gctx == NULL) in prof_gctx_create()
552 gctx->lock = prof_gctx_mutex_choose(); in prof_gctx_create()
557 gctx->nlimbo = 1; in prof_gctx_create()
558 tctx_tree_new(&gctx->tctxs); in prof_gctx_create()
560 memcpy(gctx->vec, bt->vec, bt->len * sizeof(void *)); in prof_gctx_create()
561 gctx->bt.vec = gctx->vec; in prof_gctx_create()
562 gctx->bt.len = bt->len; in prof_gctx_create()
563 return (gctx); in prof_gctx_create()
567 prof_gctx_try_destroy(tsd_t *tsd, prof_tdata_t *tdata_self, prof_gctx_t *gctx, in prof_gctx_try_destroy() argument
581 malloc_mutex_lock(gctx->lock); in prof_gctx_try_destroy()
582 assert(gctx->nlimbo != 0); in prof_gctx_try_destroy()
583 if (tctx_tree_empty(&gctx->tctxs) && gctx->nlimbo == 1) { in prof_gctx_try_destroy()
585 if (ckh_remove(tsd, &bt2gctx, &gctx->bt, NULL, NULL)) in prof_gctx_try_destroy()
589 malloc_mutex_unlock(gctx->lock); in prof_gctx_try_destroy()
590 idalloctm(tsd, gctx, tcache_get(tsd, false), true); in prof_gctx_try_destroy()
596 gctx->nlimbo--; in prof_gctx_try_destroy()
597 malloc_mutex_unlock(gctx->lock); in prof_gctx_try_destroy()
617 prof_gctx_should_destroy(prof_gctx_t *gctx) in prof_gctx_should_destroy() argument
622 if (!tctx_tree_empty(&gctx->tctxs)) in prof_gctx_should_destroy()
624 if (gctx->nlimbo != 0) in prof_gctx_should_destroy()
634 prof_gctx_t *gctx = tctx->gctx; in prof_tctx_destroy() local
643 ckh_remove(tsd, &tdata->bt2tctx, &gctx->bt, NULL, NULL); in prof_tctx_destroy()
647 malloc_mutex_lock(gctx->lock); in prof_tctx_destroy()
650 tctx_tree_remove(&gctx->tctxs, tctx); in prof_tctx_destroy()
652 if (prof_gctx_should_destroy(gctx)) { in prof_tctx_destroy()
667 gctx->nlimbo++; in prof_tctx_destroy()
687 malloc_mutex_unlock(gctx->lock); in prof_tctx_destroy()
689 prof_gctx_try_destroy(tsd, prof_tdata_get(tsd, false), gctx, in prof_tctx_destroy()
707 } gctx; in prof_lookup_global() local
715 if (ckh_search(&bt2gctx, bt, &btkey.v, &gctx.v)) { in prof_lookup_global()
717 gctx.p = prof_gctx_create(tsd, bt); in prof_lookup_global()
718 if (gctx.v == NULL) { in prof_lookup_global()
722 btkey.p = &gctx.p->bt; in prof_lookup_global()
723 if (ckh_insert(tsd, &bt2gctx, btkey.v, gctx.v)) { in prof_lookup_global()
726 idalloctm(tsd, gctx.v, tcache_get(tsd, false), true); in prof_lookup_global()
735 malloc_mutex_lock(gctx.p->lock); in prof_lookup_global()
736 gctx.p->nlimbo++; in prof_lookup_global()
737 malloc_mutex_unlock(gctx.p->lock); in prof_lookup_global()
743 *p_gctx = gctx.p; in prof_lookup_global()
772 prof_gctx_t *gctx; in prof_lookup() local
779 if (prof_lookup_global(tsd, bt, tdata, &btkey, &gctx, in prof_lookup()
789 prof_gctx_try_destroy(tsd, tdata, gctx, tdata); in prof_lookup()
795 ret.p->gctx = gctx; in prof_lookup()
804 prof_gctx_try_destroy(tsd, tdata, gctx, tdata); in prof_lookup()
808 malloc_mutex_lock(gctx->lock); in prof_lookup()
810 tctx_tree_insert(&gctx->tctxs, ret.p); in prof_lookup()
811 gctx->nlimbo--; in prof_lookup()
812 malloc_mutex_unlock(gctx->lock); in prof_lookup()
1031 malloc_mutex_lock(tctx->gctx->lock); in prof_tctx_merge_tdata()
1035 malloc_mutex_unlock(tctx->gctx->lock); in prof_tctx_merge_tdata()
1039 malloc_mutex_unlock(tctx->gctx->lock); in prof_tctx_merge_tdata()
1060 prof_tctx_merge_gctx(prof_tctx_t *tctx, prof_gctx_t *gctx) in prof_tctx_merge_gctx() argument
1063 gctx->cnt_summed.curobjs += tctx->dump_cnts.curobjs; in prof_tctx_merge_gctx()
1064 gctx->cnt_summed.curbytes += tctx->dump_cnts.curbytes; in prof_tctx_merge_gctx()
1066 gctx->cnt_summed.accumobjs += tctx->dump_cnts.accumobjs; in prof_tctx_merge_gctx()
1067 gctx->cnt_summed.accumbytes += tctx->dump_cnts.accumbytes; in prof_tctx_merge_gctx()
1082 prof_tctx_merge_gctx(tctx, tctx->gctx); in prof_tctx_merge_iter()
1131 prof_dump_gctx_prep(prof_gctx_t *gctx, prof_gctx_tree_t *gctxs) in prof_dump_gctx_prep() argument
1136 malloc_mutex_lock(gctx->lock); in prof_dump_gctx_prep()
1143 gctx->nlimbo++; in prof_dump_gctx_prep()
1144 gctx_tree_insert(gctxs, gctx); in prof_dump_gctx_prep()
1146 memset(&gctx->cnt_summed, 0, sizeof(prof_cnt_t)); in prof_dump_gctx_prep()
1148 malloc_mutex_unlock(gctx->lock); in prof_dump_gctx_prep()
1152 prof_gctx_merge_iter(prof_gctx_tree_t *gctxs, prof_gctx_t *gctx, void *arg) in prof_gctx_merge_iter() argument
1156 malloc_mutex_lock(gctx->lock); in prof_gctx_merge_iter()
1157 tctx_tree_iter(&gctx->tctxs, NULL, prof_tctx_merge_iter, NULL); in prof_gctx_merge_iter()
1158 if (gctx->cnt_summed.curobjs != 0) in prof_gctx_merge_iter()
1160 malloc_mutex_unlock(gctx->lock); in prof_gctx_merge_iter()
1169 prof_gctx_t *gctx; in prof_gctx_finish() local
1177 while ((gctx = gctx_tree_first(gctxs)) != NULL) { in prof_gctx_finish()
1178 gctx_tree_remove(gctxs, gctx); in prof_gctx_finish()
1179 malloc_mutex_lock(gctx->lock); in prof_gctx_finish()
1186 tctx_tree_iter(&gctx->tctxs, next, in prof_gctx_finish()
1189 next = tctx_tree_next(&gctx->tctxs, in prof_gctx_finish()
1191 tctx_tree_remove(&gctx->tctxs, in prof_gctx_finish()
1199 gctx->nlimbo--; in prof_gctx_finish()
1200 if (prof_gctx_should_destroy(gctx)) { in prof_gctx_finish()
1201 gctx->nlimbo++; in prof_gctx_finish()
1202 malloc_mutex_unlock(gctx->lock); in prof_gctx_finish()
1203 prof_gctx_try_destroy(tsd, tdata, gctx, tdata); in prof_gctx_finish()
1205 malloc_mutex_unlock(gctx->lock); in prof_gctx_finish()
1290 prof_dump_gctx(bool propagate_err, prof_gctx_t *gctx, const prof_bt_t *bt, in prof_dump_gctx() argument
1299 if ((!opt_prof_accum && gctx->cnt_summed.curobjs == 0) || in prof_dump_gctx()
1300 (opt_prof_accum && gctx->cnt_summed.accumobjs == 0)) { in prof_dump_gctx()
1301 assert(gctx->cnt_summed.curobjs == 0); in prof_dump_gctx()
1302 assert(gctx->cnt_summed.curbytes == 0); in prof_dump_gctx()
1303 assert(gctx->cnt_summed.accumobjs == 0); in prof_dump_gctx()
1304 assert(gctx->cnt_summed.accumbytes == 0); in prof_dump_gctx()
1324 gctx->cnt_summed.curobjs, gctx->cnt_summed.curbytes, in prof_dump_gctx()
1325 gctx->cnt_summed.accumobjs, gctx->cnt_summed.accumbytes)) { in prof_dump_gctx()
1330 if (tctx_tree_iter(&gctx->tctxs, NULL, prof_tctx_dump_iter, in prof_dump_gctx()
1427 prof_gctx_dump_iter(prof_gctx_tree_t *gctxs, prof_gctx_t *gctx, void *arg) in prof_gctx_dump_iter() argument
1432 malloc_mutex_lock(gctx->lock); in prof_gctx_dump_iter()
1434 if (prof_dump_gctx(propagate_err, gctx, &gctx->bt, gctxs)) { in prof_gctx_dump_iter()
1435 ret = gctx; in prof_gctx_dump_iter()
1441 malloc_mutex_unlock(gctx->lock); in prof_gctx_dump_iter()
1454 } gctx; in prof_dump() local
1472 for (tabind = 0; !ckh_iter(&bt2gctx, &tabind, NULL, &gctx.v);) in prof_dump()
1473 prof_dump_gctx_prep(gctx.p, &gctxs); in prof_dump()