[RFC PATCH v4 03/16] mm/mglru: retry the same type once if isolation fails due to races
From: Barry Song (Xiaomi)
Date: Wed Aug 12 2026 - 08:21:32 EST
If we are not exhausted (i.e., there are still folios in the
reclaimable generations) but fail to isolate any folios due to
promotions, protection, or races, give this type one more chance to
avoid going through the outer loop again.
Signed-off-by: Barry Song (Xiaomi) <baohua@xxxxxxxxxx>
---
mm/vmscan.c | 10 +++++++++-
1 file changed, 9 insertions(+), 1 deletion(-)
diff --git a/mm/vmscan.c b/mm/vmscan.c
index 0670a25d3a7e..dddd2ecf970a 100644
--- a/mm/vmscan.c
+++ b/mm/vmscan.c
@@ -4868,7 +4868,7 @@ static int isolate_folios(unsigned long nr_to_scan, struct lruvec *lruvec,
bool type_fallback_allowed = !is_single_type_reclaim(swappiness);
int type = get_type_to_scan(lruvec, swappiness);
int total_scanned = 0, scanned, tier;
- bool exhausted;
+ bool exhausted, tried = false;
retry:
tier = get_tier_idx(lruvec, type);
@@ -4891,6 +4891,14 @@ static int isolate_folios(unsigned long nr_to_scan, struct lruvec *lruvec,
type_fallback_allowed = false;
goto retry;
}
+ /*
+ * We are not exhausted, but failed to isolate any folios due to
+ * races. Give this type one more chance to avoid a larger loop.
+ */
+ if (!exhausted && !tried) {
+ tried = true;
+ goto retry;
+ }
return total_scanned;
}
--
2.34.1