Thread (29 messages) flat view 29 messages, 5 authors, 6h ago

Re: [PATCH 3/9] mm: name pointers to copied PTE values ptentp

From: Anshuman Khandual <hidden>
Date: 2026-08-12 04:06:15
Also in: bpf, damon, dri-devel, intel-gfx, linux-arch, linux-fsdevel, linux-mm, linux-perf-users, lkml, xen-devel

On Tue, Aug 11, 2026 at 03:09:07PM +0100, Muhammad Usama Anjum wrote:
On 11/08/2026 11:58 am, Anshuman Khandual wrote:
quoted
Subject line is very confusing. Perhaps something like the following.

mm: Rename pointers to copied PTE values as ptentp

But even 'copied PTE values' is not very clear as well.
Something like:

mm: rename pointers to logical PTE values as ptentp

or

mm: rename pointers to software PTE values as ptentp
Yeah but we need to get these nomenclature right at the very beginning
and also probably get it documented some where.
quoted
On Thu, Aug 06, 2026 at 09:38:41AM +0100, Muhammad Usama Anjum wrote:
quoted
The hw_pte_t conversion must retain pte_t * for pointers to standalone PTE
We need to explain what is `standalone PTE values` first.
quoted
values. Name the value parameters ptentp in the install_pte callback,
write_protect_page(), and guard_install_set_pte() so the later mechanical
conversion can distinguish them from pointers to PTE table storage.

Some functions already use the ptentp name, including:
- madvise_folio_pte_batch()
- folio_pte_batch_flags()
No need to convert them.

This is a naming-only change.
Small nit - s/naming-only/rename
I'll fix it.
quoted
The commit message needs rewrite clearly explaining the following details

- What are standalone PTE values
Logical/software PTE is correct and better name here.
Right but we need to define these early on and then be consistent in their usage
afterwards in the entire series.
quoted
- How these are different from HW pgtable pointers
- Change is just a rename for pointers into such 'standalone PTE'
- These renamed 'ptentp' here would be used for skip or replaced during
  upcoming mechanical change via a script
- No functional changes intended
I'll update message in more elaborate way.
quoted
quoted
Signed-off-by: Muhammad Usama Anjum <redacted>
---
Changes since RFC v1:
- Update the description for the architecture opt-in conversion.
---
 include/linux/pagewalk.h | 2 +-
 mm/ksm.c                 | 4 ++--
 mm/madvise.c             | 4 ++--
 3 files changed, 5 insertions(+), 5 deletions(-)
diff --git a/include/linux/pagewalk.h b/include/linux/pagewalk.h
index b41d7265c01bc..c34d826c5e4a2 100644
--- a/include/linux/pagewalk.h
+++ b/include/linux/pagewalk.h
@@ -89,7 +89,7 @@ struct mm_walk_ops {
 		       struct mm_walk *walk);
 	void (*post_vma)(struct mm_walk *walk);
 	int (*install_pte)(unsigned long addr, unsigned long next,
-			   pte_t *ptep, struct mm_walk *walk);
+			   pte_t *ptentp, struct mm_walk *walk);
 	enum page_walk_lock walk_lock;
 };
 
diff --git a/mm/ksm.c b/mm/ksm.c
index ad05d7791307e..11d50518d02e9 100644
--- a/mm/ksm.c
+++ b/mm/ksm.c
@@ -1292,7 +1292,7 @@ static u32 calc_checksum(struct page *page)
 }
 
 static int write_protect_page(struct vm_area_struct *vma, struct folio *folio,
-			      pte_t *orig_pte)
+			      pte_t *ptentp)
 {
 	struct mm_struct *mm = vma->vm_mm;
 	DEFINE_FOLIO_VMA_WALK(pvmw, folio, vma, 0, 0);
@@ -1371,7 +1371,7 @@ static int write_protect_page(struct vm_area_struct *vma, struct folio *folio,
 
 		set_pte_at(mm, pvmw.address, pvmw.pte, entry);
 	}
-	*orig_pte = entry;
+	*ptentp = entry;
 	err = 0;
 
 out_unlock:
diff --git a/mm/madvise.c b/mm/madvise.c
index 07a21ca31bad4..c324cc991f841 100644
--- a/mm/madvise.c
+++ b/mm/madvise.c
@@ -1101,12 +1101,12 @@ static int guard_install_pte_entry(pte_t *pte, unsigned long addr,
 }
 
 static int guard_install_set_pte(unsigned long addr, unsigned long next,
-				 pte_t *ptep, struct mm_walk *walk)
+				 pte_t *ptentp, struct mm_walk *walk)
 {
 	unsigned long *nr_pages = (unsigned long *)walk->private;
 
 	/* Simply install a PTE marker, this causes segfault on access. */
-	*ptep = make_pte_marker(PTE_MARKER_GUARD);
+	*ptentp = make_pte_marker(PTE_MARKER_GUARD);
 	(*nr_pages)++;
 
 	return 0;
-- 
2.47.3
How did we ensure that the above changes are comprehensive and nothing
else got left in here ?
The order of patches and even the code was found out after adding hw_pte_t
structure. Then everything was converted, until some pte_t pointers were left
which didn't require conversion.

If something is left, we'll get build errors when we build a converted architecture.
So the branch mentioned in the cover letter when built, would produce build errors.
(Those patches would be sent separately, after finalization of this series).

Whenever I'm rebasing (on mm-new), I'm rerunning Coccinelle script to see if new code
has arrived which requires conversion or renaming.
But in the early patch where the manual renaming was done for the script to
pick up 'ptentp' patterns needs to be audited again.
-- 
Thanks,
Usama
Keyboard shortcuts
hback out one level
jnext message in thread
kprevious message in thread
ldrill in
Escclose help / fold thread tree
?toggle this help