[PATCH] mm/vmscan: respect can_reclaim_anon_pages() in MGLRU get_swappiness()

From: Muhammad Haris Awan

Date: Mon Nov 16 2026 - 22:00:04 EST


Under GFP_NOIO reclaim, reclaimers cannot add anonymous folios to the
swapcache and can only reclaim anon folios that are already in the
swapcache (or demotable). Traditional LRU avoids scanning anon when
swapcache < (anon_pages >> 6) via reclaimable_anon_is_low(), but MGLRU
explicitly skipped this check because get_swappiness() did not consult
can_reclaim_anon_pages().

Call can_reclaim_anon_pages() from get_swappiness() and remove the
lru_gen_enabled() bypass from reclaimable_anon_is_low(). When anon
pages are not reclaimable (e.g., GFP_NOIO with low swapcache and no
demotion target), get_swappiness() now returns 0, restricting MGLRU
eviction, aging, and fallback isolation to LRU_GEN_FILE only.

Signed-off-by: Muhammad Haris Awan <m.harisawan@xxxxxxxxxx>
---
mm/vmscan.c | 10 +++-------
1 file changed, 3 insertions(+), 7 deletions(-)

diff --git a/mm/vmscan.c b/mm/vmscan.c
index 6a1af9b92..f5fa67985 100644
--- a/mm/vmscan.c
+++ b/mm/vmscan.c
@@ -379,13 +379,6 @@ static inline bool reclaimable_anon_is_low(struct mem_cgroup *memcg,
if (!sc || (sc->gfp_mask & __GFP_IO))
return false;

- /*
- * FIXME: MGLRU doesn't fully respect can_reclaim_anon_pages() for the
- * scanning type, so only apply this to the traditional LRU for now.
- */
- if (lru_gen_enabled())
- return false;
-
if (memcg) {
struct lruvec *lruvec = mem_cgroup_lruvec(memcg, pgdat);

@@ -2893,6 +2886,9 @@ static int get_swappiness(struct lruvec *lruvec, struct scan_control *sc)
if (!sc->may_swap)
return 0;

+ if (!can_reclaim_anon_pages(memcg, pgdat->node_id, sc))
+ return 0;
+
if (!can_demote(pgdat->node_id, sc, memcg) &&
mem_cgroup_get_nr_swap_pages(memcg) < MIN_LRU_BATCH)
return 0;
--
2.56.0