[PATCH] mm: skip dirty file folios during isolation

From: zhaoyang.huang

Date: Wed Mar 18 2026 - 05:07:45 EST


From: Zhaoyang Huang <zhaoyang.huang@xxxxxxxxxx>

Since dirty file folios are no longer writeout in reclaiming after
'commit 84798514db50 ("mm: Remove swap_writepage() and
shmem_writepage()")', there is no need to isolate them from LRU which
could help to improve the scan efficiency.

Signed-off-by: Zhaoyang Huang <zhaoyang.huang@xxxxxxxxxx>
---
mm/vmscan.c | 6 ++++++
1 file changed, 6 insertions(+)

diff --git a/mm/vmscan.c b/mm/vmscan.c
index 10f1e7d716ca..3a029dede5ce 100644
--- a/mm/vmscan.c
+++ b/mm/vmscan.c
@@ -4507,6 +4507,7 @@ static bool sort_folio(struct lruvec *lruvec, struct folio *folio, struct scan_c
static bool isolate_folio(struct lruvec *lruvec, struct folio *folio, struct scan_control *sc)
{
bool success;
+ struct address_space *mapping = folio_mapping(folio);

/* swap constrained */
if (!(sc->gfp_mask & __GFP_IO) &&
@@ -4514,6 +4515,11 @@ static bool isolate_folio(struct lruvec *lruvec, struct folio *folio, struct sca
(folio_test_anon(folio) && !folio_test_swapcache(folio))))
return false;

+ /* skip dirty file pages since they can't be writeout */
+ if (mapping && !shmem_mapping(mapping) &&
+ !folio_test_anon(folio) && folio_test_dirty(folio))
+ return false;
+
/* raced with release_pages() */
if (!folio_try_get(folio))
return false;
--
2.25.1