From 75dae934a167424f0dad663e9f96fefdac25ae1b Mon Sep 17 00:00:00 2001 From: Yinan Zhang Date: Fri, 17 Apr 2020 14:10:18 -0700 Subject: [PATCH] Always initialize TE counters in TSD init --- src/tsd.c | 25 ++++++++++++++----------- 1 file changed, 14 insertions(+), 11 deletions(-) diff --git a/src/tsd.c b/src/tsd.c index c07a4bff..cc1b3ac8 100644 --- a/src/tsd.c +++ b/src/tsd.c @@ -221,14 +221,8 @@ tsd_state_set(tsd_t *tsd, uint8_t new_state) { te_recompute_fast_threshold(tsd); } -static bool -tsd_data_init(tsd_t *tsd) { - /* - * We initialize the rtree context first (before the tcache), since the - * tcache initialization depends on it. - */ - rtree_ctx_data_init(tsd_rtree_ctxp_get_unsafe(tsd)); - +static void +tsd_prng_state_init(tsd_t *tsd) { /* * A nondeterministic seed based on the address of tsd reduces * the likelihood of lockstep non-uniform cache index @@ -238,10 +232,17 @@ tsd_data_init(tsd_t *tsd) { */ *tsd_prng_statep_get(tsd) = config_debug ? 0 : (uint64_t)(uintptr_t)tsd; +} - /* event_init may use the prng state above. */ - tsd_te_init(tsd); - +static bool +tsd_data_init(tsd_t *tsd) { + /* + * We initialize the rtree context first (before the tcache), since the + * tcache initialization depends on it. + */ + rtree_ctx_data_init(tsd_rtree_ctxp_get_unsafe(tsd)); + tsd_prng_state_init(tsd); + tsd_te_init(tsd); /* event_init may use the prng state above. */ return tsd_tcache_enabled_data_init(tsd); } @@ -270,6 +271,8 @@ tsd_data_init_nocleanup(tsd_t *tsd) { *tsd_arenas_tdata_bypassp_get(tsd) = true; *tsd_tcache_enabledp_get_unsafe(tsd) = false; *tsd_reentrancy_levelp_get(tsd) = 1; + tsd_prng_state_init(tsd); + tsd_te_init(tsd); /* event_init may use the prng state above. */ assert_tsd_data_cleanup_done(tsd); return false;