[PATCH v2 1/8] memblock: Introduce MEMBLOCK_PTEMAP

Mike Rapoport rppt at kernel.org
Wed Oct 28 10:08:50 PDT 2026


On Mon, Sep 21, 2026 at 12:00:43PM +0100, Vincent Donnefort wrote:
> Keeping PTE-level mappings is interesting on some architectures as it
> allows mapping/unmapping pages from the kernel direct map without the
> risk of splitting blocks which, under the break-before-make rule, may
> trigger page-faults the kernel can't handle.

Let's be honest, it's arm64 :)
 
I believe that some powerpc variants could use this too, but they don't
have break-before-make, so either "some architectures" or
"break-before-make" should be rephrased.

> However, mapping the entire direct map at PTE-level is costly. So
> instead, create a new memblock flag MEMBLOCK_PTEMAP to selectively apply
> a PTE-level mapping.
> 
> Signed-off-by: Vincent Donnefort <vdonnefort at google.com>
> ---
>  include/linux/memblock.h | 18 ++++++++++++++++++
>  mm/memblock.c            | 30 ++++++++++++++++++++++++++++++
>  2 files changed, 48 insertions(+)
> 
> diff --git a/include/linux/memblock.h b/include/linux/memblock.h
> index aa845f488327..13263055996d 100644
> --- a/include/linux/memblock.h
> +++ b/include/linux/memblock.h

...

> @@ -285,8 +289,16 @@ static inline bool memblock_is_mirror(struct memblock_region *m)
>  	return m->flags & MEMBLOCK_MIRROR;
>  }
>  
> +static inline void memblock_warn_invalid_map_flags(struct memblock_region *m)
> +{
> +	enum memblock_flags map_flags = MEMBLOCK_NOMAP | MEMBLOCK_PTEMAP;
> +
> +	WARN_ON_ONCE((m->flags & map_flags) == map_flags);
> +}
> +
>  static inline bool memblock_is_nomap(struct memblock_region *m)
>  {
> +	memblock_warn_invalid_map_flags(m);

I think it's better to check and warn when setting an incompatible flag
rather than when querying it.

>  	return m->flags & MEMBLOCK_NOMAP;
>  }

-- 
Sincerely yours,
Mike.



More information about the linux-arm-kernel mailing list