Refactor chunk_[de]commit_wrapper() to take extent arguments.

This commit is contained in:
Jason Evans 2016-05-23 15:04:40 -07:00
parent 6c94470822
commit 0eb6f08959
3 changed files with 14 additions and 16 deletions

View File

@ -63,11 +63,9 @@ void chunk_dalloc_cache(tsdn_t *tsdn, arena_t *arena,
void chunk_dalloc_wrapper(tsdn_t *tsdn, arena_t *arena,
chunk_hooks_t *chunk_hooks, extent_t *extent);
bool chunk_commit_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);
bool chunk_decommit_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);
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);

View File

@ -440,7 +440,7 @@ arena_run_split_large_helper(tsdn_t *tsdn, arena_t *arena, extent_t *extent,
assert(need_pages > 0);
if (flag_decommitted != 0 && chunk_commit_wrapper(tsdn, arena,
&arena->chunk_hooks, chunk, chunksize, run_ind << LG_PAGE, size))
&arena->chunk_hooks, extent, run_ind << LG_PAGE, size))
return (true);
if (remove) {
@ -523,7 +523,7 @@ arena_run_split_small(tsdn_t *tsdn, arena_t *arena, extent_t *extent,
assert(need_pages > 0);
if (flag_decommitted != 0 && chunk_commit_wrapper(tsdn, arena,
&arena->chunk_hooks, chunk, chunksize, run_ind << LG_PAGE, size))
&arena->chunk_hooks, extent, run_ind << LG_PAGE, size))
return (true);
arena_run_split_remove(arena, chunk, run_ind, flag_dirty,
@ -578,8 +578,7 @@ arena_chunk_alloc_internal_hard(tsdn_t *tsdn, arena_t *arena,
chunksize, zero, commit);
if (extent != NULL && !*commit) {
/* Commit header. */
if (chunk_commit_wrapper(tsdn, arena, chunk_hooks,
extent_addr_get(extent), extent_size_get(extent), 0,
if (chunk_commit_wrapper(tsdn, arena, chunk_hooks, extent, 0,
map_bias << LG_PAGE)) {
chunk_dalloc_wrapper(tsdn, arena, chunk_hooks, extent);
extent = NULL;
@ -708,8 +707,7 @@ arena_chunk_discard(tsdn_t *tsdn, arena_t *arena, extent_t *extent)
* chunk as committed has a high potential for causing later
* access of decommitted memory.
*/
chunk_decommit_wrapper(tsdn, arena, &chunk_hooks,
extent_addr_get(extent), extent_size_get(extent), 0,
chunk_decommit_wrapper(tsdn, arena, &chunk_hooks, extent, 0,
map_bias << LG_PAGE);
}
@ -1537,8 +1535,8 @@ arena_purge_stashed(tsdn_t *tsdn, arena_t *arena, chunk_hooks_t *chunk_hooks,
assert(!arena_mapbits_decommitted_get(chunk,
pageind+npages-1));
decommitted = !chunk_decommit_wrapper(tsdn, arena,
chunk_hooks, chunk, chunksize, pageind << LG_PAGE,
npages << LG_PAGE);
chunk_hooks, extent, pageind << LG_PAGE, npages <<
LG_PAGE);
if (decommitted) {
flag_unzeroed = 0;
flags = CHUNK_MAP_DECOMMITTED;

View File

@ -695,11 +695,12 @@ chunk_commit_default(void *chunk, size_t size, size_t offset, size_t length,
bool
chunk_commit_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->commit(chunk, size, offset, length, arena->ind));
return (chunk_hooks->commit(extent_addr_get(extent),
extent_size_get(extent), offset, length, arena->ind));
}
static bool
@ -713,11 +714,12 @@ chunk_decommit_default(void *chunk, size_t size, size_t offset, size_t length,
bool
chunk_decommit_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->decommit(chunk, size, offset, length, arena->ind));
return (chunk_hooks->decommit(extent_addr_get(extent),
extent_size_get(extent), offset, length, arena->ind));
}
static bool