]> git.ipfire.org Git - thirdparty/kernel/linux.git/commitdiff
mm/filemap: do not count FAULT_FLAG_TRIED retries as mmap hits
authorfujunjie <fujunjie1@qq.com>
Tue, 28 Apr 2026 01:59:44 +0000 (01:59 +0000)
committerAndrew Morton <akpm@linux-foundation.org>
Fri, 29 May 2026 04:05:06 +0000 (21:05 -0700)
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 <fujunjie1@qq.com>
Reviewed-by: Jan Kara <jack@suse.cz>
Reviewed-by: Vishal Moola <vishal.moola@gmail.com>
Cc: Matthew Wilcox (Oracle) <willy@infradead.org>
Cc: Roman Gushchin <roman.gushchin@linux.dev>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
mm/filemap.c

index 816eabb22e19c91ce20c4c7fec8ea8a250f55fe1..ab34cab2416a45889b9aa026ca8d365b394f176e 100644 (file)
@@ -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;