arm64-mm-automatically-fold-contpte-mappings.patch removed from -mm tree
The quilt patch titled
Subject: arm64/mm: automatically fold contpte mappings
has been removed from the -mm tree. Its filename was
arm64-mm-automatically-fold-contpte-mappings.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: Ryan Roberts <[email protected]>
Subject: arm64/mm: automatically fold contpte mappings
Date: Thu, 15 Feb 2024 10:32:05 +0000
There are situations where a change to a single PTE could cause the contpte block in which it resides to become foldable (i.e. could be repainted with the contiguous bit). Such situations arise, for example, when user space temporarily changes protections, via mprotect, for individual pages, such can be the case for certain garbage collectors.
We would like to detect when such a PTE change occurs. However this can be expensive due to the amount of checking required. Therefore only perform the checks when an indiviual PTE is modified via mprotect (ptep_modify_prot_commit() -> set_pte_at() -> set_ptes(nr=1)) and only when we are setting the final PTE in a contpte-aligned block.
---
arch/arm64/include/asm/pgtable.h | 26 +++++++++++ arch/arm64/mm/contpte.c | 64 +++++++++++++++++++++++++++++ 2 files changed, 90 insertions(+)
arch/arm64/include/asm/pgtable.h renamed from arch/arm64/include/asm/pgtable.h~arm64-mm-automatically-fold-contpte-mappings +26 -0
@@ -1185,6 +1185,8 @@ extern void ptep_modify_prot_commit(stru* where it is possible and makes sense to do so. The PTE_CONT bit is considered * a private implementation detail of the public ptep API (see below). */ +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);
@@ -1206,6 +1208,29 @@ extern int contpte_ptep_set_access_flags unsigned long addr, pte_t *ptep, pte_t entry, int dirty); +static __always_inline void contpte_try_fold(struct mm_struct *mm, +unsigned long addr,pte_t *ptep,pte_t pte) +{ +/* +* Only bother trying if both the virtual and physical addresses are +* aligned and correspond to the last entry in a contig range. The core +* code mostly modifies ranges from low to high, so this is the likely +* the last modification in the contig range, so a good time to fold. +* We can't fold special mappings, because there is no associated folio. +*/ + +const unsigned long contmask =CONT_PTES -1 ; +bool valign = ((addr >>PAGE_SHIFT ) & contmask) == contmask; + +if (unlikely (valign)) { +bool palign = (pte_pfn (pte) & contmask) == contmask; + +if (unlikely (palign && +pte_valid (pte) && !pte_cont (pte) && !pte_special (pte))) +__contpte_try_fold (mm, addr, ptep, pte); + } +} + static __always_inline void contpte_try_unfold(struct mm_struct *mm,unsigned long addr,pte_t *ptep,pte_t pte) {
@@ -1286,6 +1311,7 @@ static __always_inline void set_ptes(strif (likely (nr ==1 )) {contpte_try_unfold (mm, addr, ptep,__ptep_get (ptep));__set_ptes (mm, addr, ptep, pte,1 ); +contpte_try_fold (mm, addr, ptep, pte); }else {contpte_set_ptes (mm, addr, ptep, pte, nr); }
arch/arm64/mm/contpte.c renamed from arch/arm64/mm/contpte.c~arm64-mm-automatically-fold-contpte-mappings +64 -0
70 lines not on this page · raw message
_
Patches currently in -mm which might be from [email protected] are