Fix in-place shrinking huge reallocation purging bugs.
Fix the shrinking case of huge_ralloc_no_move_similar() to purge the correct number of pages, at the correct offset. This regression was introduced by8d6a3e8321
(Implement dynamic per arena control over dirty page purging.). Fix huge_ralloc_no_move_shrink() to purge the correct number of pages. This bug was introduced by9673983443
(Purge/zero sub-chunk huge allocations as necessary.).
This commit is contained in:
parent
562d266511
commit
65db63cf3f
@ -1245,16 +1245,11 @@ arena_purge_stashed(arena_t *arena,
|
|||||||
|
|
||||||
if (rdelm == &chunkselm->rd) {
|
if (rdelm == &chunkselm->rd) {
|
||||||
size_t size = extent_node_size_get(chunkselm);
|
size_t size = extent_node_size_get(chunkselm);
|
||||||
void *addr, *chunk;
|
|
||||||
size_t offset;
|
|
||||||
bool unzeroed;
|
bool unzeroed;
|
||||||
|
|
||||||
npages = size >> LG_PAGE;
|
npages = size >> LG_PAGE;
|
||||||
addr = extent_node_addr_get(chunkselm);
|
|
||||||
chunk = CHUNK_ADDR2BASE(addr);
|
|
||||||
offset = CHUNK_ADDR2OFFSET(addr);
|
|
||||||
unzeroed = chunk_purge_wrapper(arena, chunk_purge,
|
unzeroed = chunk_purge_wrapper(arena, chunk_purge,
|
||||||
chunk, offset, size);
|
extent_node_addr_get(chunkselm), 0, size);
|
||||||
extent_node_zeroed_set(chunkselm, !unzeroed);
|
extent_node_zeroed_set(chunkselm, !unzeroed);
|
||||||
chunkselm = qr_next(chunkselm, cc_link);
|
chunkselm = qr_next(chunkselm, cc_link);
|
||||||
} else {
|
} else {
|
||||||
|
31
src/huge.c
31
src/huge.c
@ -145,12 +145,11 @@ huge_ralloc_no_move_similar(void *ptr, size_t oldsize, size_t usize,
|
|||||||
|
|
||||||
/* Fill if necessary (shrinking). */
|
/* Fill if necessary (shrinking). */
|
||||||
if (oldsize > usize) {
|
if (oldsize > usize) {
|
||||||
size_t sdiff = CHUNK_CEILING(usize) - usize;
|
size_t sdiff = oldsize - usize;
|
||||||
zeroed = (sdiff != 0) ? !chunk_purge_wrapper(arena, chunk_purge,
|
zeroed = !chunk_purge_wrapper(arena, chunk_purge, ptr, usize,
|
||||||
CHUNK_ADDR2BASE(ptr), CHUNK_ADDR2OFFSET(ptr), usize) : true;
|
sdiff);
|
||||||
if (config_fill && unlikely(opt_junk_free)) {
|
if (config_fill && unlikely(opt_junk_free)) {
|
||||||
memset((void *)((uintptr_t)ptr + usize), 0x5a, oldsize -
|
memset((void *)((uintptr_t)ptr + usize), 0x5a, sdiff);
|
||||||
usize);
|
|
||||||
zeroed = false;
|
zeroed = false;
|
||||||
}
|
}
|
||||||
} else
|
} else
|
||||||
@ -186,7 +185,6 @@ huge_ralloc_no_move_shrink(void *ptr, size_t oldsize, size_t usize)
|
|||||||
extent_node_t *node;
|
extent_node_t *node;
|
||||||
arena_t *arena;
|
arena_t *arena;
|
||||||
chunk_purge_t *chunk_purge;
|
chunk_purge_t *chunk_purge;
|
||||||
size_t sdiff;
|
|
||||||
bool zeroed;
|
bool zeroed;
|
||||||
|
|
||||||
node = huge_node_get(ptr);
|
node = huge_node_get(ptr);
|
||||||
@ -196,15 +194,18 @@ huge_ralloc_no_move_shrink(void *ptr, size_t oldsize, size_t usize)
|
|||||||
chunk_purge = arena->chunk_purge;
|
chunk_purge = arena->chunk_purge;
|
||||||
malloc_mutex_unlock(&arena->lock);
|
malloc_mutex_unlock(&arena->lock);
|
||||||
|
|
||||||
sdiff = CHUNK_CEILING(usize) - usize;
|
if (oldsize > usize) {
|
||||||
zeroed = (sdiff != 0) ? !chunk_purge_wrapper(arena, chunk_purge,
|
size_t sdiff = oldsize - usize;
|
||||||
CHUNK_ADDR2BASE((uintptr_t)ptr + usize),
|
zeroed = !chunk_purge_wrapper(arena, chunk_purge,
|
||||||
CHUNK_ADDR2OFFSET((uintptr_t)ptr + usize), sdiff) : true;
|
CHUNK_ADDR2BASE((uintptr_t)ptr + usize),
|
||||||
if (config_fill && unlikely(opt_junk_free)) {
|
CHUNK_ADDR2OFFSET((uintptr_t)ptr + usize), sdiff);
|
||||||
huge_dalloc_junk((void *)((uintptr_t)ptr + usize), oldsize -
|
if (config_fill && unlikely(opt_junk_free)) {
|
||||||
usize);
|
huge_dalloc_junk((void *)((uintptr_t)ptr + usize),
|
||||||
zeroed = false;
|
sdiff);
|
||||||
}
|
zeroed = false;
|
||||||
|
}
|
||||||
|
} else
|
||||||
|
zeroed = true;
|
||||||
|
|
||||||
malloc_mutex_lock(&arena->huge_mtx);
|
malloc_mutex_lock(&arena->huge_mtx);
|
||||||
/* Update the size of the huge allocation. */
|
/* Update the size of the huge allocation. */
|
||||||
|
Loading…
Reference in New Issue
Block a user