From 760bf11b23b96a9c26e48ca51df9644bb382892f Mon Sep 17 00:00:00 2001 From: Jason Evans Date: Tue, 24 May 2016 20:56:46 -0700 Subject: [PATCH] Add extent_dirty_[gs]et(). --- include/jemalloc/internal/extent.h | 25 +++++++++++++++++-- include/jemalloc/internal/private_symbols.txt | 2 ++ src/arena.c | 2 +- src/base.c | 2 +- src/chunk.c | 11 ++++---- src/chunk_dss.c | 2 +- 6 files changed, 34 insertions(+), 10 deletions(-) diff --git a/include/jemalloc/internal/extent.h b/include/jemalloc/internal/extent.h index 775f89bb..a286fa9a 100644 --- a/include/jemalloc/internal/extent.h +++ b/include/jemalloc/internal/extent.h @@ -21,6 +21,9 @@ struct extent_s { /* True if extent is active (in use). */ bool e_active; + /* True if extent is dirty (touched). */ + bool e_dirty; + /* * The zeroed flag is used by chunk recycling code to track whether * memory is zero-filled. @@ -86,6 +89,7 @@ void *extent_addr_get(const extent_t *extent); size_t extent_size_get(const extent_t *extent); void *extent_past_get(const extent_t *extent); bool extent_active_get(const extent_t *extent); +bool extent_dirty_get(const extent_t *extent); bool extent_retained_get(const extent_t *extent); bool extent_zeroed_get(const extent_t *extent); bool extent_committed_get(const extent_t *extent); @@ -95,12 +99,14 @@ void extent_arena_set(extent_t *extent, arena_t *arena); void extent_addr_set(extent_t *extent, void *addr); void extent_size_set(extent_t *extent, size_t size); void extent_active_set(extent_t *extent, bool active); +void extent_dirty_set(extent_t *extent, bool dirty); void extent_zeroed_set(extent_t *extent, bool zeroed); void extent_committed_set(extent_t *extent, bool committed); 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, bool slab); + size_t size, bool active, bool dirty, 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); @@ -142,6 +148,13 @@ extent_active_get(const extent_t *extent) return (extent->e_active); } +JEMALLOC_INLINE bool +extent_dirty_get(const extent_t *extent) +{ + + return (extent->e_dirty); +} + JEMALLOC_INLINE bool extent_retained_get(const extent_t *extent) { @@ -205,6 +218,13 @@ extent_active_set(extent_t *extent, bool active) extent->e_active = active; } +JEMALLOC_INLINE void +extent_dirty_set(extent_t *extent, bool dirty) +{ + + extent->e_dirty = dirty; +} + JEMALLOC_INLINE void extent_zeroed_set(extent_t *extent, bool zeroed) { @@ -235,13 +255,14 @@ 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 slab) + bool active, bool dirty, bool zeroed, bool committed, bool slab) { extent_arena_set(extent, arena); extent_addr_set(extent, addr); extent_size_set(extent, size); extent_active_set(extent, active); + extent_dirty_set(extent, dirty); extent_zeroed_set(extent, zeroed); extent_committed_set(extent, committed); extent_slab_set(extent, slab); diff --git a/include/jemalloc/internal/private_symbols.txt b/include/jemalloc/internal/private_symbols.txt index 8998aed9..02bef63e 100644 --- a/include/jemalloc/internal/private_symbols.txt +++ b/include/jemalloc/internal/private_symbols.txt @@ -215,8 +215,10 @@ extent_arena_set extent_committed_get extent_committed_set extent_dalloc +extent_dirty_get extent_dirty_insert extent_dirty_remove +extent_dirty_set extent_init extent_past_get extent_prof_tctx_get diff --git a/src/arena.c b/src/arena.c index 17cf973a..a08a3245 100644 --- a/src/arena.c +++ b/src/arena.c @@ -1644,7 +1644,7 @@ arena_purge_to_limit(tsdn_t *tsdn, arena_t *arena, size_t ndirty_limit) arena->lg_dirty_mult) < arena->ndirty || ndirty_limit == 0); qr_new(&purge_runs_sentinel, rd_link); - extent_init(&purge_chunks_sentinel, arena, NULL, 0, false, false, + extent_init(&purge_chunks_sentinel, arena, NULL, 0, false, false, false, false, false); npurge = arena_stash_dirty(tsdn, arena, &chunk_hooks, ndirty_limit, diff --git a/src/base.c b/src/base.c index 518f966c..225f522b 100644 --- a/src/base.c +++ b/src/base.c @@ -74,7 +74,7 @@ base_chunk_alloc(tsdn_t *tsdn, size_t minsize) base_resident += PAGE_CEILING(nsize); } } - extent_init(extent, NULL, addr, csize, true, true, true, false); + extent_init(extent, NULL, addr, csize, true, false, true, true, false); return (extent); } diff --git a/src/chunk.c b/src/chunk.c index 2ec12b4b..c1094ff4 100644 --- a/src/chunk.c +++ b/src/chunk.c @@ -553,7 +553,7 @@ chunk_alloc_wrapper_hard(tsdn_t *tsdn, arena_t *arena, arena->ind); if (addr == NULL) return (NULL); - extent_init(extent, arena, addr, size, true, zero, commit, slab); + extent_init(extent, arena, addr, size, true, false, zero, commit, slab); if (chunk_register(tsdn, extent)) { chunk_leak(tsdn, arena, chunk_hooks, false, extent); return (NULL); @@ -828,8 +828,9 @@ chunk_split_wrapper(tsdn_t *tsdn, arena_t *arena, chunk_hooks_t *chunk_hooks, extent_t lead; extent_init(&lead, arena, extent_addr_get(extent), size_a, - extent_active_get(extent), extent_zeroed_get(extent), - extent_committed_get(extent), extent_slab_get(extent)); + extent_active_get(extent), extent_dirty_get(extent), + extent_zeroed_get(extent), extent_committed_get(extent), + extent_slab_get(extent)); if (extent_rtree_acquire(tsdn, &lead, false, true, &lead_elm_a, &lead_elm_b)) @@ -838,8 +839,8 @@ chunk_split_wrapper(tsdn_t *tsdn, arena_t *arena, chunk_hooks_t *chunk_hooks, extent_init(trail, arena, (void *)((uintptr_t)extent_addr_get(extent) + size_a), CHUNK_CEILING(size_b), extent_active_get(extent), - extent_zeroed_get(extent), extent_committed_get(extent), - extent_slab_get(extent)); + extent_dirty_get(extent), extent_zeroed_get(extent), + extent_committed_get(extent), extent_slab_get(extent)); if (extent_rtree_acquire(tsdn, trail, false, true, &trail_elm_a, &trail_elm_b)) goto label_error_c; diff --git a/src/chunk_dss.c b/src/chunk_dss.c index 251f17b8..6b90c53e 100644 --- a/src/chunk_dss.c +++ b/src/chunk_dss.c @@ -126,7 +126,7 @@ chunk_alloc_dss(tsdn_t *tsdn, arena_t *arena, void *new_addr, size_t size, return (NULL); } extent_init(cpad, arena, cpad_addr, cpad_size, - false, false, true, false); + false, true, false, true, false); } dss_next = (void *)((uintptr_t)ret + size); if ((uintptr_t)ret < (uintptr_t)dss_max ||