Linux-mm Archive on lore.kernel.org
 help / color / mirror / Atom feed
From: Tianyi Chen <hi@tychen.cc>
To: rppt@kernel.org
Cc: Tianyi Chen <hi@tychen.cc>,
	Andrew Morton <akpm@linux-foundation.org>,
	linux-mm@kvack.org, linux-kernel@vger.kernel.org
Subject: [PATCH 1/2] memblock tests: model the low allocation limit within dummy memory
Date: Sun,  6 Sep 2026 22:40:10 +0800	[thread overview]
Message-ID: <20260906144011.848898-1-hi@tychen.cc> (raw)

The simulator represents physical addresses using the address of its
allocated buffer. That buffer can lie above the default
ARCH_LOW_ADDRESS_LIMIT, preventing meaningful memblock_alloc_low()
tests.

Use the existing architecture override in asm/dma.h to place the limit
halfway through the dummy memory buffer. Resolve it after the buffer
has been allocated, so both low and high memory can be represented
regardless of its address. The production allocator is unchanged.

Assisted-by: LLM
Signed-off-by: Tianyi Chen <hi@tychen.cc>
---
 tools/testing/memblock/asm/dma.h      | 6 ++++++
 tools/testing/memblock/tests/common.c | 5 +++++
 2 files changed, 11 insertions(+)

diff --git a/tools/testing/memblock/asm/dma.h b/tools/testing/memblock/asm/dma.h
index 13ff8e5d22e..6607408dcf2 100644
--- a/tools/testing/memblock/asm/dma.h
+++ b/tools/testing/memblock/asm/dma.h
@@ -2,4 +2,10 @@
 #ifndef _TOOLS_DMA_H
 #define _TOOLS_DMA_H
 
+#include <linux/types.h>
+
+phys_addr_t dummy_physical_memory_low_limit(void);
+
+#define ARCH_LOW_ADDRESS_LIMIT dummy_physical_memory_low_limit()
+
 #endif
diff --git a/tools/testing/memblock/tests/common.c b/tools/testing/memblock/tests/common.c
index 3250c8e5124..4e6a920c459 100644
--- a/tools/testing/memblock/tests/common.c
+++ b/tools/testing/memblock/tests/common.c
@@ -118,6 +118,11 @@ phys_addr_t dummy_physical_memory_base(void)
 	return (phys_addr_t)memory_block.base;
 }
 
+phys_addr_t dummy_physical_memory_low_limit(void)
+{
+	return dummy_physical_memory_base() + MEM_SIZE / 2;
+}
+
 static void usage(const char *prog)
 {
 	BUILD_BUG_ON(ARRAY_SIZE(help_opts) != ARRAY_SIZE(long_opts) - 1);
-- 
2.55.0



             reply	other threads:[~2026-09-06 14:40 UTC|newest]

Thread overview: 12+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-09-06 14:40 Tianyi Chen [this message]
2026-09-06 14:40 ` [PATCH 2/2] memblock tests: cover allocations below the low address limit Tianyi Chen
2026-09-06 20:29   ` Mike Rapoport
2026-09-06 20:21 ` [PATCH 1/2] memblock tests: model the low allocation limit within dummy memory Mike Rapoport
2026-09-07  1:20   ` Tianyi Chen
2026-09-07  1:20 ` [PATCH v2 0/2] memblock tests: cover low-address allocations Tianyi Chen
2026-09-07  1:20   ` [PATCH v2 1/2] memblock tests: model the low allocation limit within dummy memory Tianyi Chen
2026-09-09 17:14     ` Mike Rapoport
2026-09-07  1:20   ` [PATCH v2 2/2] memblock tests: cover allocations below the low address limit Tianyi Chen
2026-09-09 17:14     ` Mike Rapoport
2026-09-09 17:31   ` [PATCH v2 0/2] memblock tests: cover low-address allocations Mike Rapoport
2026-09-09 23:55     ` 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=20260906144011.848898-1-hi@tychen.cc \
    --to=hi@tychen.cc \
    --cc=akpm@linux-foundation.org \
    --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