[PATCH v2 2/2] mm/filemap: do not count FAULT_FLAG_TRIED retries as mmap hits

From: fujunjie

Date: Mon Apr 27 2026 - 12:58:59 EST


A fault that starts synchronous mmap readahead can return VM_FAULT_RETRY
after dropping mmap_lock. The retry may then map the folio brought in
by that same miss.

Do not let this retry decrement mmap_miss. The retry still maps the
folio from the page cache; it just does not count as a useful mmap
readahead hit.

Signed-off-by: fujunjie <fujunjie1@xxxxxx>
---
mm/filemap.c | 1 +
1 file changed, 1 insertion(+)

diff --git a/mm/filemap.c b/mm/filemap.c
index 41ffe9036c96e..f244886b1df3b 100644
--- a/mm/filemap.c
+++ b/mm/filemap.c
@@ -3926,6 +3926,7 @@ vm_fault_t filemap_map_pages(struct vm_fault *vmf,
ret |= map_ret;

if ((map_ret & VM_FAULT_NOPAGE) &&
+ !(vmf->flags & FAULT_FLAG_TRIED) &&
!folio_test_workingset(folio)) {
unsigned short mmap_miss;

--
2.34.1