From 5c6be2bdd33d1eb9d544f46f128ba93d05a01492 Mon Sep 17 00:00:00 2001 From: Jason Evans Date: Mon, 23 May 2016 15:10:25 -0700 Subject: [PATCH] Refactor chunk_purge_wrapper() to take extent argument. --- include/jemalloc/internal/chunk.h | 3 +-- src/arena.c | 4 ++-- src/chunk.c | 9 +++++---- src/huge.c | 6 ++---- 4 files changed, 10 insertions(+), 12 deletions(-) diff --git a/include/jemalloc/internal/chunk.h b/include/jemalloc/internal/chunk.h index 085b43c0..5f5629eb 100644 --- a/include/jemalloc/internal/chunk.h +++ b/include/jemalloc/internal/chunk.h @@ -67,8 +67,7 @@ bool chunk_commit_wrapper(tsdn_t *tsdn, arena_t *arena, bool chunk_decommit_wrapper(tsdn_t *tsdn, arena_t *arena, chunk_hooks_t *chunk_hooks, extent_t *extent, size_t offset, size_t length); bool chunk_purge_wrapper(tsdn_t *tsdn, arena_t *arena, - chunk_hooks_t *chunk_hooks, void *chunk, size_t size, size_t offset, - size_t length); + chunk_hooks_t *chunk_hooks, extent_t *extent, size_t offset, size_t length); extent_t *chunk_split_wrapper(tsdn_t *tsdn, arena_t *arena, chunk_hooks_t *chunk_hooks, extent_t *extent, size_t size_a, size_t size_b); bool chunk_merge_wrapper(tsdn_t *tsdn, arena_t *arena, diff --git a/src/arena.c b/src/arena.c index 24793549..de3024da 100644 --- a/src/arena.c +++ b/src/arena.c @@ -1542,8 +1542,8 @@ arena_purge_stashed(tsdn_t *tsdn, arena_t *arena, chunk_hooks_t *chunk_hooks, flags = CHUNK_MAP_DECOMMITTED; } else { flag_unzeroed = chunk_purge_wrapper(tsdn, arena, - chunk_hooks, chunk, chunksize, pageind << - LG_PAGE, run_size) ? CHUNK_MAP_UNZEROED : 0; + chunk_hooks, extent, pageind << LG_PAGE, + run_size) ? CHUNK_MAP_UNZEROED : 0; flags = flag_unzeroed; } arena_mapbits_large_set(chunk, pageind+npages-1, 0, diff --git a/src/chunk.c b/src/chunk.c index 363ce8f7..d20c2dfb 100644 --- a/src/chunk.c +++ b/src/chunk.c @@ -281,8 +281,7 @@ chunk_leak(tsdn_t *tsdn, arena_t *arena, chunk_hooks_t *chunk_hooks, bool cache, * that this is only a virtual memory leak. */ if (cache) { - chunk_purge_wrapper(tsdn, arena, chunk_hooks, - extent_addr_get(extent), extent_size_get(extent), 0, + chunk_purge_wrapper(tsdn, arena, chunk_hooks, extent, 0, extent_size_get(extent)); } extent_dalloc(tsdn, arena, extent); @@ -739,11 +738,13 @@ chunk_purge_default(void *chunk, size_t size, size_t offset, size_t length, bool chunk_purge_wrapper(tsdn_t *tsdn, arena_t *arena, chunk_hooks_t *chunk_hooks, - void *chunk, size_t size, size_t offset, size_t length) + extent_t *extent, size_t offset, size_t length) { chunk_hooks_assure_initialized(tsdn, arena, chunk_hooks); - return (chunk_hooks->purge(chunk, size, offset, length, arena->ind)); + return (chunk_hooks->purge(extent_addr_get(extent), + CHUNK_CEILING(extent_size_get(extent)), offset, length, + arena->ind)); } static bool diff --git a/src/huge.c b/src/huge.c index 880e4333..70383144 100644 --- a/src/huge.c +++ b/src/huge.c @@ -115,8 +115,7 @@ huge_ralloc_no_move_similar(tsdn_t *tsdn, extent_t *extent, size_t usize_min, post_zeroed = false; } else { post_zeroed = !chunk_purge_wrapper(tsdn, arena, - &chunk_hooks, extent_addr_get(extent), - CHUNK_CEILING(oldsize), usize, sdiff); + &chunk_hooks, extent, usize, sdiff); } } else post_zeroed = pre_zeroed; @@ -183,8 +182,7 @@ huge_ralloc_no_move_shrink(tsdn_t *tsdn, extent_t *extent, size_t usize) post_zeroed = false; } else { post_zeroed = !chunk_purge_wrapper(tsdn, arena, - &chunk_hooks, extent_addr_get(extent), - CHUNK_CEILING(usize), usize, sdiff); + &chunk_hooks, extent, usize, sdiff); if (config_fill && unlikely(opt_zero) && !post_zeroed) { memset((void *)