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

From: Tianyi Chen

Date: Wed Sep 09 2026 - 20:02:58 EST


Model a low allocation limit within the memory registered by the simulator,
then exercise memblock_alloc_low() in both allocation directions.

Changes in v3:
- Describe the low limit and simulated RAM alignment directly in comments
and README.
- Use Assisted-by: LLM in both patches.
- Start a separate thread for this revision.

The pointer casts remain unchanged. With BUILD=32, pointers are 32-bit and
phys_addr_t is 64-bit: the tested compiler sign-extends a direct cast, while
the conversion through uintptr_t zero-extends it. The direct casts also
introduce compiler warnings, so this revision preserves the existing
conversion behavior. There are no executable code changes from v2.

Validation with ASan and UBSan enabled:
- Default and 32BIT_PHYS_ADDR_T=1: 189 tests pass in each runtime mode.
- NUMA=1, 32BIT_PHYS_ADDR_T=1 with NUMA=1, and MEMBLOCK_DEBUG=1 with NUMA=1:
272 tests pass in each runtime mode.
- Both ./main -v and ./main -v -m were run for those configurations.
- BUILD=32 builds without warnings from alloc_low_api.c. Its runtime still
hits the pre-existing basic_api.c memblock_free_near_max_check assertion
before reaching the low-allocation tests.

v2: https://lore.kernel.org/r/178874362959.1415955.18132997964995947947.memblock-v2-0@xxxxxxxxx

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 | 12 +-
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, 178 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