[PATCH v2 0/2] memblock tests: cover low-address allocations

From: Tianyi Chen

Date: Sun Sep 06 2026 - 21:20:48 EST


Model a low allocation limit within the dummy memory registered with
memblock, then exercise memblock_alloc_low() in both allocation directions.

Changes in v2, following Mike Rapoport's review:
- Clarify why the limit splits MEM_SIZE, the region registered by
setup_memblock(), rather than the larger PHYS_MEM_SIZE malloc buffer.
- Explain why the malloc-backed base still needs alignment.
- Describe the boundary in terms of the last usable byte and clarify
that reserving low memory succeeds; the following allocation fails.
- Update Assisted-by tags to the required tool:model format.

No allocator or test behavior changes from v1.

Validation with the existing Makefile and ASan/UBSan enabled:
- Default, NUMA=1, 32BIT_PHYS_ADDR_T=1, 32BIT_PHYS_ADDR_T=1 with NUMA=1,
and MEMBLOCK_DEBUG=1 with NUMA=1 builds passed.
- Each configuration passed both ./main -v and ./main -v -m.
- A separate BUILD=32 run still hits the pre-existing
memblock_free_near_max_check assertion in basic_api.c, also seen on
the baseline. This is distinct from the passing 32-bit physical-address
configuration above.

v1: https://lore.kernel.org/r/20260906144011.848898-1-hi@xxxxxxxxx
Review: https://lore.kernel.org/r/ap3LTQlKTpDbAEJZ@xxxxxxxxxx
Review: https://lore.kernel.org/r/ap3NJsaG10rLDVpd@xxxxxxxxxx

Tianyi Chen (2):
memblock tests: model the low allocation limit within dummy memory
memblock tests: cover allocations below the low address limit

tools/testing/memblock/Makefile | 3 +-
tools/testing/memblock/README | 14 +-
tools/testing/memblock/TODO | 5 -
tools/testing/memblock/asm/dma.h | 6 +
tools/testing/memblock/main.c | 2 +
tools/testing/memblock/tests/alloc_low_api.c | 148 +++++++++++++++++++
tools/testing/memblock/tests/alloc_low_api.h | 9 ++
tools/testing/memblock/tests/common.c | 6 +
8 files changed, 180 insertions(+), 13 deletions(-)
delete mode 100644 tools/testing/memblock/TODO
create mode 100644 tools/testing/memblock/tests/alloc_low_api.c
create mode 100644 tools/testing/memblock/tests/alloc_low_api.h

--
2.55.0