Lines Matching refs:tctx
124 static bool prof_tctx_should_destroy(tsdn_t *tsdn, prof_tctx_t *tctx);
125 static void prof_tctx_destroy(tsd_t *tsd, prof_tctx_t *tctx);
197 prof_alloc_rollback(tsd_t *tsd, prof_tctx_t *tctx, bool updated) in rb_gen()
215 if ((uintptr_t)tctx > (uintptr_t)1U) { in rb_gen()
216 malloc_mutex_lock(tsd_tsdn(tsd), tctx->tdata->lock); in rb_gen()
217 tctx->prepared = false; in rb_gen()
218 if (prof_tctx_should_destroy(tsd_tsdn(tsd), tctx)) in rb_gen()
219 prof_tctx_destroy(tsd, tctx); in rb_gen()
221 malloc_mutex_unlock(tsd_tsdn(tsd), tctx->tdata->lock); in rb_gen()
227 prof_tctx_t *tctx) in prof_malloc_sample_object() argument
230 prof_tctx_set(tsdn, ptr, usize, tctx); in prof_malloc_sample_object()
232 malloc_mutex_lock(tsdn, tctx->tdata->lock); in prof_malloc_sample_object()
233 tctx->cnts.curobjs++; in prof_malloc_sample_object()
234 tctx->cnts.curbytes += usize; in prof_malloc_sample_object()
236 tctx->cnts.accumobjs++; in prof_malloc_sample_object()
237 tctx->cnts.accumbytes += usize; in prof_malloc_sample_object()
239 tctx->prepared = false; in prof_malloc_sample_object()
240 malloc_mutex_unlock(tsdn, tctx->tdata->lock); in prof_malloc_sample_object()
244 prof_free_sampled_object(tsd_t *tsd, size_t usize, prof_tctx_t *tctx) in prof_free_sampled_object() argument
247 malloc_mutex_lock(tsd_tsdn(tsd), tctx->tdata->lock); in prof_free_sampled_object()
248 assert(tctx->cnts.curobjs > 0); in prof_free_sampled_object()
249 assert(tctx->cnts.curbytes >= usize); in prof_free_sampled_object()
250 tctx->cnts.curobjs--; in prof_free_sampled_object()
251 tctx->cnts.curbytes -= usize; in prof_free_sampled_object()
253 if (prof_tctx_should_destroy(tsd_tsdn(tsd), tctx)) in prof_free_sampled_object()
254 prof_tctx_destroy(tsd, tctx); in prof_free_sampled_object()
256 malloc_mutex_unlock(tsd_tsdn(tsd), tctx->tdata->lock); in prof_free_sampled_object()
612 prof_tctx_should_destroy(tsdn_t *tsdn, prof_tctx_t *tctx) in prof_tctx_should_destroy() argument
615 malloc_mutex_assert_owner(tsdn, tctx->tdata->lock); in prof_tctx_should_destroy()
619 if (tctx->cnts.curobjs != 0) in prof_tctx_should_destroy()
621 if (tctx->prepared) in prof_tctx_should_destroy()
640 prof_tctx_destroy(tsd_t *tsd, prof_tctx_t *tctx) in prof_tctx_destroy() argument
642 prof_tdata_t *tdata = tctx->tdata; in prof_tctx_destroy()
643 prof_gctx_t *gctx = tctx->gctx; in prof_tctx_destroy()
646 malloc_mutex_assert_owner(tsd_tsdn(tsd), tctx->tdata->lock); in prof_tctx_destroy()
648 assert(tctx->cnts.curobjs == 0); in prof_tctx_destroy()
649 assert(tctx->cnts.curbytes == 0); in prof_tctx_destroy()
651 assert(tctx->cnts.accumobjs == 0); in prof_tctx_destroy()
652 assert(tctx->cnts.accumbytes == 0); in prof_tctx_destroy()
659 switch (tctx->state) { in prof_tctx_destroy()
661 tctx_tree_remove(&gctx->tctxs, tctx); in prof_tctx_destroy()
689 tctx->state = prof_tctx_state_purgatory; in prof_tctx_destroy()
704 malloc_mutex_assert_not_owner(tsd_tsdn(tsd), tctx->tdata->lock); in prof_tctx_destroy()
710 idalloctm(tsd_tsdn(tsd), tctx, NULL, true, true); in prof_tctx_destroy()
1041 prof_tctx_merge_tdata(tsdn_t *tsdn, prof_tctx_t *tctx, prof_tdata_t *tdata) in prof_tctx_merge_tdata() argument
1044 malloc_mutex_assert_owner(tsdn, tctx->tdata->lock); in prof_tctx_merge_tdata()
1046 malloc_mutex_lock(tsdn, tctx->gctx->lock); in prof_tctx_merge_tdata()
1048 switch (tctx->state) { in prof_tctx_merge_tdata()
1050 malloc_mutex_unlock(tsdn, tctx->gctx->lock); in prof_tctx_merge_tdata()
1053 tctx->state = prof_tctx_state_dumping; in prof_tctx_merge_tdata()
1054 malloc_mutex_unlock(tsdn, tctx->gctx->lock); in prof_tctx_merge_tdata()
1056 memcpy(&tctx->dump_cnts, &tctx->cnts, sizeof(prof_cnt_t)); in prof_tctx_merge_tdata()
1058 tdata->cnt_summed.curobjs += tctx->dump_cnts.curobjs; in prof_tctx_merge_tdata()
1059 tdata->cnt_summed.curbytes += tctx->dump_cnts.curbytes; in prof_tctx_merge_tdata()
1062 tctx->dump_cnts.accumobjs; in prof_tctx_merge_tdata()
1064 tctx->dump_cnts.accumbytes; 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
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()
1088 prof_tctx_merge_iter(prof_tctx_tree_t *tctxs, prof_tctx_t *tctx, void *arg) in prof_tctx_merge_iter() argument
1092 malloc_mutex_assert_owner(tsdn, tctx->gctx->lock); in prof_tctx_merge_iter()
1094 switch (tctx->state) { in prof_tctx_merge_iter()
1100 prof_tctx_merge_gctx(tsdn, tctx, tctx->gctx); in prof_tctx_merge_iter()
1115 prof_tctx_dump_iter(prof_tctx_tree_t *tctxs, prof_tctx_t *tctx, void *opaque) in prof_tctx_dump_iter() argument
1120 malloc_mutex_assert_owner(arg->tsdn, tctx->gctx->lock); in prof_tctx_dump_iter()
1122 switch (tctx->state) { in prof_tctx_dump_iter()
1131 "%"FMTu64"]\n", tctx->thr_uid, tctx->dump_cnts.curobjs, in prof_tctx_dump_iter()
1132 tctx->dump_cnts.curbytes, tctx->dump_cnts.accumobjs, in prof_tctx_dump_iter()
1133 tctx->dump_cnts.accumbytes)) in prof_tctx_dump_iter()
1134 return (tctx); in prof_tctx_dump_iter()
1143 prof_tctx_finish_iter(prof_tctx_tree_t *tctxs, prof_tctx_t *tctx, void *arg) in prof_tctx_finish_iter() argument
1148 malloc_mutex_assert_owner(tsdn, tctx->gctx->lock); in prof_tctx_finish_iter()
1150 switch (tctx->state) { in prof_tctx_finish_iter()
1155 tctx->state = prof_tctx_state_nominal; in prof_tctx_finish_iter()
1158 ret = tctx; in prof_tctx_finish_iter()
1274 } tctx; in prof_tdata_merge_iter() local
1279 &tctx.v);) in prof_tdata_merge_iter()
1280 prof_tctx_merge_tdata(arg->tsdn, tctx.p, tdata); in prof_tdata_merge_iter()