Skip to content

Commit d824ec2

Browse files
jankaraakpm00
authored andcommitted
mm: do not reclaim private data from pinned page
If the page is pinned, there's no point in trying to reclaim it. Furthermore if the page is from the page cache we don't want to reclaim fs-private data from the page because the pinning process may be writing to the page at any time and reclaiming fs private info on a dirty page can upset the filesystem (see link below). Link: https://lore.kernel.org/linux-mm/20180103100430.GE4911@quack2.suse.cz Link: https://lkml.kernel.org/r/20230428124140.30166-1-jack@suse.cz Signed-off-by: Jan Kara <jack@suse.cz> Reviewed-by: Matthew Wilcox (Oracle) <willy@infradead.org> Reviewed-by: Lorenzo Stoakes <lstoakes@gmail.com> Reviewed-by: Christoph Hellwig <hch@lst.de> Reviewed-by: John Hubbard <jhubbard@nvidia.com> Acked-by: David Hildenbrand <david@redhat.com> Acked-by: Peter Xu <peterx@redhat.com> Cc: <stable@vger.kernel.org> Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
1 parent a6a491c commit d824ec2

File tree

1 file changed

+10
-0
lines changed

1 file changed

+10
-0
lines changed

mm/vmscan.c

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1967,6 +1967,16 @@ static unsigned int shrink_folio_list(struct list_head *folio_list,
19671967
}
19681968
}
19691969

1970+
/*
1971+
* Folio is unmapped now so it cannot be newly pinned anymore.
1972+
* No point in trying to reclaim folio if it is pinned.
1973+
* Furthermore we don't want to reclaim underlying fs metadata
1974+
* if the folio is pinned and thus potentially modified by the
1975+
* pinning process as that may upset the filesystem.
1976+
*/
1977+
if (folio_maybe_dma_pinned(folio))
1978+
goto activate_locked;
1979+
19701980
mapping = folio_mapping(folio);
19711981
if (folio_test_dirty(folio)) {
19721982
/*

0 commit comments

Comments
 (0)