Re: [PATCH 1/2] memblock tests: model the low allocation limit within dummy memory

From: Mike Rapoport

Date: Sun Sep 06 2026 - 16:21:41 EST


On Sun, Sep 06, 2026 at 10:40:10PM +0800, Tianyi Chen wrote:
> 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

Please add LLM attribution as per

https://docs.kernel.org/process/coding-assistants.html#attribution

> Signed-off-by: Tianyi Chen <hi@xxxxxxxxx>
> ---
> 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;

Shouldn't this be PHYS_MEM_SIZE?

> +}
> +
> static void usage(const char *prog)
> {
> BUILD_BUG_ON(ARRAY_SIZE(help_opts) != ARRAY_SIZE(long_opts) - 1);
> --
> 2.55.0
>
>

--
Sincerely yours,
Mike.