Linux-ARM-Kernel Archive on lore.kernel.org
 help / color / mirror / Atom feed
From: "Christophe Leroy (CS GROUP)" <chleroy@kernel.org>
To: Pedro Falcato <pfalcato@suse.de>,
	David Hildenbrand <david@kernel.org>,
	Andrew Morton <akpm@linux-foundation.org>
Cc: Catalin Marinas <catalin.marinas@arm.com>,
	Will Deacon <will@kernel.org>,
	"James E.J. Bottomley" <James.Bottomley@HansenPartnership.com>,
	Helge Deller <deller@gmx.de>,
	Madhavan Srinivasan <maddy@linux.ibm.com>,
	Michael Ellerman <mpe@ellerman.id.au>,
	Lorenzo Stoakes <ljs@kernel.org>,
	"Liam R. Howlett" <liam@infradead.org>,
	Vlastimil Babka <vbabka@kernel.org>,
	Mike Rapoport <rppt@kernel.org>,
	Suren Baghdasaryan <surenb@google.com>,
	Michal Hocko <mhocko@suse.com>,
	"Matthew Wilcox (Oracle)" <willy@infradead.org>,
	Jan Kara <jack@suse.cz>, Zi Yan <ziy@nvidia.com>,
	Baolin Wang <baolin.wang@linux.alibaba.com>,
	Nico Pache <npache@redhat.com>,
	Ryan Roberts <ryan.roberts@arm.com>, Dev Jain <dev.jain@arm.com>,
	Barry Song <baohua@kernel.org>, Lance Yang <lance.yang@linux.dev>,
	Usama Arif <usama.arif@linux.dev>,
	Kevin Brodsky <kevin.brodsky@arm.com>,
	Muhammad Usama Anjum <usama.anjum@arm.com>,
	linux-arm-kernel@lists.infradead.org,
	linux-kernel@vger.kernel.org, linux-parisc@vger.kernel.org,
	linuxppc-dev@lists.ozlabs.org, linux-mm@kvack.org,
	linux-fsdevel@vger.kernel.org
Subject: Re: [PATCH v2 0/6] mm: add basic PTE const type-safety
Date: Tue, 4 Aug 2026 08:55:32 +0200	[thread overview]
Message-ID: <d031d9f5-b248-4251-9214-448b7be5bd3e@kernel.org> (raw)
In-Reply-To: <20260803164400.531199-1-pfalcato@suse.de>



Le 03/08/2026 à 18:43, Pedro Falcato a écrit :
> Since forever, MM code has thrown pte_t * around with no concern for const
> safety, or typesafety of any kind. This is confusing. Attempt to address it
> by:

What do you mean by "typesafety of any kind" ?

On powerpc64, pte_t is a struct so you can't play-up too much with it.

On powerpc32, pte_t is a long int because having it as a struct is 
counter-performant, but we have it as a struct when __CHECKER__ is 
defined, ie when doing a sparse check with 'make C=2'.


> 1) Making sure pte_get*() helpers can cope with const pte_t * arguments
> 2) Constifying the pte_offset_map_ro_nolock() return type, which by definition
> already pledges that users will not write to it.
> 
> These two simple steps were already able to uncover code smell from
> khugepaged + do_swap_page().
> 
> Separate steps could include introducing pte_offset_map_ro_lock() for more
> widespread usage of this.
> 
> Benefits of this include less confusion and better type-safety. It could also
> futurely aid in efforts such as [0] which may want semantic annotation of these
> accesses.
> 
> Based on mm-unstable and compile-tested on a handful of architectures.
> 
> No functional changes intended.
> 

For the series,

Reviewed-by: Christophe Leroy (CS GROUP) <chleroy@kernel.org>



> [CC list editorially trimmed for brevity reasons; apologies if you're not on it]
> 
> Link: https://lore.kernel.org/linux-mm/20260526-kpkeys-v8-0-eaaacdacc67c@arm.com/#t [0]
> Cc: Catalin Marinas <catalin.marinas@arm.com>
> Cc: Will Deacon <will@kernel.org>
> Cc: "James E.J. Bottomley" <James.Bottomley@HansenPartnership.com>
> Cc: Helge Deller <deller@gmx.de>
> Cc: Madhavan Srinivasan <maddy@linux.ibm.com>
> Cc: Michael Ellerman <mpe@ellerman.id.au>
> Cc: Lorenzo Stoakes <ljs@kernel.org>
> Cc: "Liam R. Howlett" <liam@infradead.org>
> Cc: Vlastimil Babka <vbabka@kernel.org>
> Cc: Mike Rapoport <rppt@kernel.org>
> Cc: Suren Baghdasaryan <surenb@google.com>
> Cc: Michal Hocko <mhocko@suse.com>
> Cc: "Matthew Wilcox (Oracle)" <willy@infradead.org>
> Cc: Jan Kara <jack@suse.cz>
> Cc: Zi Yan <ziy@nvidia.com>
> Cc: Baolin Wang <baolin.wang@linux.alibaba.com>
> Cc: Nico Pache <npache@redhat.com>
> Cc: Ryan Roberts <ryan.roberts@arm.com>
> Cc: Dev Jain <dev.jain@arm.com>
> Cc: Barry Song <baohua@kernel.org>
> Cc: Lance Yang <lance.yang@linux.dev>
> Cc: Usama Arif <usama.arif@linux.dev>
> Cc: Kevin Brodsky <kevin.brodsky@arm.com>
> Cc: Muhammad Usama Anjum <usama.anjum@arm.com>
> Cc: linux-arm-kernel@lists.infradead.org
> Cc: linux-kernel@vger.kernel.org
> Cc: linux-parisc@vger.kernel.org
> Cc: linuxppc-dev@lists.ozlabs.org
> Cc: linux-mm@kvack.org
> Cc: linux-fsdevel@vger.kernel.org
> 
> v2:
>   - Small fixups on the arm64 side
>   - Re-order patches in a way such that bisection is preserved
>   - Pick up Helge's patch dropping parisc ptep_get()
>   - Constify s390's ptep_get() as well
> 
> Helge Deller (1):
>    parisc: Drop own implementations for ptep_get() and
>      ptep_test_and_clear_young()
> 
> Pedro Falcato (5):
>    mm/arm64: constify pte_get*() and contpte get logic
>    mm/powerpc/8xx: constify ptep_get() argument
>    mm/s390: constify ptep_get() argument
>    mm: constify generic pte_get*()
>    mm: constify the pte_offset_map_ro_nolock() return value
> 
>   arch/arm64/include/asm/pgtable.h             | 10 +++++-----
>   arch/arm64/mm/contpte.c                      | 11 ++++++++---
>   arch/parisc/include/asm/pgtable.h            | 20 --------------------
>   arch/powerpc/include/asm/nohash/32/pte-8xx.h |  2 +-
>   arch/powerpc/mm/pgtable.c                    |  2 +-
>   arch/s390/include/asm/pgtable.h              |  2 +-
>   include/linux/mm.h                           |  4 ++--
>   include/linux/pgtable.h                      |  8 ++++----
>   mm/filemap.c                                 |  2 +-
>   mm/khugepaged.c                              |  2 +-
>   mm/pgtable-generic.c                         |  4 ++--
>   11 files changed, 26 insertions(+), 41 deletions(-)
> 



      parent reply	other threads:[~2026-08-04  6:55 UTC|newest]

Thread overview: 27+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-08-03 16:43 [PATCH v2 0/6] mm: add basic PTE const type-safety Pedro Falcato
2026-08-03 16:43 ` [PATCH v2 1/6] mm/arm64: constify pte_get*() and contpte get logic Pedro Falcato
2026-08-04 10:55   ` Lorenzo Stoakes (ARM)
2026-08-04 12:31     ` Pedro Falcato
2026-08-04 12:36       ` Lorenzo Stoakes (ARM)
2026-08-03 16:43 ` [PATCH v2 2/6] parisc: Drop own implementations for ptep_get() and ptep_test_and_clear_young() Pedro Falcato
2026-08-04 11:11   ` Lorenzo Stoakes (ARM)
2026-08-04 12:34     ` Pedro Falcato
2026-08-04 12:42       ` Lorenzo Stoakes (ARM)
2026-08-04 13:00         ` Helge Deller
2026-08-04 13:03           ` Lorenzo Stoakes (ARM)
2026-08-03 16:43 ` [PATCH v2 3/6] mm/powerpc/8xx: constify ptep_get() argument Pedro Falcato
2026-08-04 11:13   ` Lorenzo Stoakes (ARM)
2026-08-04 12:38     ` Pedro Falcato
2026-08-04 12:43       ` Lorenzo Stoakes (ARM)
2026-08-04 12:50     ` Christophe Leroy (CS GROUP)
2026-08-04 12:59       ` Lorenzo Stoakes (ARM)
2026-08-04 13:08         ` LEROY Christophe
2026-08-04 13:09         ` Christophe Leroy (CS GROUP)
2026-08-03 16:43 ` [PATCH v2 4/6] mm/s390: " Pedro Falcato
2026-08-04 11:14   ` Lorenzo Stoakes (ARM)
2026-08-03 16:43 ` [PATCH v2 5/6] mm: constify generic pte_get*() Pedro Falcato
2026-08-04 11:15   ` Lorenzo Stoakes (ARM)
2026-08-03 16:44 ` [PATCH v2 6/6] mm: constify the pte_offset_map_ro_nolock() return value Pedro Falcato
2026-08-04 11:22   ` Lorenzo Stoakes (ARM)
2026-08-03 18:38 ` [PATCH v2 0/6] mm: add basic PTE const type-safety Muhammad Usama Anjum
2026-08-04  6:55 ` Christophe Leroy (CS GROUP) [this message]

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=d031d9f5-b248-4251-9214-448b7be5bd3e@kernel.org \
    --to=chleroy@kernel.org \
    --cc=James.Bottomley@HansenPartnership.com \
    --cc=akpm@linux-foundation.org \
    --cc=baohua@kernel.org \
    --cc=baolin.wang@linux.alibaba.com \
    --cc=catalin.marinas@arm.com \
    --cc=david@kernel.org \
    --cc=deller@gmx.de \
    --cc=dev.jain@arm.com \
    --cc=jack@suse.cz \
    --cc=kevin.brodsky@arm.com \
    --cc=lance.yang@linux.dev \
    --cc=liam@infradead.org \
    --cc=linux-arm-kernel@lists.infradead.org \
    --cc=linux-fsdevel@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-mm@kvack.org \
    --cc=linux-parisc@vger.kernel.org \
    --cc=linuxppc-dev@lists.ozlabs.org \
    --cc=ljs@kernel.org \
    --cc=maddy@linux.ibm.com \
    --cc=mhocko@suse.com \
    --cc=mpe@ellerman.id.au \
    --cc=npache@redhat.com \
    --cc=pfalcato@suse.de \
    --cc=rppt@kernel.org \
    --cc=ryan.roberts@arm.com \
    --cc=surenb@google.com \
    --cc=usama.anjum@arm.com \
    --cc=usama.arif@linux.dev \
    --cc=vbabka@kernel.org \
    --cc=will@kernel.org \
    --cc=willy@infradead.org \
    --cc=ziy@nvidia.com \
    /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