From 19a51abf337d35b3bdbbac22d8c513f4fd8b6c57 Mon Sep 17 00:00:00 2001 From: Qi Wang Date: Mon, 4 Nov 2019 16:44:37 -0800 Subject: [PATCH] Avoid arena->offset_state when tsd not available for prng. Use stack locals and remove the offset_state in arena. --- include/jemalloc/internal/arena_structs.h | 8 -------- src/arena.c | 12 ------------ src/extent.c | 4 ++-- 3 files changed, 2 insertions(+), 22 deletions(-) diff --git a/include/jemalloc/internal/arena_structs.h b/include/jemalloc/internal/arena_structs.h index 54889dc8..bc8c0394 100644 --- a/include/jemalloc/internal/arena_structs.h +++ b/include/jemalloc/internal/arena_structs.h @@ -118,14 +118,6 @@ struct arena_s { /* Synchronization: internal. */ prof_accum_t prof_accum; - /* - * PRNG state for cache index randomization of large allocation base - * pointers. - * - * Synchronization: atomic. - */ - atomic_zu_t offset_state; - /* * Extent serial number generator state. * diff --git a/src/arena.c b/src/arena.c index e4dd4770..fa18d144 100644 --- a/src/arena.c +++ b/src/arena.c @@ -1981,18 +1981,6 @@ arena_new(tsdn_t *tsdn, unsigned ind, extent_hooks_t *extent_hooks) { } } - if (config_cache_oblivious) { - /* - * A nondeterministic seed based on the address of arena reduces - * the likelihood of lockstep non-uniform cache index - * utilization among identical concurrent processes, but at the - * cost of test repeatability. For debug builds, instead use a - * deterministic seed. - */ - atomic_store_zu(&arena->offset_state, config_debug ? ind : - (size_t)(uintptr_t)arena, ATOMIC_RELAXED); - } - atomic_store_zu(&arena->extent_sn_next, 0, ATOMIC_RELAXED); atomic_store_u(&arena->dss_prec, (unsigned)extent_dss_prec_get(), diff --git a/src/extent.c b/src/extent.c index 4bb358d4..50a81055 100644 --- a/src/extent.c +++ b/src/extent.c @@ -187,8 +187,8 @@ extent_addr_randomize(tsdn_t *tsdn, arena_t *arena, extent_t *extent, r = (size_t)prng_lg_range_u64( tsd_offset_statep_get(tsd), lg_range); } else { - r = prng_lg_range_zu(&arena->offset_state, lg_range, - true); + uint64_t stack_value = (uint64_t)(uintptr_t)&r; + r = (size_t)prng_lg_range_u64(&stack_value, lg_range); } uintptr_t random_offset = ((uintptr_t)r) << (LG_PAGE - lg_range);