[PATCH 3/4] mm: mark PTEs referencing the accessed folio young

From: Yin Fengwei
Date: Tue May 30 2023 - 04:07:37 EST


To allow using larger TLB entries, it's better to mark the
PTEs of same folio accessed when setup the PTEs.

Reported-by: Ryan Roberts <ryan.roberts@xxxxxxx>
Signed-off-by: Yin Fengwei <fengwei.yin@xxxxxxxxx>
---
mm/memory.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/mm/memory.c b/mm/memory.c
index c359fb8643e5..2615ea552613 100644
--- a/mm/memory.c
+++ b/mm/memory.c
@@ -4259,7 +4259,7 @@ void set_pte_range(struct vm_fault *vmf, struct folio *folio,
struct vm_area_struct *vma = vmf->vma;
bool uffd_wp = pte_marker_uffd_wp(vmf->orig_pte);
bool write = vmf->flags & FAULT_FLAG_WRITE;
- bool prefault = vmf->address != addr;
+ bool prefault = (addr > vmf->address) || ((addr + nr) < vmf->address);
pte_t entry;

flush_icache_pages(vma, page, nr);
--
2.30.2