If we are not exhausted (i.e., there are still folios in the reclaimable generations) but fail to isolate any folios due to promotions, protections, or races, retry once more to avoid going through the outer loop again. Signed-off-by: Barry Song (Xiaomi) --- mm/vmscan.c | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/mm/vmscan.c b/mm/vmscan.c index 1f2e574b0061..1f302386d8ab 100644 --- a/mm/vmscan.c +++ b/mm/vmscan.c @@ -4862,7 +4862,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); @@ -4885,6 +4885,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 + * promotions, protections, or races. Retry once to avoid a larger loop. + */ + if (!exhausted && !tried) { + tried = true; + goto retry; + } return total_scanned; } -- 2.34.1