Linux PARISC architecture development
 help / color / mirror / Atom feed
* [PATCH 0/5] mm: add basic PTE const type-safety
@ 2026-07-24 10:20 Pedro Falcato
  2026-07-24 10:20 ` [PATCH 1/5] mm: constify generic pte_get*() Pedro Falcato
                   ` (4 more replies)
  0 siblings, 5 replies; 12+ messages in thread
From: Pedro Falcato @ 2026-07-24 10:20 UTC (permalink / raw)
  To: Andrew Morton, David Hildenbrand
  Cc: Pedro Falcato, Catalin Marinas, Will Deacon, James E.J. Bottomley,
	Helge Deller, Madhavan Srinivasan, Michael Ellerman,
	Lorenzo Stoakes, Liam R. Howlett, Vlastimil Babka, Mike Rapoport,
	Suren Baghdasaryan, Michal Hocko, Matthew Wilcox (Oracle),
	Jan Kara, Zi Yan, Baolin Wang, Nico Pache, Ryan Roberts, Dev Jain,
	Barry Song, Lance Yang, Usama Arif, Kevin Brodsky,
	Muhammad Usama Anjum, linux-arm-kernel, linux-kernel,
	linux-parisc, linuxppc-dev, linux-mm, linux-fsdevel

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:
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.

[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

Pedro Falcato (5):
  mm: constify generic pte_get*()
  mm/arm64: constify pte_get*() and contpte get logic
  mm/parisc: constify ptep_get() argument
  mm/powerpc/8xx: constify ptep_get() argument
  mm: constify the pte_offset_map_ro_nolock() return value

 arch/arm64/include/asm/pgtable.h             | 10 +++++-----
 arch/arm64/mm/contpte.c                      |  4 ++--
 arch/parisc/include/asm/pgtable.h            |  2 +-
 arch/powerpc/include/asm/nohash/32/pte-8xx.h |  2 +-
 arch/powerpc/mm/pgtable.c                    |  2 +-
 include/linux/mm.h                           |  4 ++--
 include/linux/pgtable.h                      |  8 ++++----
 mm/filemap.c                                 |  2 +-
 mm/khugepaged.c                              |  2 +-
 mm/pgtable-generic.c                         |  4 ++--
 10 files changed, 20 insertions(+), 20 deletions(-)

-- 
2.55.0


^ permalink raw reply	[flat|nested] 12+ messages in thread

* [PATCH 1/5] mm: constify generic pte_get*()
  2026-07-24 10:20 [PATCH 0/5] mm: add basic PTE const type-safety Pedro Falcato
@ 2026-07-24 10:20 ` Pedro Falcato
  2026-07-24 10:20 ` [PATCH 2/5] mm/arm64: constify pte_get*() and contpte get logic Pedro Falcato
                   ` (3 subsequent siblings)
  4 siblings, 0 replies; 12+ messages in thread
From: Pedro Falcato @ 2026-07-24 10:20 UTC (permalink / raw)
  To: Andrew Morton, David Hildenbrand
  Cc: Pedro Falcato, Catalin Marinas, Will Deacon, James E.J. Bottomley,
	Helge Deller, Madhavan Srinivasan, Michael Ellerman,
	Lorenzo Stoakes, Liam R. Howlett, Vlastimil Babka, Mike Rapoport,
	Suren Baghdasaryan, Michal Hocko, Matthew Wilcox (Oracle),
	Jan Kara, Zi Yan, Baolin Wang, Nico Pache, Ryan Roberts, Dev Jain,
	Barry Song, Lance Yang, Usama Arif, Kevin Brodsky,
	Muhammad Usama Anjum, linux-arm-kernel, linux-kernel,
	linux-parisc, linuxppc-dev, linux-mm, linux-fsdevel

None of the helpers need write access to the PTE. Constifying the param
allows for const typesafety.

Signed-off-by: Pedro Falcato <pfalcato@suse.de>
---
 include/linux/pgtable.h | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

diff --git a/include/linux/pgtable.h b/include/linux/pgtable.h
index 8c093c119e5a..dc418553e57a 100644
--- a/include/linux/pgtable.h
+++ b/include/linux/pgtable.h
@@ -490,7 +490,7 @@ static inline int pudp_set_access_flags(struct vm_area_struct *vma,
 #endif
 
 #ifndef ptep_get
-static inline pte_t ptep_get(pte_t *ptep)
+static inline pte_t ptep_get(const pte_t *ptep)
 {
 	return READ_ONCE(*ptep);
 }
@@ -739,7 +739,7 @@ static inline void ptep_clear(struct mm_struct *mm, unsigned long addr,
  * present bit set *unless* it is 'l'. Because get_user_pages_fast() only
  * operates on present ptes we're safe.
  */
-static inline pte_t ptep_get_lockless(pte_t *ptep)
+static inline pte_t ptep_get_lockless(const pte_t *ptep)
 {
 	pte_t pte;
 
@@ -777,7 +777,7 @@ static inline pmd_t pmdp_get_lockless(pmd_t *pmdp)
  * We require that the PTE can be read atomically.
  */
 #ifndef ptep_get_lockless
-static inline pte_t ptep_get_lockless(pte_t *ptep)
+static inline pte_t ptep_get_lockless(const pte_t *ptep)
 {
 	return ptep_get(ptep);
 }
-- 
2.55.0


^ permalink raw reply related	[flat|nested] 12+ messages in thread

* [PATCH 2/5] mm/arm64: constify pte_get*() and contpte get logic
  2026-07-24 10:20 [PATCH 0/5] mm: add basic PTE const type-safety Pedro Falcato
  2026-07-24 10:20 ` [PATCH 1/5] mm: constify generic pte_get*() Pedro Falcato
@ 2026-07-24 10:20 ` Pedro Falcato
  2026-07-24 10:20 ` [PATCH 3/5] mm/parisc: constify ptep_get() argument Pedro Falcato
                   ` (2 subsequent siblings)
  4 siblings, 0 replies; 12+ messages in thread
From: Pedro Falcato @ 2026-07-24 10:20 UTC (permalink / raw)
  To: Andrew Morton, David Hildenbrand
  Cc: Pedro Falcato, Catalin Marinas, Will Deacon, James E.J. Bottomley,
	Helge Deller, Madhavan Srinivasan, Michael Ellerman,
	Lorenzo Stoakes, Liam R. Howlett, Vlastimil Babka, Mike Rapoport,
	Suren Baghdasaryan, Michal Hocko, Matthew Wilcox (Oracle),
	Jan Kara, Zi Yan, Baolin Wang, Nico Pache, Ryan Roberts, Dev Jain,
	Barry Song, Lance Yang, Usama Arif, Kevin Brodsky,
	Muhammad Usama Anjum, linux-arm-kernel, linux-kernel,
	linux-parisc, linuxppc-dev, linux-mm, linux-fsdevel

None of the contpte code needs write access to the PTEs.

Signed-off-by: Pedro Falcato <pfalcato@suse.de>
---
 arch/arm64/include/asm/pgtable.h | 10 +++++-----
 arch/arm64/mm/contpte.c          |  4 ++--
 2 files changed, 7 insertions(+), 7 deletions(-)

diff --git a/arch/arm64/include/asm/pgtable.h b/arch/arm64/include/asm/pgtable.h
index a2681d755358..043bc0649cee 100644
--- a/arch/arm64/include/asm/pgtable.h
+++ b/arch/arm64/include/asm/pgtable.h
@@ -378,7 +378,7 @@ static inline void __set_pte(pte_t *ptep, pte_t pte)
 	__set_pte_complete(pte);
 }
 
-static inline pte_t __ptep_get(pte_t *ptep)
+static inline pte_t __ptep_get(const pte_t *ptep)
 {
 	return READ_ONCE(*ptep);
 }
@@ -1652,8 +1652,8 @@ extern void __contpte_try_fold(struct mm_struct *mm, unsigned long addr,
 				pte_t *ptep, pte_t pte);
 extern void __contpte_try_unfold(struct mm_struct *mm, unsigned long addr,
 				pte_t *ptep, pte_t pte);
-extern pte_t contpte_ptep_get(pte_t *ptep, pte_t orig_pte);
-extern pte_t contpte_ptep_get_lockless(pte_t *orig_ptep);
+extern pte_t contpte_ptep_get(const pte_t *ptep, pte_t orig_pte);
+extern pte_t contpte_ptep_get_lockless(const pte_t *orig_ptep);
 extern void contpte_set_ptes(struct mm_struct *mm, unsigned long addr,
 				pte_t *ptep, pte_t pte, unsigned int nr);
 extern void contpte_clear_full_ptes(struct mm_struct *mm, unsigned long addr,
@@ -1732,7 +1732,7 @@ static inline unsigned int pte_batch_hint(pte_t *ptep, pte_t pte)
  */
 
 #define ptep_get ptep_get
-static inline pte_t ptep_get(pte_t *ptep)
+static inline pte_t ptep_get(const pte_t *ptep)
 {
 	pte_t pte = __ptep_get(ptep);
 
@@ -1743,7 +1743,7 @@ static inline pte_t ptep_get(pte_t *ptep)
 }
 
 #define ptep_get_lockless ptep_get_lockless
-static inline pte_t ptep_get_lockless(pte_t *ptep)
+static inline pte_t ptep_get_lockless(const pte_t *ptep)
 {
 	pte_t pte = __ptep_get(ptep);
 
diff --git a/arch/arm64/mm/contpte.c b/arch/arm64/mm/contpte.c
index 2de12656b4d8..3853ecd2cee9 100644
--- a/arch/arm64/mm/contpte.c
+++ b/arch/arm64/mm/contpte.c
@@ -310,7 +310,7 @@ void __contpte_try_unfold(struct mm_struct *mm, unsigned long addr,
 }
 EXPORT_SYMBOL_GPL(__contpte_try_unfold);
 
-pte_t contpte_ptep_get(pte_t *ptep, pte_t orig_pte)
+pte_t contpte_ptep_get(const pte_t *ptep, pte_t orig_pte)
 {
 	/*
 	 * Gather access/dirty bits, which may be populated in any of the ptes
@@ -367,7 +367,7 @@ static inline bool contpte_is_consistent(pte_t pte, unsigned long pfn,
 			pgprot_val(prot) == pgprot_val(orig_prot);
 }
 
-pte_t contpte_ptep_get_lockless(pte_t *orig_ptep)
+pte_t contpte_ptep_get_lockless(const pte_t *orig_ptep)
 {
 	/*
 	 * The ptep_get_lockless() API requires us to read and return *orig_ptep
-- 
2.55.0


^ permalink raw reply related	[flat|nested] 12+ messages in thread

* [PATCH 3/5] mm/parisc: constify ptep_get() argument
  2026-07-24 10:20 [PATCH 0/5] mm: add basic PTE const type-safety Pedro Falcato
  2026-07-24 10:20 ` [PATCH 1/5] mm: constify generic pte_get*() Pedro Falcato
  2026-07-24 10:20 ` [PATCH 2/5] mm/arm64: constify pte_get*() and contpte get logic Pedro Falcato
@ 2026-07-24 10:20 ` Pedro Falcato
  2026-07-24 13:36   ` Usama Arif
  2026-07-24 10:20 ` [PATCH 4/5] mm/powerpc/8xx: " Pedro Falcato
  2026-07-24 10:20 ` [PATCH 5/5] mm: constify the pte_offset_map_ro_nolock() return value Pedro Falcato
  4 siblings, 1 reply; 12+ messages in thread
From: Pedro Falcato @ 2026-07-24 10:20 UTC (permalink / raw)
  To: Andrew Morton, David Hildenbrand
  Cc: Pedro Falcato, Catalin Marinas, Will Deacon, James E.J. Bottomley,
	Helge Deller, Madhavan Srinivasan, Michael Ellerman,
	Lorenzo Stoakes, Liam R. Howlett, Vlastimil Babka, Mike Rapoport,
	Suren Baghdasaryan, Michal Hocko, Matthew Wilcox (Oracle),
	Jan Kara, Zi Yan, Baolin Wang, Nico Pache, Ryan Roberts, Dev Jain,
	Barry Song, Lance Yang, Usama Arif, Kevin Brodsky,
	Muhammad Usama Anjum, linux-arm-kernel, linux-kernel,
	linux-parisc, linuxppc-dev, linux-mm, linux-fsdevel

ptep_get() does not need write access to the PTE.

Signed-off-by: Pedro Falcato <pfalcato@suse.de>
---
 arch/parisc/include/asm/pgtable.h | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/arch/parisc/include/asm/pgtable.h b/arch/parisc/include/asm/pgtable.h
index 467b8547ac8b..83f8333ad099 100644
--- a/arch/parisc/include/asm/pgtable.h
+++ b/arch/parisc/include/asm/pgtable.h
@@ -432,7 +432,7 @@ static inline pte_t pte_swp_clear_exclusive(pte_t pte)
 	return pte;
 }
 
-static inline pte_t ptep_get(pte_t *ptep)
+static inline pte_t ptep_get(const pte_t *ptep)
 {
 	return READ_ONCE(*ptep);
 }
-- 
2.55.0


^ permalink raw reply related	[flat|nested] 12+ messages in thread

* [PATCH 4/5] mm/powerpc/8xx: constify ptep_get() argument
  2026-07-24 10:20 [PATCH 0/5] mm: add basic PTE const type-safety Pedro Falcato
                   ` (2 preceding siblings ...)
  2026-07-24 10:20 ` [PATCH 3/5] mm/parisc: constify ptep_get() argument Pedro Falcato
@ 2026-07-24 10:20 ` Pedro Falcato
  2026-07-24 10:20 ` [PATCH 5/5] mm: constify the pte_offset_map_ro_nolock() return value Pedro Falcato
  4 siblings, 0 replies; 12+ messages in thread
From: Pedro Falcato @ 2026-07-24 10:20 UTC (permalink / raw)
  To: Andrew Morton, David Hildenbrand
  Cc: Pedro Falcato, Catalin Marinas, Will Deacon, James E.J. Bottomley,
	Helge Deller, Madhavan Srinivasan, Michael Ellerman,
	Lorenzo Stoakes, Liam R. Howlett, Vlastimil Babka, Mike Rapoport,
	Suren Baghdasaryan, Michal Hocko, Matthew Wilcox (Oracle),
	Jan Kara, Zi Yan, Baolin Wang, Nico Pache, Ryan Roberts, Dev Jain,
	Barry Song, Lance Yang, Usama Arif, Kevin Brodsky,
	Muhammad Usama Anjum, linux-arm-kernel, linux-kernel,
	linux-parisc, linuxppc-dev, linux-mm, linux-fsdevel

There is no need for write access to the PTE.

Signed-off-by: Pedro Falcato <pfalcato@suse.de>
---
 arch/powerpc/include/asm/nohash/32/pte-8xx.h | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/arch/powerpc/include/asm/nohash/32/pte-8xx.h b/arch/powerpc/include/asm/nohash/32/pte-8xx.h
index e2ea8ba9f8ca..f2bab31040c7 100644
--- a/arch/powerpc/include/asm/nohash/32/pte-8xx.h
+++ b/arch/powerpc/include/asm/nohash/32/pte-8xx.h
@@ -226,7 +226,7 @@ static inline pte_basic_t pte_update(struct mm_struct *mm, unsigned long addr, p
 
 #ifdef CONFIG_PPC_16K_PAGES
 #define ptep_get ptep_get
-static inline pte_t ptep_get(pte_t *ptep)
+static inline pte_t ptep_get(const pte_t *ptep)
 {
 	pte_basic_t val = READ_ONCE(ptep->pte);
 	pte_t pte = {val, val, val, val};
-- 
2.55.0


^ permalink raw reply related	[flat|nested] 12+ messages in thread

* [PATCH 5/5] mm: constify the pte_offset_map_ro_nolock() return value
  2026-07-24 10:20 [PATCH 0/5] mm: add basic PTE const type-safety Pedro Falcato
                   ` (3 preceding siblings ...)
  2026-07-24 10:20 ` [PATCH 4/5] mm/powerpc/8xx: " Pedro Falcato
@ 2026-07-24 10:20 ` Pedro Falcato
  4 siblings, 0 replies; 12+ messages in thread
From: Pedro Falcato @ 2026-07-24 10:20 UTC (permalink / raw)
  To: Andrew Morton, David Hildenbrand
  Cc: Pedro Falcato, Catalin Marinas, Will Deacon, James E.J. Bottomley,
	Helge Deller, Madhavan Srinivasan, Michael Ellerman,
	Lorenzo Stoakes, Liam R. Howlett, Vlastimil Babka, Mike Rapoport,
	Suren Baghdasaryan, Michal Hocko, Matthew Wilcox (Oracle),
	Jan Kara, Zi Yan, Baolin Wang, Nico Pache, Ryan Roberts, Dev Jain,
	Barry Song, Lance Yang, Usama Arif, Kevin Brodsky,
	Muhammad Usama Anjum, linux-arm-kernel, linux-kernel,
	linux-parisc, linuxppc-dev, linux-mm, linux-fsdevel

Constify the pte_t * retval from pte_offset_map_ro_nolock(), for which it is
already pledged that accesses must be read-only. With it, convert the three
treewide users to use const pte_t *.

khugepaged passes the result right down to fault code (do_swap_page()). This
leads to a complicated set of conditions that, in order to be correct, must
not install anything into *vmf->pte. This is not trivial to work around in
fault code, and as such just trivially cast to non-const pte_t* in the
meantime.

The other users are far more trivial and the conversion is equally
trivially simple.

Signed-off-by: Pedro Falcato <pfalcato@suse.de>
---
 arch/powerpc/mm/pgtable.c | 2 +-
 include/linux/mm.h        | 4 ++--
 include/linux/pgtable.h   | 2 +-
 mm/filemap.c              | 2 +-
 mm/khugepaged.c           | 2 +-
 mm/pgtable-generic.c      | 4 ++--
 6 files changed, 8 insertions(+), 8 deletions(-)

diff --git a/arch/powerpc/mm/pgtable.c b/arch/powerpc/mm/pgtable.c
index a9be337be3e4..e29db41b6043 100644
--- a/arch/powerpc/mm/pgtable.c
+++ b/arch/powerpc/mm/pgtable.c
@@ -390,7 +390,7 @@ void assert_pte_locked(struct mm_struct *mm, unsigned long addr)
 	p4d_t *p4d;
 	pud_t *pud;
 	pmd_t *pmd;
-	pte_t *pte;
+	const pte_t *pte;
 	spinlock_t *ptl;
 
 	if (mm == &init_mm)
diff --git a/include/linux/mm.h b/include/linux/mm.h
index 87feaa5a2b78..4b768639d31d 100644
--- a/include/linux/mm.h
+++ b/include/linux/mm.h
@@ -3887,8 +3887,8 @@ static inline pte_t *pte_offset_map(pmd_t *pmd, unsigned long addr)
 pte_t *pte_offset_map_lock(struct mm_struct *mm, pmd_t *pmd,
 			   unsigned long addr, spinlock_t **ptlp);
 
-pte_t *pte_offset_map_ro_nolock(struct mm_struct *mm, pmd_t *pmd,
-				unsigned long addr, spinlock_t **ptlp);
+const pte_t *pte_offset_map_ro_nolock(struct mm_struct *mm, pmd_t *pmd,
+				      unsigned long addr, spinlock_t **ptlp);
 pte_t *pte_offset_map_rw_nolock(struct mm_struct *mm, pmd_t *pmd,
 				unsigned long addr, pmd_t *pmdvalp,
 				spinlock_t **ptlp);
diff --git a/include/linux/pgtable.h b/include/linux/pgtable.h
index dc418553e57a..dd51e722c535 100644
--- a/include/linux/pgtable.h
+++ b/include/linux/pgtable.h
@@ -112,7 +112,7 @@ static inline pte_t *__pte_map(pmd_t *pmd, unsigned long address)
 {
 	return pte_offset_kernel(pmd, address);
 }
-static inline void pte_unmap(pte_t *pte)
+static inline void pte_unmap(const pte_t *pte)
 {
 	rcu_read_unlock();
 }
diff --git a/mm/filemap.c b/mm/filemap.c
index 1dbb4c6f824e..4f0575f13b3a 100644
--- a/mm/filemap.c
+++ b/mm/filemap.c
@@ -3484,7 +3484,7 @@ static vm_fault_t filemap_fault_recheck_pte_none(struct vm_fault *vmf)
 {
 	struct vm_area_struct *vma = vmf->vma;
 	vm_fault_t ret = 0;
-	pte_t *ptep;
+	const pte_t *ptep;
 
 	/*
 	 * We might have COW'ed a pagecache folio and might now have an mlocked
diff --git a/mm/khugepaged.c b/mm/khugepaged.c
index 27e8f3077e80..b87e23ad094f 100644
--- a/mm/khugepaged.c
+++ b/mm/khugepaged.c
@@ -1169,7 +1169,7 @@ static enum scan_result __collapse_huge_page_swapin(struct mm_struct *mm,
 			 * Here the ptl is only used to check pte_same() in
 			 * do_swap_page(), so readonly version is enough.
 			 */
-			pte = pte_offset_map_ro_nolock(mm, pmd, addr, &ptl);
+			pte = (pte_t *) pte_offset_map_ro_nolock(mm, pmd, addr, &ptl);
 			if (!pte) {
 				mmap_read_unlock(mm);
 				result = SCAN_NO_PTE_TABLE;
diff --git a/mm/pgtable-generic.c b/mm/pgtable-generic.c
index b91b1a98029c..2cfc6e608ef4 100644
--- a/mm/pgtable-generic.c
+++ b/mm/pgtable-generic.c
@@ -308,8 +308,8 @@ pte_t *__pte_offset_map(pmd_t *pmd, unsigned long addr, pmd_t *pmdvalp)
 	return NULL;
 }
 
-pte_t *pte_offset_map_ro_nolock(struct mm_struct *mm, pmd_t *pmd,
-				unsigned long addr, spinlock_t **ptlp)
+const pte_t *pte_offset_map_ro_nolock(struct mm_struct *mm, pmd_t *pmd,
+				      unsigned long addr, spinlock_t **ptlp)
 {
 	pmd_t pmdval;
 	pte_t *pte;
-- 
2.55.0


^ permalink raw reply related	[flat|nested] 12+ messages in thread

* Re: [PATCH 3/5] mm/parisc: constify ptep_get() argument
  2026-07-24 10:20 ` [PATCH 3/5] mm/parisc: constify ptep_get() argument Pedro Falcato
@ 2026-07-24 13:36   ` Usama Arif
  2026-07-24 13:39     ` Usama Arif
  2026-07-24 14:14     ` Matthew Wilcox
  0 siblings, 2 replies; 12+ messages in thread
From: Usama Arif @ 2026-07-24 13:36 UTC (permalink / raw)
  To: Pedro Falcato, Andrew Morton, David Hildenbrand
  Cc: Catalin Marinas, Will Deacon, James E.J. Bottomley, Helge Deller,
	Madhavan Srinivasan, Michael Ellerman, Lorenzo Stoakes,
	Liam R. Howlett, Vlastimil Babka, Mike Rapoport,
	Suren Baghdasaryan, Michal Hocko, Matthew Wilcox (Oracle),
	Jan Kara, Zi Yan, Baolin Wang, Nico Pache, Ryan Roberts, Dev Jain,
	Barry Song, Lance Yang, Kevin Brodsky, Muhammad Usama Anjum,
	linux-arm-kernel, linux-kernel, linux-parisc, linuxppc-dev,
	linux-mm, linux-fsdevel



On 24/07/2026 11:20, Pedro Falcato wrote:
> ptep_get() does not need write access to the PTE.
> 
> Signed-off-by: Pedro Falcato <pfalcato@suse.de>
> ---
>  arch/parisc/include/asm/pgtable.h | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
> 
hmm I think you might break build bisectibility if
you separate out the patches, you should squash patch 3 and 4,
with patch 1.

^ permalink raw reply	[flat|nested] 12+ messages in thread

* Re: [PATCH 3/5] mm/parisc: constify ptep_get() argument
  2026-07-24 13:36   ` Usama Arif
@ 2026-07-24 13:39     ` Usama Arif
  2026-07-24 14:14     ` Matthew Wilcox
  1 sibling, 0 replies; 12+ messages in thread
From: Usama Arif @ 2026-07-24 13:39 UTC (permalink / raw)
  To: Pedro Falcato, Andrew Morton, David Hildenbrand
  Cc: Catalin Marinas, Will Deacon, James E.J. Bottomley, Helge Deller,
	Madhavan Srinivasan, Michael Ellerman, Lorenzo Stoakes,
	Liam R. Howlett, Vlastimil Babka, Mike Rapoport,
	Suren Baghdasaryan, Michal Hocko, Matthew Wilcox (Oracle),
	Jan Kara, Zi Yan, Baolin Wang, Nico Pache, Ryan Roberts, Dev Jain,
	Barry Song, Lance Yang, Kevin Brodsky, Muhammad Usama Anjum,
	linux-arm-kernel, linux-kernel, linux-parisc, linuxppc-dev,
	linux-mm, linux-fsdevel



On 24/07/2026 14:36, Usama Arif wrote:
> 
> 
> On 24/07/2026 11:20, Pedro Falcato wrote:
>> ptep_get() does not need write access to the PTE.
>>
>> Signed-off-by: Pedro Falcato <pfalcato@suse.de>
>> ---
>>  arch/parisc/include/asm/pgtable.h | 2 +-
>>  1 file changed, 1 insertion(+), 1 deletion(-)
>>
> hmm I think you might break build bisectibility if
> you separate out the patches, you should squash patch 3 and 4,
> with patch 1.

* squash patch 2, 3 and 4 with patch 1.

^ permalink raw reply	[flat|nested] 12+ messages in thread

* Re: [PATCH 3/5] mm/parisc: constify ptep_get() argument
  2026-07-24 13:36   ` Usama Arif
  2026-07-24 13:39     ` Usama Arif
@ 2026-07-24 14:14     ` Matthew Wilcox
  2026-07-24 15:03       ` Usama Arif
  1 sibling, 1 reply; 12+ messages in thread
From: Matthew Wilcox @ 2026-07-24 14:14 UTC (permalink / raw)
  To: Usama Arif
  Cc: Pedro Falcato, Andrew Morton, David Hildenbrand, Catalin Marinas,
	Will Deacon, James E.J. Bottomley, Helge Deller,
	Madhavan Srinivasan, Michael Ellerman, Lorenzo Stoakes,
	Liam R. Howlett, Vlastimil Babka, Mike Rapoport,
	Suren Baghdasaryan, Michal Hocko, Jan Kara, Zi Yan, Baolin Wang,
	Nico Pache, Ryan Roberts, Dev Jain, Barry Song, Lance Yang,
	Kevin Brodsky, Muhammad Usama Anjum, linux-arm-kernel,
	linux-kernel, linux-parisc, linuxppc-dev, linux-mm, linux-fsdevel

On Fri, Jul 24, 2026 at 02:36:59PM +0100, Usama Arif wrote:
> 
> 
> On 24/07/2026 11:20, Pedro Falcato wrote:
> > ptep_get() does not need write access to the PTE.
> > 
> > Signed-off-by: Pedro Falcato <pfalcato@suse.de>
> > ---
> >  arch/parisc/include/asm/pgtable.h | 2 +-
> >  1 file changed, 1 insertion(+), 1 deletion(-)
> > 
> hmm I think you might break build bisectibility if
> you separate out the patches, you should squash patch 3 and 4,
> with patch 1.

I don't see how this breaks bisectability.  Can you elaborate on what
you think would break?

^ permalink raw reply	[flat|nested] 12+ messages in thread

* Re: [PATCH 3/5] mm/parisc: constify ptep_get() argument
  2026-07-24 14:14     ` Matthew Wilcox
@ 2026-07-24 15:03       ` Usama Arif
  2026-07-24 15:32         ` Pedro Falcato
  0 siblings, 1 reply; 12+ messages in thread
From: Usama Arif @ 2026-07-24 15:03 UTC (permalink / raw)
  To: Matthew Wilcox
  Cc: Pedro Falcato, Andrew Morton, David Hildenbrand, Catalin Marinas,
	Will Deacon, James E.J. Bottomley, Helge Deller,
	Madhavan Srinivasan, Michael Ellerman, Lorenzo Stoakes,
	Liam R. Howlett, Vlastimil Babka, Mike Rapoport,
	Suren Baghdasaryan, Michal Hocko, Jan Kara, Zi Yan, Baolin Wang,
	Nico Pache, Ryan Roberts, Dev Jain, Barry Song, Lance Yang,
	Kevin Brodsky, Muhammad Usama Anjum, linux-arm-kernel,
	linux-kernel, linux-parisc, linuxppc-dev, linux-mm, linux-fsdevel



On 24/07/2026 15:14, Matthew Wilcox wrote:
> On Fri, Jul 24, 2026 at 02:36:59PM +0100, Usama Arif wrote:
>>
>>
>> On 24/07/2026 11:20, Pedro Falcato wrote:
>>> ptep_get() does not need write access to the PTE.
>>>
>>> Signed-off-by: Pedro Falcato <pfalcato@suse.de>
>>> ---
>>>  arch/parisc/include/asm/pgtable.h | 2 +-
>>>  1 file changed, 1 insertion(+), 1 deletion(-)
>>>
>> hmm I think you might break build bisectibility if
>> you separate out the patches, you should squash patch 3 and 4,
>> with patch 1.
> 
> I don't see how this breaks bisectability.  Can you elaborate on what
> you think would break?

Patch 1 does:

-static inline pte_t ptep_get_lockless(pte_t *ptep)
+static inline pte_t ptep_get_lockless(const pte_t *ptep)
 {
 	return ptep_get(ptep);
 }


ptep_get() takes a non-const arg till patch 3 for example for parsic.
I don't think you can pass a const variable to non const function arg?

So parsic won't compile in patch 1 and 2, powerprc wont compile
for patches 1, 2 and 3..





^ permalink raw reply	[flat|nested] 12+ messages in thread

* Re: [PATCH 3/5] mm/parisc: constify ptep_get() argument
  2026-07-24 15:03       ` Usama Arif
@ 2026-07-24 15:32         ` Pedro Falcato
  2026-07-24 15:48           ` Usama Arif
  0 siblings, 1 reply; 12+ messages in thread
From: Pedro Falcato @ 2026-07-24 15:32 UTC (permalink / raw)
  To: Usama Arif
  Cc: Matthew Wilcox, Andrew Morton, David Hildenbrand, Catalin Marinas,
	Will Deacon, James E.J. Bottomley, Helge Deller,
	Madhavan Srinivasan, Michael Ellerman, Lorenzo Stoakes,
	Liam R. Howlett, Vlastimil Babka, Mike Rapoport,
	Suren Baghdasaryan, Michal Hocko, Jan Kara, Zi Yan, Baolin Wang,
	Nico Pache, Ryan Roberts, Dev Jain, Barry Song, Lance Yang,
	Kevin Brodsky, Muhammad Usama Anjum, linux-arm-kernel,
	linux-kernel, linux-parisc, linuxppc-dev, linux-mm, linux-fsdevel

On Fri, Jul 24, 2026 at 04:03:44PM +0100, Usama Arif wrote:
> 
> 
> On 24/07/2026 15:14, Matthew Wilcox wrote:
> > On Fri, Jul 24, 2026 at 02:36:59PM +0100, Usama Arif wrote:
> >>
> >>
> >> On 24/07/2026 11:20, Pedro Falcato wrote:
> >>> ptep_get() does not need write access to the PTE.
> >>>
> >>> Signed-off-by: Pedro Falcato <pfalcato@suse.de>
> >>> ---
> >>>  arch/parisc/include/asm/pgtable.h | 2 +-
> >>>  1 file changed, 1 insertion(+), 1 deletion(-)
> >>>
> >> hmm I think you might break build bisectibility if
> >> you separate out the patches, you should squash patch 3 and 4,
> >> with patch 1.
> > 
> > I don't see how this breaks bisectability.  Can you elaborate on what
> > you think would break?
> 
> Patch 1 does:
> 
> -static inline pte_t ptep_get_lockless(pte_t *ptep)
> +static inline pte_t ptep_get_lockless(const pte_t *ptep)
>  {
>  	return ptep_get(ptep);
>  }
> 
> 
> ptep_get() takes a non-const arg till patch 3 for example for parsic.
> I don't think you can pass a const variable to non const function arg?
> 
> So parsic won't compile in patch 1 and 2, powerprc wont compile
> for patches 1, 2 and 3..

Aha, yes, nice catch! I'll have to rethink that. Maybe squashing the patches
would be the cleanest way forward.

FWIW, the vast majority of architectures aren't doing funny things on
ptep_get(). E.g PA-RISC, loongarch only define these so they can use it in
their own asm/pgtable.h. I'd really like to delete these but I can't tell
if they are *actually* required.

With those gone only PPC 8xx and generic would need to be squashed (arm64 also
defines its own version of ptep_get_lockless()).


-- 
Pedro

^ permalink raw reply	[flat|nested] 12+ messages in thread

* Re: [PATCH 3/5] mm/parisc: constify ptep_get() argument
  2026-07-24 15:32         ` Pedro Falcato
@ 2026-07-24 15:48           ` Usama Arif
  0 siblings, 0 replies; 12+ messages in thread
From: Usama Arif @ 2026-07-24 15:48 UTC (permalink / raw)
  To: Pedro Falcato
  Cc: Matthew Wilcox, Andrew Morton, David Hildenbrand, Catalin Marinas,
	Will Deacon, James E.J. Bottomley, Helge Deller,
	Madhavan Srinivasan, Michael Ellerman, Lorenzo Stoakes,
	Liam R. Howlett, Vlastimil Babka, Mike Rapoport,
	Suren Baghdasaryan, Michal Hocko, Jan Kara, Zi Yan, Baolin Wang,
	Nico Pache, Ryan Roberts, Dev Jain, Barry Song, Lance Yang,
	Kevin Brodsky, Muhammad Usama Anjum, linux-arm-kernel,
	linux-kernel, linux-parisc, linuxppc-dev, linux-mm, linux-fsdevel



On 24/07/2026 16:32, Pedro Falcato wrote:
> On Fri, Jul 24, 2026 at 04:03:44PM +0100, Usama Arif wrote:
>>
>>
>> On 24/07/2026 15:14, Matthew Wilcox wrote:
>>> On Fri, Jul 24, 2026 at 02:36:59PM +0100, Usama Arif wrote:
>>>>
>>>>
>>>> On 24/07/2026 11:20, Pedro Falcato wrote:
>>>>> ptep_get() does not need write access to the PTE.
>>>>>
>>>>> Signed-off-by: Pedro Falcato <pfalcato@suse.de>
>>>>> ---
>>>>>  arch/parisc/include/asm/pgtable.h | 2 +-
>>>>>  1 file changed, 1 insertion(+), 1 deletion(-)
>>>>>
>>>> hmm I think you might break build bisectibility if
>>>> you separate out the patches, you should squash patch 3 and 4,
>>>> with patch 1.
>>>
>>> I don't see how this breaks bisectability.  Can you elaborate on what
>>> you think would break?
>>
>> Patch 1 does:
>>
>> -static inline pte_t ptep_get_lockless(pte_t *ptep)
>> +static inline pte_t ptep_get_lockless(const pte_t *ptep)
>>  {
>>  	return ptep_get(ptep);
>>  }
>>
>>
>> ptep_get() takes a non-const arg till patch 3 for example for parsic.
>> I don't think you can pass a const variable to non const function arg?
>>
>> So parsic won't compile in patch 1 and 2, powerprc wont compile
>> for patches 1, 2 and 3..
> 
> Aha, yes, nice catch! I'll have to rethink that. Maybe squashing the patches
> would be the cleanest way forward.
> 

Yes, squashing is the simplest way forward.

> FWIW, the vast majority of architectures aren't doing funny things on
> ptep_get(). E.g PA-RISC, loongarch only define these so they can use it in
> their own asm/pgtable.h. I'd really like to delete these but I can't tell
> if they are *actually* required.
> 

Ah maybe there is something in git history on why it was needed?

If not, hopefully someone from the arch lists could clarify..

> With those gone only PPC 8xx and generic would need to be squashed (arm64 also
> defines its own version of ptep_get_lockless()).
> 
> 


^ permalink raw reply	[flat|nested] 12+ messages in thread

end of thread, other threads:[~2026-07-24 15:49 UTC | newest]

Thread overview: 12+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-07-24 10:20 [PATCH 0/5] mm: add basic PTE const type-safety Pedro Falcato
2026-07-24 10:20 ` [PATCH 1/5] mm: constify generic pte_get*() Pedro Falcato
2026-07-24 10:20 ` [PATCH 2/5] mm/arm64: constify pte_get*() and contpte get logic Pedro Falcato
2026-07-24 10:20 ` [PATCH 3/5] mm/parisc: constify ptep_get() argument Pedro Falcato
2026-07-24 13:36   ` Usama Arif
2026-07-24 13:39     ` Usama Arif
2026-07-24 14:14     ` Matthew Wilcox
2026-07-24 15:03       ` Usama Arif
2026-07-24 15:32         ` Pedro Falcato
2026-07-24 15:48           ` Usama Arif
2026-07-24 10:20 ` [PATCH 4/5] mm/powerpc/8xx: " Pedro Falcato
2026-07-24 10:20 ` [PATCH 5/5] mm: constify the pte_offset_map_ro_nolock() return value Pedro Falcato

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox