[PATCH] tmp

From: David Hildenbrand (Arm)

Date: Thu Apr 16 2026 - 03:51:07 EST


Signed-off-by: David Hildenbrand (Arm) <david@xxxxxxxxxx>
---
arch/sparc/include/asm/pgtable_64.h | 4 ----
include/linux/pgtable.h | 28 +++++-----------------------
mm/madvise.c | 6 +++---
mm/memory.c | 2 +-
4 files changed, 9 insertions(+), 31 deletions(-)

diff --git a/arch/sparc/include/asm/pgtable_64.h b/arch/sparc/include/asm/pgtable_64.h
index 74ede706fb32..0837ebbc5dce 100644
--- a/arch/sparc/include/asm/pgtable_64.h
+++ b/arch/sparc/include/asm/pgtable_64.h
@@ -945,10 +945,6 @@ static inline void set_ptes(struct mm_struct *mm, unsigned long addr,
#define pte_clear(mm,addr,ptep) \
set_pte_at((mm), (addr), (ptep), __pte(0UL))

-#define __HAVE_ARCH_PTE_CLEAR_NOT_PRESENT_FULL
-#define pte_clear_not_present_full(mm,addr,ptep,fullmm) \
- __set_pte_at((mm), (addr), (ptep), __pte(0UL), (fullmm))
-
#ifdef DCACHE_ALIASING_POSSIBLE
#define __HAVE_ARCH_MOVE_PTE
#define move_pte(pte, old_addr, new_addr) \
diff --git a/include/linux/pgtable.h b/include/linux/pgtable.h
index 17d961c612fc..b3d6c8ddd687 100644
--- a/include/linux/pgtable.h
+++ b/include/linux/pgtable.h
@@ -955,24 +955,8 @@ static inline void update_mmu_tlb(struct vm_area_struct *vma,
update_mmu_tlb_range(vma, address, ptep, 1);
}

-/*
- * Some architectures may be able to avoid expensive synchronization
- * primitives when modifications are made to PTE's which are already
- * not present, or in the process of an address space destruction.
- */
-#ifndef __HAVE_ARCH_PTE_CLEAR_NOT_PRESENT_FULL
-static inline void pte_clear_not_present_full(struct mm_struct *mm,
- unsigned long address,
- pte_t *ptep,
- int full)
-{
- pte_clear(mm, address, ptep);
-}
-#endif
-
-#ifndef clear_not_present_full_ptes
/**
- * clear_not_present_full_ptes - Clear multiple not present PTEs which are
+ * clear_not_present_full_ptes - Clear multiple non-present PTEs which are
* consecutive in the pgtable.
* @mm: Address space the ptes represent.
* @addr: Address of the first pte.
@@ -980,24 +964,22 @@ static inline void pte_clear_not_present_full(struct mm_struct *mm,
* @nr: Number of entries to clear.
* @full: Whether we are clearing a full mm.
*
- * May be overridden by the architecture; otherwise, implemented as a simple
- * loop over pte_clear_not_present_full().
+ * Implemented as a simple loop over pte_clear().
*
* Context: The caller holds the page table lock. The PTEs are all not present.
* The PTEs are all in the same PMD.
*/
-static inline void clear_not_present_full_ptes(struct mm_struct *mm,
- unsigned long addr, pte_t *ptep, unsigned int nr, int full)
+static inline void clear_non_present_ptes(struct mm_struct *mm,
+ unsigned long addr, pte_t *ptep, unsigned int nr)
{
for (;;) {
- pte_clear_not_present_full(mm, addr, ptep, full);
+ pte_clear(mm, addr, ptep);
if (--nr == 0)
break;
ptep++;
addr += PAGE_SIZE;
}
}
-#endif

#ifndef __HAVE_ARCH_PTEP_CLEAR_FLUSH
extern pte_t ptep_clear_flush(struct vm_area_struct *vma,
diff --git a/mm/madvise.c b/mm/madvise.c
index 69708e953cf5..0e430e03e69c 100644
--- a/mm/madvise.c
+++ b/mm/madvise.c
@@ -695,10 +695,10 @@ static int madvise_free_pte_range(pmd_t *pmd, unsigned long addr,
nr = swap_pte_batch(pte, max_nr, ptent);
nr_swap -= nr;
swap_put_entries_direct(entry, nr);
- clear_not_present_full_ptes(mm, addr, pte, nr, tlb->fullmm);
+ clear_non_present_(mm, addr, pte, nr);
} else if (softleaf_is_hwpoison(entry) ||
softleaf_is_poison_marker(entry)) {
- pte_clear_not_present_full(mm, addr, pte, tlb->fullmm);
+ pte_clear(mm, addr, pte);
}
continue;
}
@@ -1234,7 +1234,7 @@ static int guard_remove_pte_entry(pte_t *pte, unsigned long addr,

if (is_guard_pte_marker(ptent)) {
/* Simply clear the PTE marker. */
- pte_clear_not_present_full(walk->mm, addr, pte, false);
+ pte_clear(walk->mm, addr, pte);
update_mmu_cache(walk->vma, addr, pte);
}

diff --git a/mm/memory.c b/mm/memory.c
index 631205a384e1..d61d4ba906cd 100644
--- a/mm/memory.c
+++ b/mm/memory.c
@@ -1781,7 +1781,7 @@ static inline int zap_nonpresent_ptes(struct mmu_gather *tlb,
pr_alert("unrecognized swap entry 0x%lx\n", entry.val);
WARN_ON_ONCE(1);
}
- clear_not_present_full_ptes(vma->vm_mm, addr, pte, nr, tlb->fullmm);
+ clear_non_present_ptes(vma->vm_mm, addr, pte, nr);
*any_skipped = zap_install_uffd_wp_if_needed(vma, addr, pte, nr, details, ptent);

return nr;
--
2.43.0





--
Cheers,

David