[PATCH v3 2/2] mm/filemap: do not count FAULT_FLAG_TRIED retries as mmap hits
From: fujunjie
Date: Mon Apr 27 2026 - 22:03:00 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 543e51c32397..86a46a61eac8 100644
--- a/mm/filemap.c
+++ b/mm/filemap.c
@@ -3933,6 +3933,7 @@ vm_fault_t filemap_map_pages(struct vm_fault *vmf,
* we can stop read-ahead.
*/
if ((map_ret & VM_FAULT_NOPAGE) &&
+ !(vmf->flags & FAULT_FLAG_TRIED) &&
!folio_test_workingset(folio)) {
unsigned short mmap_miss;
--
2.34.1