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

From: Jan Kara

Date: Tue Apr 28 2026 - 05:49:11 EST


On Tue 28-04-26 01:59:44, fujunjie wrote:
> 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>

Looks good. Feel free to add:

Reviewed-by: Jan Kara <jack@xxxxxxx>

Honza

> ---
> 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
>
--
Jan Kara <jack@xxxxxxxx>
SUSE Labs, CR