diff --git a/include/jemalloc/internal/arena_externs.h b/include/jemalloc/internal/arena_externs.h index c95570e9..c5b6e6c7 100644 --- a/include/jemalloc/internal/arena_externs.h +++ b/include/jemalloc/internal/arena_externs.h @@ -33,8 +33,6 @@ extern size_t oversize_threshold; extern bool opt_huge_arena_pac_thp; extern pac_thp_t huge_arena_pac_thp; -extern unsigned huge_arena_ind; - /* * arena_bin_offsets[binind] is the offset of the first bin shard for size class * binind. @@ -108,6 +106,7 @@ void arena_nthreads_inc(arena_t *arena, bool internal); void arena_nthreads_dec(arena_t *arena, bool internal); arena_t *arena_new(tsdn_t *tsdn, unsigned ind, const arena_config_t *config); bool arena_init_huge(tsdn_t *tsdn, arena_t *a0); +bool arena_ind_is_huge(unsigned ind); arena_t *arena_choose_huge(tsd_t *tsd); size_t arena_fill_small_fresh(tsdn_t *tsdn, arena_t *arena, szind_t binind, void **ptrs, size_t nfill, bool zero); diff --git a/src/arena.c b/src/arena.c index 98385460..559ec47a 100644 --- a/src/arena.c +++ b/src/arena.c @@ -47,7 +47,7 @@ static unsigned nbins_total; * that, the huge_arena_ind is updated to point to the actual huge arena, * which is the last one of the auto arenas. */ -unsigned huge_arena_ind = 0; +static unsigned huge_arena_ind = 0; bool opt_huge_arena_pac_thp = false; pac_thp_t huge_arena_pac_thp = {.thp_madvise = false, .auto_thp_switched = false, @@ -1978,6 +1978,11 @@ arena_init_huge(tsdn_t *tsdn, arena_t *a0) { return huge_enabled; } +bool +arena_ind_is_huge(unsigned ind) { + return huge_arena_ind != 0 && ind == huge_arena_ind; +} + bool arena_boot(sc_data_t *sc_data, base_t *base, bool hpa) { arena_dirty_decay_ms_default_set(opt_dirty_decay_ms); diff --git a/src/extent.c b/src/extent.c index 118c8785..12050f04 100644 --- a/src/extent.c +++ b/src/extent.c @@ -823,7 +823,7 @@ extent_grow_retained(tsdn_t *tsdn, pac_t *pac, ehooks_t *ehooks, size_t size, if (huge_arena_pac_thp.thp_madvise) { /* Avoid using HUGEPAGE when the grow size is less than HUGEPAGE. */ - if (ind != 0 && ind == huge_arena_ind + if (arena_ind_is_huge(ind) && ehooks_are_default(ehooks) && likely(alloc_size >= HUGEPAGE)) { extent_handle_huge_arena_thp(tsdn, &huge_arena_pac_thp,