aboutsummaryrefslogtreecommitdiff
path: root/malloc/tst-obstack.c
diff options
context:
space:
mode:
authorSiddhesh Poyarekar <siddhesh@sourceware.org>2023-07-06 11:09:44 -0400
committerSiddhesh Poyarekar <siddhesh@sourceware.org>2023-07-06 11:10:27 -0400
commit2fb12bbd092b0c10f1f2083216e723d2406e21c4 (patch)
tree00a2c18863e3248148c39fc8c362f74818919531 /malloc/tst-obstack.c
parent320ac7eeb47671e03ee26d4419b640fac0312390 (diff)
downloadglibc-2fb12bbd092b0c10f1f2083216e723d2406e21c4.tar
glibc-2fb12bbd092b0c10f1f2083216e723d2406e21c4.tar.gz
glibc-2fb12bbd092b0c10f1f2083216e723d2406e21c4.tar.bz2
glibc-2fb12bbd092b0c10f1f2083216e723d2406e21c4.zip
realloc: Limit chunk reuse to only growing requests [BZ #30579]
The trim_threshold is too aggressive a heuristic to decide if chunk reuse is OK for reallocated memory; for repeated small, shrinking allocations it leads to internal fragmentation and for repeated larger allocations that fragmentation may blow up even worse due to the dynamic nature of the threshold. Limit reuse only when it is within the alignment padding, which is 2 * size_t for heap allocations and a page size for mmapped allocations. There's the added wrinkle of THP, but this fix ignores it for now, pessimizing that case in favor of keeping fragmentation low. This resolves BZ #30579. Signed-off-by: Siddhesh Poyarekar <siddhesh@sourceware.org> Reported-by: Nicolas Dusart <nicolas@freedelity.be> Reported-by: Aurelien Jarno <aurelien@aurel32.net> Reviewed-by: Aurelien Jarno <aurelien@aurel32.net> Tested-by: Aurelien Jarno <aurelien@aurel32.net>
Diffstat (limited to 'malloc/tst-obstack.c')
0 files changed, 0 insertions, 0 deletions