memalign: Support scanning for aligned chunks.
commit24cdd6c71debfd10a9f7cb217fe2a2c4c486ed6f
authorDJ Delorie <dj@redhat.com>
Wed, 29 Mar 2023 04:18:40 +0000 (29 00:18 -0400)
committerDJ Delorie <dj@redhat.com>
Wed, 29 Mar 2023 20:36:03 +0000 (29 16:36 -0400)
tree67fb2733a20d3358f82f92f3e976ab1ec8d09be9
parent998fba01b254be6c1848da4900454a3bc309cb69
memalign: Support scanning for aligned chunks.

This patch adds a chunk scanning algorithm to the _int_memalign code
path that reduces heap fragmentation by reusing already aligned chunks
instead of always looking for chunks of larger sizes and splitting
them.  The tcache macros are extended to allow removing a chunk from
the middle of the list.

The goal is to fix the pathological use cases where heaps grow
continuously in workloads that are heavy users of memalign.

Note that tst-memalign-2 checks for tcache operation, which
malloc-check bypasses.

Reviewed-by: Adhemerval Zanella <adhemerval.zanella@linaro.org>
malloc/Makefile
malloc/malloc.c
malloc/tst-memalign-2.c [new file with mode: 0644]