diff --git a/include/jemalloc/internal/extent.h b/include/jemalloc/internal/extent.h index 2f14b81f..2eb53f66 100644 --- a/include/jemalloc/internal/extent.h +++ b/include/jemalloc/internal/extent.h @@ -48,7 +48,7 @@ edata_t *extent_split_wrapper(tsdn_t *tsdn, pa_shard_t *shard, ehooks_t *ehooks, edata_t *edata, size_t size_a, size_t size_b); bool extent_merge_wrapper(tsdn_t *tsdn, pa_shard_t *shard, ehooks_t *ehooks, edata_t *a, edata_t *b); - +size_t extent_sn_next(pac_t *pac); bool extent_boot(void); #endif /* JEMALLOC_INTERNAL_EXTENT_H */ diff --git a/include/jemalloc/internal/pa.h b/include/jemalloc/internal/pa.h index 2891d7c4..e6ed1fd9 100644 --- a/include/jemalloc/internal/pa.h +++ b/include/jemalloc/internal/pa.h @@ -84,9 +84,6 @@ struct pa_shard_s { /* The source of edata_t objects. */ edata_cache_t edata_cache; - /* Extent serial number generator state. */ - atomic_zu_t extent_sn_next; - malloc_mutex_t *stats_mtx; pa_shard_stats_t *stats; @@ -131,8 +128,6 @@ void pa_shard_reset(pa_shard_t *shard); */ void pa_shard_destroy_retained(tsdn_t *tsdn, pa_shard_t *shard); -size_t pa_shard_extent_sn_next(pa_shard_t *shard); - /* Gets an edata for the given allocation. */ edata_t *pa_alloc(tsdn_t *tsdn, pa_shard_t *shard, size_t size, size_t alignment, bool slab, szind_t szind, bool zero); diff --git a/include/jemalloc/internal/pac.h b/include/jemalloc/internal/pac.h index 14ee09f3..d1d68534 100644 --- a/include/jemalloc/internal/pac.h +++ b/include/jemalloc/internal/pac.h @@ -90,6 +90,9 @@ struct pac_s { malloc_mutex_t *stats_mtx; pac_stats_t *stats; + + /* Extent serial number generator state. */ + atomic_zu_t extent_sn_next; }; bool pac_init(tsdn_t *tsdn, pac_t *pac, unsigned ind, emap_t *emap, diff --git a/src/extent.c b/src/extent.c index fb6ccebd..bb5daba1 100644 --- a/src/extent.c +++ b/src/extent.c @@ -50,6 +50,11 @@ static edata_t *extent_alloc_retained(tsdn_t *tsdn, pa_shard_t *shard, /******************************************************************************/ +size_t +extent_sn_next(pac_t *pac) { + return atomic_fetch_add_zu(&pac->extent_sn_next, 1, ATOMIC_RELAXED); +} + static bool extent_try_delayed_coalesce(tsdn_t *tsdn, pa_shard_t *shard, ehooks_t *ehooks, ecache_t *ecache, edata_t *edata) { @@ -648,7 +653,7 @@ extent_grow_retained(tsdn_t *tsdn, pa_shard_t *shard, ehooks_t *ehooks, } edata_init(edata, ecache_ind_get(&shard->pac.ecache_retained), ptr, - alloc_size, false, SC_NSIZES, pa_shard_extent_sn_next(shard), + alloc_size, false, SC_NSIZES, extent_sn_next(&shard->pac), extent_state_active, zeroed, committed, /* ranged */ false, EXTENT_IS_HEAD); @@ -793,7 +798,7 @@ extent_alloc_wrapper(tsdn_t *tsdn, pa_shard_t *shard, ehooks_t *ehooks, return NULL; } edata_init(edata, ecache_ind_get(&shard->pac.ecache_dirty), addr, - size, /* slab */ false, SC_NSIZES, pa_shard_extent_sn_next(shard), + size, /* slab */ false, SC_NSIZES, extent_sn_next(&shard->pac), extent_state_active, zero, *commit, /* ranged */ false, EXTENT_NOT_HEAD); if (extent_register(tsdn, shard, edata)) { diff --git a/src/extent_dss.c b/src/extent_dss.c index 81161b3a..dff231d9 100644 --- a/src/extent_dss.c +++ b/src/extent_dss.c @@ -154,9 +154,10 @@ extent_alloc_dss(tsdn_t *tsdn, arena_t *arena, void *new_addr, size_t size, if (gap_size_page != 0) { edata_init(gap, arena_ind_get(arena), gap_addr_page, gap_size_page, false, - SC_NSIZES, pa_shard_extent_sn_next( - &arena->pa_shard), extent_state_active, - false, true, false, EXTENT_NOT_HEAD); + SC_NSIZES, extent_sn_next( + &arena->pa_shard.pac), + extent_state_active, false, true, false, + EXTENT_NOT_HEAD); } /* * Compute the address just past the end of the desired diff --git a/src/pa.c b/src/pa.c index 3ca8e35d..2f970c76 100644 --- a/src/pa.c +++ b/src/pa.c @@ -35,7 +35,6 @@ pa_shard_init(tsdn_t *tsdn, pa_shard_t *shard, emap_t *emap, base_t *base, return true; } - atomic_store_zu(&shard->extent_sn_next, 0, ATOMIC_RELAXED); atomic_store_zu(&shard->nactive, 0, ATOMIC_RELAXED); shard->stats_mtx = stats_mtx; @@ -79,11 +78,6 @@ pa_shard_destroy_retained(tsdn_t *tsdn, pa_shard_t *shard) { } } -size_t -pa_shard_extent_sn_next(pa_shard_t *shard) { - return atomic_fetch_add_zu(&shard->extent_sn_next, 1, ATOMIC_RELAXED); -} - static bool pa_shard_may_have_muzzy(pa_shard_t *shard) { return pac_muzzy_decay_ms_get(&shard->pac) != 0; diff --git a/src/pac.c b/src/pac.c index 9192f54c..8ff6f1c8 100644 --- a/src/pac.c +++ b/src/pac.c @@ -49,6 +49,7 @@ pac_init(tsdn_t *tsdn, pac_t *pac, unsigned ind, emap_t *emap, pac->edata_cache = edata_cache; pac->stats = pac_stats; pac->stats_mtx = stats_mtx; + atomic_store_zu(&pac->extent_sn_next, 0, ATOMIC_RELAXED); return false; }