Lines Matching refs:gctx
558 prof_gctx_t *gctx = (prof_gctx_t *)iallocztm(tsdn, size, in prof_gctx_create() local
561 if (gctx == NULL) { in prof_gctx_create()
564 gctx->lock = prof_gctx_mutex_choose(); in prof_gctx_create()
569 gctx->nlimbo = 1; in prof_gctx_create()
570 tctx_tree_new(&gctx->tctxs); in prof_gctx_create()
572 memcpy(gctx->vec, bt->vec, bt->len * sizeof(void *)); in prof_gctx_create()
573 gctx->bt.vec = gctx->vec; in prof_gctx_create()
574 gctx->bt.len = bt->len; in prof_gctx_create()
575 return gctx; in prof_gctx_create()
579 prof_gctx_try_destroy(tsd_t *tsd, prof_tdata_t *tdata_self, prof_gctx_t *gctx, in prof_gctx_try_destroy() argument
591 malloc_mutex_lock(tsd_tsdn(tsd), gctx->lock); in prof_gctx_try_destroy()
592 assert(gctx->nlimbo != 0); in prof_gctx_try_destroy()
593 if (tctx_tree_empty(&gctx->tctxs) && gctx->nlimbo == 1) { in prof_gctx_try_destroy()
595 if (ckh_remove(tsd, &bt2gctx, &gctx->bt, NULL, NULL)) { in prof_gctx_try_destroy()
600 malloc_mutex_unlock(tsd_tsdn(tsd), gctx->lock); in prof_gctx_try_destroy()
601 idalloctm(tsd_tsdn(tsd), gctx, NULL, NULL, true, true); in prof_gctx_try_destroy()
607 gctx->nlimbo--; in prof_gctx_try_destroy()
608 malloc_mutex_unlock(tsd_tsdn(tsd), gctx->lock); in prof_gctx_try_destroy()
630 prof_gctx_should_destroy(prof_gctx_t *gctx) { in prof_gctx_should_destroy() argument
634 if (!tctx_tree_empty(&gctx->tctxs)) { in prof_gctx_should_destroy()
637 if (gctx->nlimbo != 0) { in prof_gctx_should_destroy()
646 prof_gctx_t *gctx = tctx->gctx; in prof_tctx_destroy() local
657 ckh_remove(tsd, &tdata->bt2tctx, &gctx->bt, NULL, NULL); in prof_tctx_destroy()
661 malloc_mutex_lock(tsd_tsdn(tsd), gctx->lock); in prof_tctx_destroy()
664 tctx_tree_remove(&gctx->tctxs, tctx); in prof_tctx_destroy()
666 if (prof_gctx_should_destroy(gctx)) { in prof_tctx_destroy()
681 gctx->nlimbo++; in prof_tctx_destroy()
702 malloc_mutex_unlock(tsd_tsdn(tsd), gctx->lock); in prof_tctx_destroy()
704 prof_gctx_try_destroy(tsd, prof_tdata_get(tsd, false), gctx, in prof_tctx_destroy()
725 } gctx, tgctx; in prof_lookup_global() local
733 if (ckh_search(&bt2gctx, bt, &btkey.v, &gctx.v)) { in prof_lookup_global()
741 if (ckh_search(&bt2gctx, bt, &btkey.v, &gctx.v)) { in prof_lookup_global()
742 gctx.p = tgctx.p; in prof_lookup_global()
743 btkey.p = &gctx.p->bt; in prof_lookup_global()
744 if (ckh_insert(tsd, &bt2gctx, btkey.v, gctx.v)) { in prof_lookup_global()
747 idalloctm(tsd_tsdn(tsd), gctx.v, NULL, NULL, in prof_lookup_global()
765 malloc_mutex_lock(tsd_tsdn(tsd), gctx.p->lock); in prof_lookup_global()
766 gctx.p->nlimbo++; in prof_lookup_global()
767 malloc_mutex_unlock(tsd_tsdn(tsd), gctx.p->lock); in prof_lookup_global()
779 *p_gctx = gctx.p; in prof_lookup_global()
808 prof_gctx_t *gctx; in prof_lookup() local
815 if (prof_lookup_global(tsd, bt, tdata, &btkey, &gctx, in prof_lookup()
826 prof_gctx_try_destroy(tsd, tdata, gctx, tdata); in prof_lookup()
834 ret.p->gctx = gctx; in prof_lookup()
843 prof_gctx_try_destroy(tsd, tdata, gctx, tdata); in prof_lookup()
848 malloc_mutex_lock(tsd_tsdn(tsd), gctx->lock); in prof_lookup()
850 tctx_tree_insert(&gctx->tctxs, ret.p); in prof_lookup()
851 gctx->nlimbo--; in prof_lookup()
852 malloc_mutex_unlock(tsd_tsdn(tsd), gctx->lock); in prof_lookup()
1059 malloc_mutex_lock(tsdn, tctx->gctx->lock); in prof_tctx_merge_tdata()
1063 malloc_mutex_unlock(tsdn, tctx->gctx->lock); in prof_tctx_merge_tdata()
1067 malloc_mutex_unlock(tsdn, tctx->gctx->lock); in prof_tctx_merge_tdata()
1087 prof_tctx_merge_gctx(tsdn_t *tsdn, prof_tctx_t *tctx, prof_gctx_t *gctx) { in prof_tctx_merge_gctx() argument
1088 malloc_mutex_assert_owner(tsdn, gctx->lock); in prof_tctx_merge_gctx()
1090 gctx->cnt_summed.curobjs += tctx->dump_cnts.curobjs; in prof_tctx_merge_gctx()
1091 gctx->cnt_summed.curbytes += tctx->dump_cnts.curbytes; in prof_tctx_merge_gctx()
1093 gctx->cnt_summed.accumobjs += tctx->dump_cnts.accumobjs; in prof_tctx_merge_gctx()
1094 gctx->cnt_summed.accumbytes += tctx->dump_cnts.accumbytes; in prof_tctx_merge_gctx()
1102 malloc_mutex_assert_owner(tsdn, tctx->gctx->lock); in prof_tctx_merge_iter()
1110 prof_tctx_merge_gctx(tsdn, tctx, tctx->gctx); in prof_tctx_merge_iter()
1129 malloc_mutex_assert_owner(arg->tsdn, tctx->gctx->lock); in prof_tctx_dump_iter()
1157 malloc_mutex_assert_owner(tsdn, tctx->gctx->lock); in prof_tctx_finish_iter()
1179 prof_dump_gctx_prep(tsdn_t *tsdn, prof_gctx_t *gctx, prof_gctx_tree_t *gctxs) { in prof_dump_gctx_prep() argument
1182 malloc_mutex_lock(tsdn, gctx->lock); in prof_dump_gctx_prep()
1189 gctx->nlimbo++; in prof_dump_gctx_prep()
1190 gctx_tree_insert(gctxs, gctx); in prof_dump_gctx_prep()
1192 memset(&gctx->cnt_summed, 0, sizeof(prof_cnt_t)); in prof_dump_gctx_prep()
1194 malloc_mutex_unlock(tsdn, gctx->lock); in prof_dump_gctx_prep()
1203 prof_gctx_merge_iter(prof_gctx_tree_t *gctxs, prof_gctx_t *gctx, void *opaque) { in prof_gctx_merge_iter() argument
1207 malloc_mutex_lock(arg->tsdn, gctx->lock); in prof_gctx_merge_iter()
1208 tctx_tree_iter(&gctx->tctxs, NULL, prof_tctx_merge_iter, in prof_gctx_merge_iter()
1210 if (gctx->cnt_summed.curobjs != 0) { in prof_gctx_merge_iter()
1213 malloc_mutex_unlock(arg->tsdn, gctx->lock); in prof_gctx_merge_iter()
1221 prof_gctx_t *gctx; in prof_gctx_finish() local
1229 while ((gctx = gctx_tree_first(gctxs)) != NULL) { in prof_gctx_finish()
1230 gctx_tree_remove(gctxs, gctx); in prof_gctx_finish()
1231 malloc_mutex_lock(tsd_tsdn(tsd), gctx->lock); in prof_gctx_finish()
1238 tctx_tree_iter(&gctx->tctxs, next, in prof_gctx_finish()
1242 next = tctx_tree_next(&gctx->tctxs, in prof_gctx_finish()
1244 tctx_tree_remove(&gctx->tctxs, in prof_gctx_finish()
1253 gctx->nlimbo--; in prof_gctx_finish()
1254 if (prof_gctx_should_destroy(gctx)) { in prof_gctx_finish()
1255 gctx->nlimbo++; in prof_gctx_finish()
1256 malloc_mutex_unlock(tsd_tsdn(tsd), gctx->lock); in prof_gctx_finish()
1257 prof_gctx_try_destroy(tsd, tdata, gctx, tdata); in prof_gctx_finish()
1259 malloc_mutex_unlock(tsd_tsdn(tsd), gctx->lock); in prof_gctx_finish()
1347 prof_dump_gctx(tsdn_t *tsdn, bool propagate_err, prof_gctx_t *gctx, in prof_dump_gctx() argument
1354 malloc_mutex_assert_owner(tsdn, gctx->lock); in prof_dump_gctx()
1357 if ((!opt_prof_accum && gctx->cnt_summed.curobjs == 0) || in prof_dump_gctx()
1358 (opt_prof_accum && gctx->cnt_summed.accumobjs == 0)) { in prof_dump_gctx()
1359 assert(gctx->cnt_summed.curobjs == 0); in prof_dump_gctx()
1360 assert(gctx->cnt_summed.curbytes == 0); in prof_dump_gctx()
1361 assert(gctx->cnt_summed.accumobjs == 0); in prof_dump_gctx()
1362 assert(gctx->cnt_summed.accumbytes == 0); in prof_dump_gctx()
1382 gctx->cnt_summed.curobjs, gctx->cnt_summed.curbytes, in prof_dump_gctx()
1383 gctx->cnt_summed.accumobjs, gctx->cnt_summed.accumbytes)) { in prof_dump_gctx()
1390 if (tctx_tree_iter(&gctx->tctxs, NULL, prof_tctx_dump_iter, in prof_dump_gctx()
1532 prof_gctx_dump_iter(prof_gctx_tree_t *gctxs, prof_gctx_t *gctx, void *opaque) { in prof_gctx_dump_iter() argument
1537 malloc_mutex_lock(arg->tsdn, gctx->lock); in prof_gctx_dump_iter()
1539 if (prof_dump_gctx(arg->tsdn, arg->propagate_err, gctx, &gctx->bt, in prof_gctx_dump_iter()
1541 ret = gctx; in prof_gctx_dump_iter()
1547 malloc_mutex_unlock(arg->tsdn, gctx->lock); in prof_gctx_dump_iter()
1560 } gctx; in prof_dump_prep() local
1569 for (tabind = 0; !ckh_iter(&bt2gctx, &tabind, NULL, &gctx.v);) { in prof_dump_prep()
1570 prof_dump_gctx_prep(tsd_tsdn(tsd), gctx.p, gctxs); in prof_dump_prep()