diff options
author | Jason Evans <je@fb.com> | 2015-03-16 22:11:06 (GMT) |
---|---|---|
committer | Jason Evans <je@fb.com> | 2015-03-16 22:11:06 (GMT) |
commit | 04211e226628c41da4b3804ba411b5dd4b3a02ab (patch) | |
tree | 5099ea597115849eff7619aef13f6ff51946c8ce /include/jemalloc | |
parent | 262146dfc4778f0671ab86458acd4ec531a80a34 (diff) | |
download | jemalloc-04211e226628c41da4b3804ba411b5dd4b3a02ab.zip jemalloc-04211e226628c41da4b3804ba411b5dd4b3a02ab.tar.gz jemalloc-04211e226628c41da4b3804ba411b5dd4b3a02ab.tar.bz2 |
Fix heap profiling regressions.
Remove the prof_tctx_state_destroying transitory state and instead add
the tctx_uid field, so that the tuple <thr_uid, tctx_uid> uniquely
identifies a tctx. This assures that tctx's are well ordered even when
more than two with the same thr_uid coexist. A previous attempted fix
based on prof_tctx_state_destroying was only sufficient for protecting
against two coexisting tctx's, but it also introduced a new dumping
race.
These regressions were introduced by
602c8e0971160e4b85b08b16cf8a2375aa24bc04 (Implement per thread heap
profiling.) and 764b00023f2bc97f240c3a758ed23ce9c0ad8526 (Fix a heap
profiling regression.).
Diffstat (limited to 'include/jemalloc')
-rw-r--r-- | include/jemalloc/internal/prof.h | 23 |
1 files changed, 22 insertions, 1 deletions
diff --git a/include/jemalloc/internal/prof.h b/include/jemalloc/internal/prof.h index 8967333..2e22711 100644 --- a/include/jemalloc/internal/prof.h +++ b/include/jemalloc/internal/prof.h @@ -81,7 +81,6 @@ struct prof_cnt_s { typedef enum { prof_tctx_state_initializing, prof_tctx_state_nominal, - prof_tctx_state_destroying, prof_tctx_state_dumping, prof_tctx_state_purgatory /* Dumper must finish destroying. */ } prof_tctx_state_t; @@ -102,6 +101,21 @@ struct prof_tctx_s { /* Associated global context. */ prof_gctx_t *gctx; + /* + * UID that distinguishes multiple tctx's created by the same thread, + * but coexisting in gctx->tctxs. There are two ways that such + * coexistence can occur: + * - A dumper thread can cause a tctx to be retained in the purgatory + * state. + * - Although a single "producer" thread must create all tctx's which + * share the same thr_uid, multiple "consumers" can each concurrently + * execute portions of prof_tctx_destroy(). prof_tctx_destroy() only + * gets called once each time cnts.cur{objs,bytes} drop to 0, but this + * threshold can be hit again before the first consumer finishes + * executing prof_tctx_destroy(). + */ + uint64_t tctx_uid; + /* Linkage into gctx's tctxs. */ rb_node(prof_tctx_t) tctx_link; @@ -179,6 +193,13 @@ struct prof_tdata_s { rb_node(prof_tdata_t) tdata_link; /* + * Counter used to initialize prof_tctx_t's tctx_uid. No locking is + * necessary when incrementing this field, because only one thread ever + * does so. + */ + uint64_t tctx_uid_next; + + /* * Hash of (prof_bt_t *)-->(prof_tctx_t *). Each thread tracks * backtraces for which it has non-zero allocation/deallocation counters * associated with thread-specific prof_tctx_t objects. Other threads |