Lines Matching refs:tsd
141 static void prof_tctx_destroy(tsd_t *tsd, prof_tctx_t *tctx);
144 static void prof_tdata_destroy(tsd_t *tsd, prof_tdata_t *tdata,
211 prof_alloc_rollback(tsd_t *tsd, prof_tctx_t *tctx, bool updated) { in rb_gen()
223 tdata = prof_tdata_get(tsd, true); in rb_gen()
230 malloc_mutex_lock(tsd_tsdn(tsd), tctx->tdata->lock); in rb_gen()
232 if (prof_tctx_should_destroy(tsd_tsdn(tsd), tctx)) { in rb_gen()
233 prof_tctx_destroy(tsd, tctx); in rb_gen()
235 malloc_mutex_unlock(tsd_tsdn(tsd), tctx->tdata->lock); in rb_gen()
257 prof_free_sampled_object(tsd_t *tsd, size_t usize, prof_tctx_t *tctx) { in prof_free_sampled_object() argument
258 malloc_mutex_lock(tsd_tsdn(tsd), tctx->tdata->lock); in prof_free_sampled_object()
264 if (prof_tctx_should_destroy(tsd_tsdn(tsd), tctx)) { in prof_free_sampled_object()
265 prof_tctx_destroy(tsd, tctx); in prof_free_sampled_object()
267 malloc_mutex_unlock(tsd_tsdn(tsd), tctx->tdata->lock); in prof_free_sampled_object()
280 prof_enter(tsd_t *tsd, prof_tdata_t *tdata) { in prof_enter() argument
282 assert(tdata == prof_tdata_get(tsd, false)); in prof_enter()
289 malloc_mutex_lock(tsd_tsdn(tsd), &bt2gctx_mtx); in prof_enter()
293 prof_leave(tsd_t *tsd, prof_tdata_t *tdata) { in prof_leave() argument
295 assert(tdata == prof_tdata_get(tsd, false)); in prof_leave()
297 malloc_mutex_unlock(tsd_tsdn(tsd), &bt2gctx_mtx); in prof_leave()
310 prof_idump(tsd_tsdn(tsd)); in prof_leave()
313 prof_gdump(tsd_tsdn(tsd)); in prof_leave()
579 prof_gctx_try_destroy(tsd_t *tsd, prof_tdata_t *tdata_self, prof_gctx_t *gctx, in prof_gctx_try_destroy() argument
590 prof_enter(tsd, tdata_self); in prof_gctx_try_destroy()
591 malloc_mutex_lock(tsd_tsdn(tsd), gctx->lock); in prof_gctx_try_destroy()
595 if (ckh_remove(tsd, &bt2gctx, &gctx->bt, NULL, NULL)) { in prof_gctx_try_destroy()
598 prof_leave(tsd, tdata_self); 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()
608 malloc_mutex_unlock(tsd_tsdn(tsd), gctx->lock); in prof_gctx_try_destroy()
609 prof_leave(tsd, tdata_self); in prof_gctx_try_destroy()
644 prof_tctx_destroy(tsd_t *tsd, prof_tctx_t *tctx) { in prof_tctx_destroy() argument
649 malloc_mutex_assert_owner(tsd_tsdn(tsd), tctx->tdata->lock); in prof_tctx_destroy()
657 ckh_remove(tsd, &tdata->bt2tctx, &gctx->bt, NULL, NULL); in prof_tctx_destroy()
658 destroy_tdata = prof_tdata_should_destroy(tsd_tsdn(tsd), tdata, false); in prof_tctx_destroy()
659 malloc_mutex_unlock(tsd_tsdn(tsd), tdata->lock); in prof_tctx_destroy()
661 malloc_mutex_lock(tsd_tsdn(tsd), gctx->lock); 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()
708 malloc_mutex_assert_not_owner(tsd_tsdn(tsd), tctx->tdata->lock); in prof_tctx_destroy()
711 prof_tdata_destroy(tsd, tdata, false); in prof_tctx_destroy()
715 idalloctm(tsd_tsdn(tsd), tctx, NULL, NULL, true, true); in prof_tctx_destroy()
720 prof_lookup_global(tsd_t *tsd, prof_bt_t *bt, prof_tdata_t *tdata, in prof_lookup_global() argument
732 prof_enter(tsd, tdata); in prof_lookup_global()
735 prof_leave(tsd, tdata); in prof_lookup_global()
736 tgctx.p = prof_gctx_create(tsd_tsdn(tsd), bt); in prof_lookup_global()
740 prof_enter(tsd, tdata); in prof_lookup_global()
744 if (ckh_insert(tsd, &bt2gctx, btkey.v, gctx.v)) { in prof_lookup_global()
746 prof_leave(tsd, tdata); 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()
767 malloc_mutex_unlock(tsd_tsdn(tsd), gctx.p->lock); in prof_lookup_global()
772 idalloctm(tsd_tsdn(tsd), tgctx.v, NULL, NULL, true, in prof_lookup_global()
776 prof_leave(tsd, tdata); in prof_lookup_global()
785 prof_lookup(tsd_t *tsd, prof_bt_t *bt) { in prof_lookup() argument
795 tdata = prof_tdata_get(tsd, false); in prof_lookup()
800 malloc_mutex_lock(tsd_tsdn(tsd), tdata->lock); in prof_lookup()
805 malloc_mutex_unlock(tsd_tsdn(tsd), tdata->lock); in prof_lookup()
815 if (prof_lookup_global(tsd, bt, tdata, &btkey, &gctx, in prof_lookup()
821 ret.v = iallocztm(tsd_tsdn(tsd), sizeof(prof_tctx_t), in prof_lookup()
823 arena_ichoose(tsd, NULL), true); in prof_lookup()
826 prof_gctx_try_destroy(tsd, tdata, gctx, tdata); in prof_lookup()
838 malloc_mutex_lock(tsd_tsdn(tsd), tdata->lock); in prof_lookup()
839 error = ckh_insert(tsd, &tdata->bt2tctx, btkey, ret.v); in prof_lookup()
840 malloc_mutex_unlock(tsd_tsdn(tsd), tdata->lock); in prof_lookup()
843 prof_gctx_try_destroy(tsd, tdata, gctx, tdata); in prof_lookup()
845 idalloctm(tsd_tsdn(tsd), ret.v, NULL, NULL, true, true); in prof_lookup()
848 malloc_mutex_lock(tsd_tsdn(tsd), gctx->lock); in prof_lookup()
852 malloc_mutex_unlock(tsd_tsdn(tsd), gctx->lock); in prof_lookup()
940 tsd_t *tsd; in prof_bt_count() local
943 tsd = tsd_fetch(); in prof_bt_count()
944 tdata = prof_tdata_get(tsd, false); in prof_bt_count()
949 malloc_mutex_lock(tsd_tsdn(tsd), &bt2gctx_mtx); in prof_bt_count()
951 malloc_mutex_unlock(tsd_tsdn(tsd), &bt2gctx_mtx); in prof_bt_count()
1219 prof_gctx_finish(tsd_t *tsd, prof_gctx_tree_t *gctxs) { in prof_gctx_finish() argument
1220 prof_tdata_t *tdata = prof_tdata_get(tsd, false); in prof_gctx_finish()
1231 malloc_mutex_lock(tsd_tsdn(tsd), gctx->lock); in prof_gctx_finish()
1240 (void *)tsd_tsdn(tsd)); in prof_gctx_finish()
1246 idalloctm(tsd_tsdn(tsd), to_destroy, 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()
1552 prof_dump_prep(tsd_t *tsd, prof_tdata_t *tdata, in prof_dump_prep() argument
1562 prof_enter(tsd, tdata); in prof_dump_prep()
1570 prof_dump_gctx_prep(tsd_tsdn(tsd), gctx.p, gctxs); in prof_dump_prep()
1577 prof_tdata_merge_iter_arg->tsdn = tsd_tsdn(tsd); in prof_dump_prep()
1579 malloc_mutex_lock(tsd_tsdn(tsd), &tdatas_mtx); in prof_dump_prep()
1582 malloc_mutex_unlock(tsd_tsdn(tsd), &tdatas_mtx); in prof_dump_prep()
1585 prof_gctx_merge_iter_arg->tsdn = tsd_tsdn(tsd); in prof_dump_prep()
1590 prof_leave(tsd, tdata); in prof_dump_prep()
1594 prof_dump_file(tsd_t *tsd, bool propagate_err, const char *filename, in prof_dump_file() argument
1606 if (prof_dump_header(tsd_tsdn(tsd), propagate_err, in prof_dump_file()
1612 prof_gctx_dump_iter_arg->tsdn = tsd_tsdn(tsd); in prof_dump_file()
1635 prof_dump(tsd_t *tsd, bool propagate_err, const char *filename, in prof_dump() argument
1638 assert(tsd_reentrancy_level_get(tsd) == 0); in prof_dump()
1640 prof_tdata_t * tdata = prof_tdata_get(tsd, true); in prof_dump()
1645 pre_reentrancy(tsd, NULL); in prof_dump()
1646 malloc_mutex_lock(tsd_tsdn(tsd), &prof_dump_mtx); in prof_dump()
1652 prof_dump_prep(tsd, tdata, &prof_tdata_merge_iter_arg, in prof_dump()
1654 bool err = prof_dump_file(tsd, propagate_err, filename, leakcheck, tdata, in prof_dump()
1657 prof_gctx_finish(tsd, &gctxs); in prof_dump()
1659 malloc_mutex_unlock(tsd_tsdn(tsd), &prof_dump_mtx); in prof_dump()
1660 post_reentrancy(tsd); in prof_dump()
1677 tsd_t *tsd; in prof_cnt_all() local
1683 tsd = tsd_fetch(); in prof_cnt_all()
1684 tdata = prof_tdata_get(tsd, false); in prof_cnt_all()
1701 prof_dump_prep(tsd, tdata, &prof_tdata_merge_iter_arg, in prof_cnt_all()
1703 prof_gctx_finish(tsd, &gctxs); in prof_cnt_all()
1742 tsd_t *tsd; in prof_fdump() local
1752 tsd = tsd_fetch(); in prof_fdump()
1753 assert(tsd_reentrancy_level_get(tsd) == 0); in prof_fdump()
1755 malloc_mutex_lock(tsd_tsdn(tsd), &prof_dump_seq_mtx); in prof_fdump()
1757 malloc_mutex_unlock(tsd_tsdn(tsd), &prof_dump_seq_mtx); in prof_fdump()
1758 prof_dump(tsd, false, filename, opt_prof_leak); in prof_fdump()
1779 tsd_t *tsd; in prof_idump() local
1787 tsd = tsdn_tsd(tsdn); in prof_idump()
1788 if (tsd_reentrancy_level_get(tsd) > 0) { in prof_idump()
1792 tdata = prof_tdata_get(tsd, false); in prof_idump()
1803 malloc_mutex_lock(tsd_tsdn(tsd), &prof_dump_seq_mtx); in prof_idump()
1806 malloc_mutex_unlock(tsd_tsdn(tsd), &prof_dump_seq_mtx); in prof_idump()
1807 prof_dump(tsd, false, filename, false); in prof_idump()
1812 prof_mdump(tsd_t *tsd, const char *filename) { in prof_mdump() argument
1814 assert(tsd_reentrancy_level_get(tsd) == 0); in prof_mdump()
1825 malloc_mutex_lock(tsd_tsdn(tsd), &prof_dump_seq_mtx); in prof_mdump()
1828 malloc_mutex_unlock(tsd_tsdn(tsd), &prof_dump_seq_mtx); in prof_mdump()
1831 return prof_dump(tsd, true, filename, false); in prof_mdump()
1836 tsd_t *tsd; in prof_gdump() local
1844 tsd = tsdn_tsd(tsdn); in prof_gdump()
1845 if (tsd_reentrancy_level_get(tsd) > 0) { in prof_gdump()
1849 tdata = prof_tdata_get(tsd, false); in prof_gdump()
1864 prof_dump(tsd, false, filename, false); in prof_gdump()
1903 prof_tdata_init_impl(tsd_t *tsd, uint64_t thr_uid, uint64_t thr_discrim, in prof_tdata_init_impl() argument
1910 tdata = (prof_tdata_t *)iallocztm(tsd_tsdn(tsd), sizeof(prof_tdata_t), in prof_tdata_init_impl()
1925 if (ckh_new(tsd, &tdata->bt2tctx, PROF_CKH_MINITEMS, prof_bt_hash, in prof_tdata_init_impl()
1927 idalloctm(tsd_tsdn(tsd), tdata, NULL, NULL, true, true); in prof_tdata_init_impl()
1941 malloc_mutex_lock(tsd_tsdn(tsd), &tdatas_mtx); in prof_tdata_init_impl()
1943 malloc_mutex_unlock(tsd_tsdn(tsd), &tdatas_mtx); in prof_tdata_init_impl()
1949 prof_tdata_init(tsd_t *tsd) { in prof_tdata_init() argument
1950 return prof_tdata_init_impl(tsd, prof_thr_uid_alloc(tsd_tsdn(tsd)), 0, in prof_tdata_init()
1951 NULL, prof_thread_active_init_get(tsd_tsdn(tsd))); in prof_tdata_init()
1974 prof_tdata_destroy_locked(tsd_t *tsd, prof_tdata_t *tdata, in prof_tdata_destroy_locked() argument
1976 malloc_mutex_assert_owner(tsd_tsdn(tsd), &tdatas_mtx); in prof_tdata_destroy_locked()
1983 idalloctm(tsd_tsdn(tsd), tdata->thread_name, NULL, NULL, true, in prof_tdata_destroy_locked()
1986 ckh_delete(tsd, &tdata->bt2tctx); in prof_tdata_destroy_locked()
1987 idalloctm(tsd_tsdn(tsd), tdata, NULL, NULL, true, true); in prof_tdata_destroy_locked()
1991 prof_tdata_destroy(tsd_t *tsd, prof_tdata_t *tdata, bool even_if_attached) { in prof_tdata_destroy() argument
1992 malloc_mutex_lock(tsd_tsdn(tsd), &tdatas_mtx); in prof_tdata_destroy()
1993 prof_tdata_destroy_locked(tsd, tdata, even_if_attached); in prof_tdata_destroy()
1994 malloc_mutex_unlock(tsd_tsdn(tsd), &tdatas_mtx); in prof_tdata_destroy()
1998 prof_tdata_detach(tsd_t *tsd, prof_tdata_t *tdata) { in prof_tdata_detach() argument
2001 malloc_mutex_lock(tsd_tsdn(tsd), tdata->lock); in prof_tdata_detach()
2003 destroy_tdata = prof_tdata_should_destroy(tsd_tsdn(tsd), tdata, in prof_tdata_detach()
2012 tsd_prof_tdata_set(tsd, NULL); in prof_tdata_detach()
2016 malloc_mutex_unlock(tsd_tsdn(tsd), tdata->lock); in prof_tdata_detach()
2018 prof_tdata_destroy(tsd, tdata, true); in prof_tdata_detach()
2023 prof_tdata_reinit(tsd_t *tsd, prof_tdata_t *tdata) { in prof_tdata_reinit() argument
2027 prof_thread_name_alloc(tsd_tsdn(tsd), tdata->thread_name) : NULL; in prof_tdata_reinit()
2030 prof_tdata_detach(tsd, tdata); in prof_tdata_reinit()
2031 return prof_tdata_init_impl(tsd, thr_uid, thr_discrim, thread_name, in prof_tdata_reinit()
2061 prof_reset(tsd_t *tsd, size_t lg_sample) { in prof_reset() argument
2066 malloc_mutex_lock(tsd_tsdn(tsd), &prof_dump_mtx); in prof_reset()
2067 malloc_mutex_lock(tsd_tsdn(tsd), &tdatas_mtx); in prof_reset()
2074 prof_tdata_reset_iter, (void *)tsd); in prof_reset()
2077 prof_tdata_destroy_locked(tsd, to_destroy, false); in prof_reset()
2083 malloc_mutex_unlock(tsd_tsdn(tsd), &tdatas_mtx); in prof_reset()
2084 malloc_mutex_unlock(tsd_tsdn(tsd), &prof_dump_mtx); in prof_reset()
2088 prof_tdata_cleanup(tsd_t *tsd) { in prof_tdata_cleanup() argument
2095 tdata = tsd_prof_tdata_get(tsd); in prof_tdata_cleanup()
2097 prof_tdata_detach(tsd, tdata); in prof_tdata_cleanup()
2123 prof_thread_name_get(tsd_t *tsd) { in prof_thread_name_get() argument
2126 tdata = prof_tdata_get(tsd, true); in prof_thread_name_get()
2157 prof_thread_name_set(tsd_t *tsd, const char *thread_name) { in prof_thread_name_set() argument
2162 tdata = prof_tdata_get(tsd, true); in prof_thread_name_set()
2178 s = prof_thread_name_alloc(tsd_tsdn(tsd), thread_name); in prof_thread_name_set()
2184 idalloctm(tsd_tsdn(tsd), tdata->thread_name, NULL, NULL, true, in prof_thread_name_set()
2195 prof_thread_active_get(tsd_t *tsd) { in prof_thread_active_get() argument
2198 tdata = prof_tdata_get(tsd, true); in prof_thread_active_get()
2206 prof_thread_active_set(tsd_t *tsd, bool active) { in prof_thread_active_set() argument
2209 tdata = prof_tdata_get(tsd, true); in prof_thread_active_set()
2292 prof_boot2(tsd_t *tsd) { in prof_boot2() argument
2320 if (ckh_new(tsd, &bt2gctx, PROF_CKH_MINITEMS, prof_bt_hash, in prof_boot2()
2358 gctx_locks = (malloc_mutex_t *)base_alloc(tsd_tsdn(tsd), in prof_boot2()
2372 tdata_locks = (malloc_mutex_t *)base_alloc(tsd_tsdn(tsd), in prof_boot2()