Skip to content

Commit 5c46d53

Browse files
Liu Shixinakpm00
authored andcommitted
mm/filemap: don't decrease mmap_miss when folio has workingset flag
If there are too many folios that are recently evicted in a file, then they will probably continue to be evicted. In such situation, there is no positive effect to read-ahead this file since it is only a waste of IO. The mmap_miss is increased in do_sync_mmap_readahead() and decreased in both do_async_mmap_readahead() and filemap_map_pages(). In order to skip read-ahead in above scenario, the mmap_miss have to increased exceed MMAP_LOTSAMISS. This can be done by stop decreased mmap_miss when folio has workingset flag. The async path is not to care because in above scenario, it's hard to run into the async path. [[email protected]: add comments] Link: https://lkml.kernel.org/r/[email protected] Link: https://lkml.kernel.org/r/[email protected] Signed-off-by: Liu Shixin <[email protected]> Reviewed-by: Jan Kara <[email protected]> Cc: Al Viro <[email protected]> Cc: Christian Brauner <[email protected]> Cc: Jinjiang Tu <[email protected]> Cc: Matthew Wilcox (Oracle) <[email protected]> Signed-off-by: Andrew Morton <[email protected]>
1 parent 0fd44ab commit 5c46d53

File tree

1 file changed

+12
-2
lines changed

1 file changed

+12
-2
lines changed

mm/filemap.c

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3492,7 +3492,15 @@ static vm_fault_t filemap_map_folio_range(struct vm_fault *vmf,
34923492
if (PageHWPoison(page + count))
34933493
goto skip;
34943494

3495-
(*mmap_miss)++;
3495+
/*
3496+
* If there are too many folios that are recently evicted
3497+
* in a file, they will probably continue to be evicted.
3498+
* In such situation, read-ahead is only a waste of IO.
3499+
* Don't decrease mmap_miss in this scenario to make sure
3500+
* we can stop read-ahead.
3501+
*/
3502+
if (!folio_test_workingset(folio))
3503+
(*mmap_miss)++;
34963504

34973505
/*
34983506
* NOTE: If there're PTE markers, we'll leave them to be
@@ -3541,7 +3549,9 @@ static vm_fault_t filemap_map_order0_folio(struct vm_fault *vmf,
35413549
if (PageHWPoison(page))
35423550
return ret;
35433551

3544-
(*mmap_miss)++;
3552+
/* See comment of filemap_map_folio_range() */
3553+
if (!folio_test_workingset(folio))
3554+
(*mmap_miss)++;
35453555

35463556
/*
35473557
* NOTE: If there're PTE markers, we'll leave them to be

0 commit comments

Comments
 (0)