Fix huge_ralloc_no_move() to succeed more often.
Fix huge_ralloc_no_move() to succeed if an allocation request results in the same usable size as the existing allocation, even if the request size is smaller than the usable size. This bug did not cause correctness issues, but it could cause unnecessary moves during reallocation.
This commit is contained in:
parent
87ccb55547
commit
40cbd30d50
@ -298,7 +298,7 @@ huge_ralloc_no_move(void *ptr, size_t oldsize, size_t size, size_t extra,
|
|||||||
* the new size.
|
* the new size.
|
||||||
*/
|
*/
|
||||||
if (CHUNK_CEILING(oldsize) >= CHUNK_CEILING(usize)
|
if (CHUNK_CEILING(oldsize) >= CHUNK_CEILING(usize)
|
||||||
&& CHUNK_CEILING(oldsize) <= CHUNK_CEILING(size+extra)) {
|
&& CHUNK_CEILING(oldsize) <= CHUNK_CEILING(s2u(size+extra))) {
|
||||||
huge_ralloc_no_move_similar(ptr, oldsize, usize, size, extra,
|
huge_ralloc_no_move_similar(ptr, oldsize, usize, size, extra,
|
||||||
zero);
|
zero);
|
||||||
return (false);
|
return (false);
|
||||||
|
@ -55,8 +55,9 @@ validate_fill(const void *p, uint8_t c, size_t offset, size_t len)
|
|||||||
for (i = 0; i < len; i++) {
|
for (i = 0; i < len; i++) {
|
||||||
uint8_t b = buf[offset+i];
|
uint8_t b = buf[offset+i];
|
||||||
if (b != c) {
|
if (b != c) {
|
||||||
test_fail("Allocation at %p contains %#x rather than "
|
test_fail("Allocation at %p (len=%zu) contains %#x "
|
||||||
"%#x at offset %zu", p, b, c, offset+i);
|
"rather than %#x at offset %zu", p, len, b, c,
|
||||||
|
offset+i);
|
||||||
ret = true;
|
ret = true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user