PA->PAC: Move in extent_sn.

This commit is contained in:
David Goldblatt 2020-06-01 18:01:19 -07:00 committed by David Goldblatt
parent 7391382349
commit dee5d1c42d
7 changed files with 16 additions and 17 deletions

View File

@ -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 */

View File

@ -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);

View File

@ -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,

View File

@ -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)) {

View File

@ -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

View File

@ -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;

View File

@ -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;
}