diff options
| author | Barry Song (Xiaomi) <baohua@kernel.org> | 2026-08-29 15:42:04 +0800 |
|---|---|---|
| committer | Andrew Morton <akpm@linux-foundation.org> | 2026-10-06 17:39:04 -0700 |
| commit | e006ab5a0f1f411202bc6a20061663b1954d79eb (patch) | |
| tree | ff6a279ce9d2001a93659cde70adce3aff74cb84 | |
| parent | 715d7fbe42393658c42ceaea7f61b147895c9e3a (diff) | |
mm/mglru: make retry logic explicit in isolate_folios()
The existing mainline code retries the same type once in a rather subtle
way. `for_each_evictable_type()` may provide one more iteration, allowing
the same type to be retried if we scanned some folios but failed to
isolate any due to protections, promotions, or races. This patch makes
the retry behavior explicit.
Link: https://lore.kernel.org/20260829074204.45304-3-baohua@kernel.org
Signed-off-by: Barry Song (Xiaomi) <baohua@kernel.org>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Reviewed-by: Baolin Wang <baolin.wang@linux.alibaba.com>
Cc: Axel Rasmussen <axelrasmussen@google.com>
Cc: Baoquan He <baoquan.he@linux.dev>
Cc: David Hildenbrand <david@kernel.org>
Cc: David Stevens <stevensd@chromium.org>
Cc: Johannes Weiner <hannes@cmpxchg.org>
Cc: Kairui Song <kasong@tencent.com>
Cc: Lorenzo Stoakes <ljs@kernel.org>
Cc: Michal Hocko <mhocko@kernel.org>
Cc: Ridong Chen <chenridong@xiaomi.com>
Cc: Shakeel Butt <shakeel.butt@linux.dev>
Cc: Wei Xu <weixugc@google.com>
Cc: Yuanchu Xie <yuanchu@google.com>
| -rw-r--r-- | mm/vmscan.c | 10 |
1 files changed, 10 insertions, 0 deletions
diff --git a/mm/vmscan.c b/mm/vmscan.c index 1b40c63706f2..413efe44d1f6 100644 --- a/mm/vmscan.c +++ b/mm/vmscan.c @@ -4840,6 +4840,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 tried = false; retry: tier = get_tier_idx(lruvec, type); @@ -4859,9 +4860,18 @@ retry: */ if (!scanned && type_fallback_allowed) { type = !type; + tried = true; type_fallback_allowed = false; goto retry; } + /* + * We scanned some folios but failed to isolate any due to promotions, + * protections, or races. Retry once to avoid a larger loop. + */ + if (scanned && !tried) { + tried = true; + goto retry; + } return total_scanned; } |
