[PATCH v2 0/7] tlsf: use 8-byte alignment for normal malloc allocations

Ahmad Fatoum a.fatoum at pengutronix.de
Mon Sep 11 08:24:26 PDT 2023


TLSF currently uses only 4-byte alignment on 32-bit platforms, which isn't
enough for ldrd/strd on ARMv7. This series reworks TLSF a bit, so we always
have at least 8 byte alignment.  dlmalloc already has 8 byte alignment
minimum, so nothing to do there.

This has the added benefit of giving TLSF the same alignment as KASAN,
which can make debugging easier.

v1 didn't actually manage to boot on an i.MX6, which v2 fixes. This
also boots normally on i.MX8M. I suggest this going into next after
v2023.09.0.

v1 -> v2:
  - drop switch of test_ffs_fls to bselftest. This function should just
    be replaced with barebox' own implementation in future
  - keep block size a size_t and just ensure the block metadata is
    correctly aligned.

Ahmad Fatoum (7):
  tlsf: turn static const variables into compiletime constant
    expressions
  tlsf: ensure malloc pool is aligned
  tlsf: fix sizeof(size_t) == sizeof(void *) assumption
  tlsf: give malloc 8-byte alignment on 32-bit as well
  common: malloc: ensure alignment is always at least 8 byte
  test: self: refactor to allow alignment check
  test: self: malloc: fix memory leaks

 common/Kconfig         |  5 +++
 common/dlmalloc.c      |  3 ++
 common/dummy_malloc.c  |  2 +-
 common/tlsf.c          | 43 ++++++++++---------
 include/linux/bitops.h |  1 +
 test/self/malloc.c     | 96 ++++++++++++++++++++++++++++++------------
 6 files changed, 102 insertions(+), 48 deletions(-)

-- 
2.39.2




More information about the barebox mailing list