Replace extent_achunk_[gs]et() with extent_slab_[gs]et().
This commit is contained in:
parent
fae8344098
commit
d78846c989
@ -1185,7 +1185,7 @@ arena_prof_tctx_get(tsdn_t *tsdn, const extent_t *extent, const void *ptr)
|
||||
cassert(config_prof);
|
||||
assert(ptr != NULL);
|
||||
|
||||
if (likely(extent_achunk_get(extent))) {
|
||||
if (likely(extent_slab_get(extent))) {
|
||||
arena_chunk_t *chunk = (arena_chunk_t *)extent_addr_get(extent);
|
||||
size_t pageind = ((uintptr_t)ptr - (uintptr_t)chunk) >> LG_PAGE;
|
||||
size_t mapbits = arena_mapbits_get(chunk, pageind);
|
||||
@ -1211,7 +1211,7 @@ arena_prof_tctx_set(tsdn_t *tsdn, extent_t *extent, const void *ptr,
|
||||
cassert(config_prof);
|
||||
assert(ptr != NULL);
|
||||
|
||||
if (likely(extent_achunk_get(extent))) {
|
||||
if (likely(extent_slab_get(extent))) {
|
||||
arena_chunk_t *chunk = (arena_chunk_t *)extent_addr_get(extent);
|
||||
size_t pageind = ((uintptr_t)ptr - (uintptr_t)chunk) >> LG_PAGE;
|
||||
|
||||
@ -1331,7 +1331,7 @@ arena_salloc(tsdn_t *tsdn, const extent_t *extent, const void *ptr, bool demote)
|
||||
|
||||
assert(ptr != NULL);
|
||||
|
||||
if (likely(extent_achunk_get(extent))) {
|
||||
if (likely(extent_slab_get(extent))) {
|
||||
const arena_chunk_t *chunk =
|
||||
(const arena_chunk_t *)extent_addr_get(extent);
|
||||
|
||||
@ -1381,7 +1381,7 @@ arena_dalloc(tsdn_t *tsdn, extent_t *extent, void *ptr, tcache_t *tcache,
|
||||
assert(!tsdn_null(tsdn) || tcache == NULL);
|
||||
assert(ptr != NULL);
|
||||
|
||||
if (likely(extent_achunk_get(extent))) {
|
||||
if (likely(extent_slab_get(extent))) {
|
||||
arena_chunk_t *chunk = (arena_chunk_t *)extent_addr_get(extent);
|
||||
|
||||
pageind = ((uintptr_t)ptr - (uintptr_t)chunk) >> LG_PAGE;
|
||||
@ -1428,7 +1428,7 @@ arena_sdalloc(tsdn_t *tsdn, extent_t *extent, void *ptr, size_t size,
|
||||
|
||||
assert(!tsdn_null(tsdn) || tcache == NULL);
|
||||
|
||||
if (likely(extent_achunk_get(extent))) {
|
||||
if (likely(extent_slab_get(extent))) {
|
||||
arena_chunk_t *chunk = (arena_chunk_t *)extent_addr_get(extent);
|
||||
|
||||
if (config_prof && opt_prof) {
|
||||
|
@ -35,10 +35,11 @@ struct extent_s {
|
||||
bool e_committed;
|
||||
|
||||
/*
|
||||
* The achunk flag is used to validate that huge allocation lookups
|
||||
* don't return arena chunks.
|
||||
* The slab flag indicates whether the extent is used for a slab of
|
||||
* small regions. This helps differentiate small size classes, and it
|
||||
* indicates whether interior pointers can be looked up via iealloc().
|
||||
*/
|
||||
bool e_achunk;
|
||||
bool e_slab;
|
||||
|
||||
/* Profile counters, used for huge objects. */
|
||||
prof_tctx_t *e_prof_tctx;
|
||||
@ -79,7 +80,7 @@ size_t extent_size_get(const extent_t *extent);
|
||||
bool extent_active_get(const extent_t *extent);
|
||||
bool extent_zeroed_get(const extent_t *extent);
|
||||
bool extent_committed_get(const extent_t *extent);
|
||||
bool extent_achunk_get(const extent_t *extent);
|
||||
bool extent_slab_get(const extent_t *extent);
|
||||
prof_tctx_t *extent_prof_tctx_get(const extent_t *extent);
|
||||
void extent_arena_set(extent_t *extent, arena_t *arena);
|
||||
void extent_addr_set(extent_t *extent, void *addr);
|
||||
@ -87,10 +88,10 @@ void extent_size_set(extent_t *extent, size_t size);
|
||||
void extent_active_set(extent_t *extent, bool active);
|
||||
void extent_zeroed_set(extent_t *extent, bool zeroed);
|
||||
void extent_committed_set(extent_t *extent, bool committed);
|
||||
void extent_achunk_set(extent_t *extent, bool achunk);
|
||||
void extent_slab_set(extent_t *extent, bool slab);
|
||||
void extent_prof_tctx_set(extent_t *extent, prof_tctx_t *tctx);
|
||||
void extent_init(extent_t *extent, arena_t *arena, void *addr,
|
||||
size_t size, bool active, bool zeroed, bool committed);
|
||||
size_t size, bool active, bool zeroed, bool committed, bool slab);
|
||||
void extent_dirty_insert(extent_t *extent,
|
||||
arena_runs_dirty_link_t *runs_dirty, extent_t *chunks_dirty);
|
||||
void extent_dirty_remove(extent_t *extent);
|
||||
@ -136,15 +137,15 @@ JEMALLOC_INLINE bool
|
||||
extent_committed_get(const extent_t *extent)
|
||||
{
|
||||
|
||||
assert(!extent->e_achunk);
|
||||
assert(!extent->e_slab);
|
||||
return (extent->e_committed);
|
||||
}
|
||||
|
||||
JEMALLOC_INLINE bool
|
||||
extent_achunk_get(const extent_t *extent)
|
||||
extent_slab_get(const extent_t *extent)
|
||||
{
|
||||
|
||||
return (extent->e_achunk);
|
||||
return (extent->e_slab);
|
||||
}
|
||||
|
||||
JEMALLOC_INLINE prof_tctx_t *
|
||||
@ -197,10 +198,10 @@ extent_committed_set(extent_t *extent, bool committed)
|
||||
}
|
||||
|
||||
JEMALLOC_INLINE void
|
||||
extent_achunk_set(extent_t *extent, bool achunk)
|
||||
extent_slab_set(extent_t *extent, bool slab)
|
||||
{
|
||||
|
||||
extent->e_achunk = achunk;
|
||||
extent->e_slab = slab;
|
||||
}
|
||||
|
||||
JEMALLOC_INLINE void
|
||||
@ -212,7 +213,7 @@ extent_prof_tctx_set(extent_t *extent, prof_tctx_t *tctx)
|
||||
|
||||
JEMALLOC_INLINE void
|
||||
extent_init(extent_t *extent, arena_t *arena, void *addr, size_t size,
|
||||
bool active, bool zeroed, bool committed)
|
||||
bool active, bool zeroed, bool committed, bool slab)
|
||||
{
|
||||
|
||||
extent_arena_set(extent, arena);
|
||||
@ -221,7 +222,7 @@ extent_init(extent_t *extent, arena_t *arena, void *addr, size_t size,
|
||||
extent_active_set(extent, active);
|
||||
extent_zeroed_set(extent, zeroed);
|
||||
extent_committed_set(extent, committed);
|
||||
extent_achunk_set(extent, false);
|
||||
extent_slab_set(extent, slab);
|
||||
if (config_prof)
|
||||
extent_prof_tctx_set(extent, NULL);
|
||||
qr_new(&extent->rd, rd_link);
|
||||
|
@ -1095,8 +1095,7 @@ ivsalloc(tsdn_t *tsdn, const void *ptr, bool demote)
|
||||
return (0);
|
||||
assert(extent_active_get(extent));
|
||||
/* Only arena chunks should be looked up via interior pointers. */
|
||||
assert(extent_addr_get(extent) == ptr ||
|
||||
extent_achunk_get(extent));
|
||||
assert(extent_addr_get(extent) == ptr || extent_slab_get(extent));
|
||||
|
||||
return (isalloc(tsdn, extent, ptr, demote));
|
||||
}
|
||||
|
@ -205,8 +205,6 @@ ctl_postfork_parent
|
||||
ctl_prefork
|
||||
decay_ticker_get
|
||||
dss_prec_names
|
||||
extent_achunk_get
|
||||
extent_achunk_set
|
||||
extent_active_get
|
||||
extent_active_set
|
||||
extent_addr_get
|
||||
@ -222,6 +220,8 @@ extent_prof_tctx_get
|
||||
extent_prof_tctx_set
|
||||
extent_size_get
|
||||
extent_size_set
|
||||
extent_slab_get
|
||||
extent_slab_set
|
||||
extent_tree_ad_destroy
|
||||
extent_tree_ad_destroy_recurse
|
||||
extent_tree_ad_empty
|
||||
|
@ -525,8 +525,8 @@ arena_chunk_register(tsdn_t *tsdn, arena_t *arena, arena_chunk_t *chunk,
|
||||
* runs is tracked individually, and upon chunk deallocation the entire
|
||||
* chunk is in a consistent commit state.
|
||||
*/
|
||||
extent_init(&chunk->extent, arena, chunk, chunksize, true, zero, true);
|
||||
extent_achunk_set(&chunk->extent, true);
|
||||
extent_init(&chunk->extent, arena, chunk, chunksize, true, zero, true,
|
||||
true);
|
||||
return (chunk_register(tsdn, chunk, &chunk->extent));
|
||||
}
|
||||
|
||||
@ -1723,7 +1723,7 @@ arena_purge_to_limit(tsdn_t *tsdn, arena_t *arena, size_t ndirty_limit)
|
||||
|
||||
qr_new(&purge_runs_sentinel, rd_link);
|
||||
extent_init(&purge_chunks_sentinel, arena, NULL, 0, false, false,
|
||||
false);
|
||||
false, false);
|
||||
|
||||
npurge = arena_stash_dirty(tsdn, arena, &chunk_hooks, ndirty_limit,
|
||||
&purge_runs_sentinel, &purge_chunks_sentinel);
|
||||
|
@ -66,7 +66,7 @@ base_chunk_alloc(tsdn_t *tsdn, size_t minsize)
|
||||
base_resident += PAGE_CEILING(nsize);
|
||||
}
|
||||
}
|
||||
extent_init(extent, NULL, addr, csize, true, true, true);
|
||||
extent_init(extent, NULL, addr, csize, true, true, true, false);
|
||||
return (extent);
|
||||
}
|
||||
|
||||
@ -90,7 +90,7 @@ base_alloc(tsdn_t *tsdn, size_t size)
|
||||
csize = CACHELINE_CEILING(size);
|
||||
|
||||
usize = s2u(csize);
|
||||
extent_init(&key, NULL, NULL, usize, false, false, false);
|
||||
extent_init(&key, NULL, NULL, usize, false, false, false, false);
|
||||
malloc_mutex_lock(tsdn, &base_mtx);
|
||||
extent = extent_tree_szad_nsearch(&base_avail_szad, &key);
|
||||
if (extent != NULL) {
|
||||
|
10
src/chunk.c
10
src/chunk.c
@ -239,7 +239,7 @@ chunk_first_best_fit(arena_t *arena, extent_tree_t *chunks_szad,
|
||||
|
||||
assert(size == CHUNK_CEILING(size));
|
||||
|
||||
extent_init(&key, arena, NULL, size, false, false, false);
|
||||
extent_init(&key, arena, NULL, size, false, false, false, false);
|
||||
return (extent_tree_szad_nsearch(chunks_szad, &key));
|
||||
}
|
||||
|
||||
@ -271,7 +271,7 @@ chunk_recycle(tsdn_t *tsdn, arena_t *arena, chunk_hooks_t *chunk_hooks,
|
||||
if (new_addr != NULL) {
|
||||
extent_t key;
|
||||
extent_init(&key, arena, new_addr, alloc_size, false, false,
|
||||
false);
|
||||
false, false);
|
||||
extent = extent_tree_ad_search(chunks_ad, &key);
|
||||
} else {
|
||||
extent = chunk_first_best_fit(arena, chunks_szad, chunks_ad,
|
||||
@ -337,7 +337,7 @@ chunk_recycle(tsdn_t *tsdn, arena_t *arena, chunk_hooks_t *chunk_hooks,
|
||||
}
|
||||
}
|
||||
extent_init(extent, arena, (void *)((uintptr_t)(ret) + size),
|
||||
trailsize, false, zeroed, committed);
|
||||
trailsize, false, zeroed, committed, false);
|
||||
extent_tree_szad_insert(chunks_szad, extent);
|
||||
extent_tree_ad_insert(chunks_ad, extent);
|
||||
arena_chunk_cache_maybe_insert(arena, extent, cache);
|
||||
@ -535,7 +535,7 @@ chunk_record(tsdn_t *tsdn, arena_t *arena, chunk_hooks_t *chunk_hooks,
|
||||
malloc_mutex_lock(tsdn, &arena->chunks_mtx);
|
||||
chunk_hooks_assure_initialized_locked(tsdn, arena, chunk_hooks);
|
||||
extent_init(&key, arena, (void *)((uintptr_t)chunk + size), 0, false,
|
||||
false, false);
|
||||
false, false, false);
|
||||
extent = extent_tree_ad_nsearch(chunks_ad, &key);
|
||||
/* Try to coalesce forward. */
|
||||
if (extent != NULL && extent_addr_get(extent) == extent_addr_get(&key)
|
||||
@ -572,7 +572,7 @@ chunk_record(tsdn_t *tsdn, arena_t *arena, chunk_hooks_t *chunk_hooks,
|
||||
goto label_return;
|
||||
}
|
||||
extent_init(extent, arena, chunk, size, false, !unzeroed,
|
||||
committed);
|
||||
committed, false);
|
||||
extent_tree_ad_insert(chunks_ad, extent);
|
||||
extent_tree_szad_insert(chunks_szad, extent);
|
||||
arena_chunk_cache_maybe_insert(arena, extent, cache);
|
||||
|
@ -50,7 +50,7 @@ huge_palloc(tsdn_t *tsdn, arena_t *arena, size_t usize, size_t alignment,
|
||||
return (NULL);
|
||||
}
|
||||
|
||||
extent_init(extent, arena, ret, usize, true, is_zeroed, true);
|
||||
extent_init(extent, arena, ret, usize, true, is_zeroed, true, false);
|
||||
|
||||
if (chunk_register(tsdn, ret, extent)) {
|
||||
arena_chunk_dalloc_huge(tsdn, arena, ret, usize);
|
||||
|
Loading…
Reference in New Issue
Block a user