Subject: Re: [RFC V1 02/16] mm: Add read-write accessors for vm_page_prot

From: Mike Rapoport <[email-masked]>
Date: Thu, 9 Apr 2026 13:37:55 +0300

Hi Anshuman,

On Tue, Feb 24, 2026 at 10:41:39AM +0530, Anshuman Khandual wrote:
> Currently vma->vm_page_prot is safely read from and written to, without any
> locks with READ_ONCE() and WRITE_ONCE(). But with introduction of D128 page
> tables on arm64 platform, vm_page_prot grows to 128 bits which can't safely
> be handled with READ_ONCE() and WRITE_ONCE().
> 
> Add read and write accessors for vm_page_prot like pgprot_read/write_once()
> which any platform can override when required, although still defaulting as
> READ_ONCE() and WRITE_ONCE(), thus preserving the functionality for others.
> 
> Cc: Andrew Morton <[email-masked]>
> Cc: David Hildenbrand <[email-masked]>
> Cc: Lorenzo Stoakes <[email-masked]>
> Cc: Mike Rapoport <[email-masked]>
> Cc: [email-masked]
> Cc: [email-masked]
> Signed-off-by: Anshuman Khandual <[email-masked]>
> ---
>  include/linux/pgtable.h | 14 ++++++++++++++
>  mm/huge_memory.c        |  4 ++--
>  mm/memory.c             |  2 +-
>  mm/migrate.c            |  2 +-
>  mm/mmap.c               |  2 +-
>  5 files changed, 19 insertions(+), 5 deletions(-)
> 
> diff --git a/include/linux/pgtable.h b/include/linux/pgtable.h
> index da17139a1279..8858b8b03a02 100644
> --- a/include/linux/pgtable.h
> +++ b/include/linux/pgtable.h
> @@ -495,6 +495,20 @@ static inline pgd_t pgdp_get(pgd_t *pgdp)
>  }
>  #endif
>  
> +#ifndef pgprot_read_once
> +static inline pgprot_t pgprot_read_once(pgprot_t *prot)

I don't think we need _once in the helper name. Presence of the helper
already implies that pointer should not be just dereferenced from one side
and that using the helper will do The Right Thing from the other side.

-- 
Sincerely yours,
Mike.