Add/use chunk_decommit_wrapper().
This commit is contained in:
parent
4d2d9cec5a
commit
56e0031d7d
@ -66,6 +66,9 @@ void chunk_dalloc_cache(tsdn_t *tsdn, arena_t *arena,
|
|||||||
void chunk_dalloc_wrapper(tsdn_t *tsdn, arena_t *arena,
|
void chunk_dalloc_wrapper(tsdn_t *tsdn, arena_t *arena,
|
||||||
chunk_hooks_t *chunk_hooks, void *chunk, size_t size, bool zeroed,
|
chunk_hooks_t *chunk_hooks, void *chunk, size_t size, bool zeroed,
|
||||||
bool committed);
|
bool committed);
|
||||||
|
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);
|
||||||
bool chunk_purge_wrapper(tsdn_t *tsdn, arena_t *arena,
|
bool chunk_purge_wrapper(tsdn_t *tsdn, arena_t *arena,
|
||||||
chunk_hooks_t *chunk_hooks, void *chunk, size_t size, size_t offset,
|
chunk_hooks_t *chunk_hooks, void *chunk, size_t size, size_t offset,
|
||||||
size_t length);
|
size_t length);
|
||||||
|
@ -162,6 +162,7 @@ chunk_boot
|
|||||||
chunk_dalloc_cache
|
chunk_dalloc_cache
|
||||||
chunk_dalloc_mmap
|
chunk_dalloc_mmap
|
||||||
chunk_dalloc_wrapper
|
chunk_dalloc_wrapper
|
||||||
|
chunk_decommit_wrapper
|
||||||
chunk_deregister
|
chunk_deregister
|
||||||
chunk_dss_boot
|
chunk_dss_boot
|
||||||
chunk_dss_postfork_child
|
chunk_dss_postfork_child
|
||||||
|
14
src/arena.c
14
src/arena.c
@ -552,8 +552,8 @@ arena_chunk_alloc_internal_hard(tsdn_t *tsdn, arena_t *arena,
|
|||||||
if (chunk != NULL && arena_chunk_register(tsdn, arena, chunk, *zero)) {
|
if (chunk != NULL && arena_chunk_register(tsdn, arena, chunk, *zero)) {
|
||||||
if (!*commit) {
|
if (!*commit) {
|
||||||
/* Undo commit of header. */
|
/* Undo commit of header. */
|
||||||
chunk_hooks->decommit(chunk, chunksize, 0, map_bias <<
|
chunk_decommit_wrapper(tsdn, arena, chunk_hooks,
|
||||||
LG_PAGE, arena->ind);
|
chunk, chunksize, 0, map_bias << LG_PAGE);
|
||||||
}
|
}
|
||||||
chunk_dalloc_wrapper(tsdn, arena, chunk_hooks, (void *)chunk,
|
chunk_dalloc_wrapper(tsdn, arena, chunk_hooks, (void *)chunk,
|
||||||
chunksize, *zero, *commit);
|
chunksize, *zero, *commit);
|
||||||
@ -675,9 +675,8 @@ arena_chunk_discard(tsdn_t *tsdn, arena_t *arena, arena_chunk_t *chunk)
|
|||||||
* chunk as committed has a high potential for causing later
|
* chunk as committed has a high potential for causing later
|
||||||
* access of decommitted memory.
|
* access of decommitted memory.
|
||||||
*/
|
*/
|
||||||
chunk_hooks = chunk_hooks_get(tsdn, arena);
|
chunk_decommit_wrapper(tsdn, arena, &chunk_hooks, chunk,
|
||||||
chunk_hooks.decommit(chunk, chunksize, 0, map_bias << LG_PAGE,
|
chunksize, 0, map_bias << LG_PAGE);
|
||||||
arena->ind);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
chunk_dalloc_cache(tsdn, arena, &chunk_hooks, (void *)chunk, chunksize,
|
chunk_dalloc_cache(tsdn, arena, &chunk_hooks, (void *)chunk, chunksize,
|
||||||
@ -1603,8 +1602,9 @@ arena_purge_stashed(tsdn_t *tsdn, arena_t *arena, chunk_hooks_t *chunk_hooks,
|
|||||||
assert(!arena_mapbits_decommitted_get(chunk, pageind));
|
assert(!arena_mapbits_decommitted_get(chunk, pageind));
|
||||||
assert(!arena_mapbits_decommitted_get(chunk,
|
assert(!arena_mapbits_decommitted_get(chunk,
|
||||||
pageind+npages-1));
|
pageind+npages-1));
|
||||||
decommitted = !chunk_hooks->decommit(chunk, chunksize,
|
decommitted = !chunk_decommit_wrapper(tsdn, arena,
|
||||||
pageind << LG_PAGE, npages << LG_PAGE, arena->ind);
|
chunk_hooks, chunk, chunksize, pageind << LG_PAGE,
|
||||||
|
npages << LG_PAGE);
|
||||||
if (decommitted) {
|
if (decommitted) {
|
||||||
flag_unzeroed = 0;
|
flag_unzeroed = 0;
|
||||||
flags = CHUNK_MAP_DECOMMITTED;
|
flags = CHUNK_MAP_DECOMMITTED;
|
||||||
|
@ -752,6 +752,15 @@ chunk_decommit_default(void *chunk, size_t size, size_t offset, size_t length,
|
|||||||
length));
|
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_assure_initialized(tsdn, arena, chunk_hooks);
|
||||||
|
return (chunk_hooks->decommit(chunk, size, offset, length, arena->ind));
|
||||||
|
}
|
||||||
|
|
||||||
static bool
|
static bool
|
||||||
chunk_purge_default(void *chunk, size_t size, size_t offset, size_t length,
|
chunk_purge_default(void *chunk, size_t size, size_t offset, size_t length,
|
||||||
unsigned arena_ind)
|
unsigned arena_ind)
|
||||||
|
Loading…
Reference in New Issue
Block a user