From 9b0fcac3cfe7ffeb3da78bfee765072861c81ce2 Mon Sep 17 00:00:00 2001 From: fujunjie Date: Tue, 28 Apr 2026 01:59:44 +0000 Subject: [PATCH] mm/filemap: do not count FAULT_FLAG_TRIED retries as mmap hits 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. Link: https://lore.kernel.org/tencent_22E6B8849EC1141FE7773C64467E6F1E2C09@qq.com Signed-off-by: fujunjie Reviewed-by: Jan Kara Reviewed-by: Vishal Moola Cc: Matthew Wilcox (Oracle) Cc: Roman Gushchin Signed-off-by: Andrew Morton --- mm/filemap.c | 1 + 1 file changed, 1 insertion(+) diff --git a/mm/filemap.c b/mm/filemap.c index 816eabb22e19..ab34cab2416a 100644 --- a/mm/filemap.c +++ b/mm/filemap.c @@ -3937,6 +3937,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.47.3