mm-add-get_and_clear_ptes-and-clear_ptes.patch removed from -mm tree
The quilt patch titled
Subject: mm: add get_and_clear_ptes() and clear_ptes()
has been removed from the -mm tree. Its filename was
mm-add-get_and_clear_ptes-and-clear_ptes.patch
This patch was dropped because it was merged into the mm-stable branch of git://git.kernel.org/pub/scm/linux/kernel/git/akpm/mm
------------------------------------------------------
From: David Hildenbrand <[email protected]>
Subject: mm: add get_and_clear_ptes() and clear_ptes()
Date: Thu, 24 Jul 2025 10:52:59 +0530
Patch series "Optimizations for khugepaged", v4.
If the underlying folio mapped by the ptes is large, we can process those ptes in a batch using folio_pte_batch().
For arm64 specifically, this results in a 16x reduction in the number of ptep_get() calls, since on a contig block, ptep_get() on arm64 will iterate through all 16 entries to collect a/d bits. Next, ptep_clear() will cause a TLBI for every contig block in the range via contpte_try_unfold(). Instead, use clear_ptes() to only do the TLBI at the first and last contig block of the range.
For split folios, there will be no pte batching; the batch size returned by folio_pte_batch() will be 1. For pagetable split folios, the ptes will still point to the same large folio; for arm64, this results in the optimization described above, and for other arches, a minor improvement is expected due to a reduction in the number of function calls and batching atomic operations.
This patch (of 3):
Let's add variants to be used where "full" does not apply -- which will be the majority of cases in the future. "full" really only applies if we are about to tear down a full MM.
Use get_and_clear_ptes() in existing code, clear_ptes() users will be added next.
---
arch/arm64/mm/mmu.c | 2 - include/linux/pgtable.h | 45 ++++++++++++++++++++++++++++++++++++++ mm/mremap.c | 2 - mm/rmap.c | 2 - 4 files changed, 48 insertions(+), 3 deletions(-)
arch/arm64/mm/mmu.c renamed from arch/arm64/mm/mmu.c~mm-add-get_and_clear_ptes-and-clear_ptes +1 -1
@@ -1528,7 +1528,7 @@ early_initcall(prevent_bootmem_remove_inpte_t modify_prot_start_ptes (struct vm_area_struct *vma,unsigned long addr,pte_t *ptep,unsigned int nr) { -pte_t pte =get_and_clear_full_ptes (vma->vm_mm, addr, ptep, nr,/* full = */ 0 ); +pte_t pte =get_and_clear_ptes (vma->vm_mm, addr, ptep, nr);if (alternative_has_cap_unlikely (ARM64_WORKAROUND_2645198 )) {/*
include/linux/pgtable.h renamed from include/linux/pgtable.h~mm-add-get_and_clear_ptes-and-clear_ptes +45 -0
57 lines not on this page · raw message
mm/mremap.c renamed from mm/mremap.c~mm-add-get_and_clear_ptes-and-clear_ptes +1 -1
@@ -280,7 +280,7 @@ static int move_ptes(struct pagetable_mo old_pte, max_nr_ptes); force_flush = true; } - pte =get_and_clear_full_ptes (mm, old_addr, old_ptep, nr_ptes,0 ); + pte =get_and_clear_ptes (mm, old_addr, old_ptep, nr_ptes); pte =move_pte (pte, old_addr, new_addr); pte =move_soft_dirty_pte (pte);
mm/rmap.c renamed from mm/rmap.c~mm-add-get_and_clear_ptes-and-clear_ptes +1 -1
@@ -2036,7 +2036,7 @@ static bool try_to_unmap_one(struct foliflush_cache_range (vma, address, end_addr);/* Nuke the page table entry. */ - pteval =get_and_clear_full_ptes (mm, address, pvmw.pte, nr_pages,0 ); + pteval =get_and_clear_ptes (mm, address, pvmw.pte, nr_pages);/* * We clear the PTE but do not flush so potentially * a remote CPU could still be writing to the folio.
_
Patches currently in -mm which might be from [email protected] are