From: Tianyi Chen <hi@tychen.cc>
To: Mike Rapoport <rppt@kernel.org>
Cc: linux-mm@kvack.org, linux-kernel@vger.kernel.org
Subject: [PATCH 1/2] memblock tests: use physical free for the maximum-address check
Date: Thu, 17 Sep 2026 00:11:04 +0800 [thread overview]
Message-ID: <20260916161105.2548281-2-hi@tychen.cc> (raw)
In-Reply-To: <20260916161105.2548281-1-hi@tychen.cc>
With BUILD=32, phys_addr_t remains 64-bit while pointers are 32-bit.
Casting the address near PHYS_ADDR_MAX to void * truncates it before
memblock_free() converts it back with __pa(). The reserved region is
therefore left unchanged and memblock_free_near_max_check() fails.
Use memblock_phys_free() for this synthetic physical range and retain
the checks that freeing past PHYS_ADDR_MAX clips the removed region.
Fixes: 21a233f68afe ("memblock tests: add additional tests for basic api and memblock_alloc")
Assisted-by: LLM
Signed-off-by: Tianyi Chen <hi@tychen.cc>
---
tools/testing/memblock/tests/basic_api.c | 6 +++---
1 file changed, 3 insertions(+), 3 deletions(-)
diff --git a/tools/testing/memblock/tests/basic_api.c b/tools/testing/memblock/tests/basic_api.c
index 01e836fba488..dfca0153b6b1 100644
--- a/tools/testing/memblock/tests/basic_api.c
+++ b/tools/testing/memblock/tests/basic_api.c
@@ -2003,7 +2003,7 @@ static int memblock_free_only_region_check(void)
* Expect the total size of reserved memory to be updated and the counter to
* not be updated.
*/
-static int memblock_free_near_max_check(void)
+static int memblock_phys_free_near_max_check(void)
{
struct memblock_region *rgn;
phys_addr_t total_size;
@@ -2026,7 +2026,7 @@ static int memblock_free_near_max_check(void)
reset_memblock_regions();
memblock_reserve(r1.base, r1.size);
- memblock_free((void *)r2.base, r2.size);
+ memblock_phys_free(r2.base, r2.size);
ASSERT_EQ(rgn->base, r1.base);
ASSERT_EQ(rgn->size, total_size);
@@ -2114,7 +2114,7 @@ static int memblock_free_checks(void)
memblock_free_overlap_bottom_check();
memblock_free_within_check();
memblock_free_only_region_check();
- memblock_free_near_max_check();
+ memblock_phys_free_near_max_check();
memblock_free_overlap_two_check();
prefix_pop();
--
2.55.0
next prev parent reply other threads:[~2026-09-16 16:23 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-09-16 16:11 [PATCH 0/2] memblock tests: fix BUILD=32 address conversions Tianyi Chen
2026-09-16 16:11 ` Tianyi Chen [this message]
2026-09-16 16:11 ` [PATCH 2/2] memblock tests: zero-extend simulated memory addresses Tianyi Chen
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20260916161105.2548281-2-hi@tychen.cc \
--to=hi@tychen.cc \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-mm@kvack.org \
--cc=rppt@kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
all inboxes | Powered by JetHome®