Skip to content

memblock tests: fix BUILD=32 address conversions and warnings

Tianyi Chen linux-mm lkml 2 versions – Applied

Status from this message: Applied to for-next branch of memblock.git tree, thanks!

Get series with b4
b4 am [email protected]

Versions newest first · linked by author and title

  1. v2 Latest4 patches 1 replyApplied
  2. v12 patches 2 repliesSuperseded

Changes in v2 from the cover letter

- Use memblock_phys_free() for all synthetic physical ranges in the basic API tests, not only the maximum-address check.
- Keep the dummy-memory address conversion fix unchanged.
- Use __pa() in tools virt_to_phys() to avoid a pointer-size warning and sign extension of 32-bit pointers with their top bit set.
- Initialize end_rgn to avoid GCC's maybe-uninitialized warning.

Patches in v2 Applied

#Subject and filesSizeRepliesApplied
1/4memblock tests: use physical addresses for region removaltools/testing/memblock/tests/basic_api.c+10 -100 replies
2/4memblock tests: zero-extend simulated memory addressestools/testing/memblock/tests/common.c+3 -30 replies
3/4tools: use __pa() in virt_to_phys()tools/include/linux/mm.h+1 -10 replies
4/4memblock: initialize the region merge end indexmm/memblock.c+1 -10 replies

Reviews trailers per patch

No Reviewed-by, Acked-by or Tested-by trailers for v2 yet.

Read the v2 thread

Cover letter [PATCH v2 0/4] memblock tests: fix BUILD=32 address conversions and warnings

Fix the BUILD=32 physical-address truncation and sign-extension failures, and address the remaining GCC warnings reported during review.

Changes in v2:
- Use memblock_phys_free() for all synthetic physical ranges in the basic API tests, not only the maximum-address check.
- Keep the dummy-memory address conversion fix unchanged.
- Use __pa() in tools virt_to_phys() to avoid a pointer-size warning and sign extension of 32-bit pointers with their top bit set.
- Initialize end_rgn to avoid GCC's maybe-uninitialized warning.

Clang BUILD=32 without NUMA also passes on v1 (189 checks). The earlier cover letter only mentioned the NUMA-enabled configuration tested then.

Validated v2 with GCC 13.3.0 and Clang 18.1.3, retaining the default ASan and UBSan flags and adding -Werror. Both compilers build without warnings and pass ./main -v and ./main -m -v in each configuration:
- Default and NUMA=1.
- BUILD=32, with and without NUMA=1.
- 32BIT_PHYS_ADDR_T=1, with and without NUMA=1.
- BUILD=32 NUMA=1 MEMBLOCK_DEBUG=1.

Each run passes 189 checks without NUMA or 272 with NUMA, including both allocation directions. A separate virt_to_phys() boundary check passes with both compilers in 32- and 64-bit builds; GCC BUILD=32 failed it on v1 for 0x80000000 due to sign extension.

v1: https://lore.kernel.org/r/[email protected]

Tianyi Chen (4):
memblock tests: use physical addresses for region removal memblock tests: zero-extend simulated memory addresses
tools: use __pa() in virt_to_phys()
memblock: initialize the region merge end index

 mm/memblock.c                            |  2 +-
 tools/include/linux/mm.h                 |  2 +-
 tools/testing/memblock/tests/basic_api.c | 20 ++++++++++----------
 tools/testing/memblock/tests/common.c    |  6 +++---
 4 files changed, 15 insertions(+), 15 deletions(-)

base-commit: 5728d3523f12826a2b180c1c5738f74e33197e14

Signature · 1 line
2.55.0