Re: [PATCH] mm: Require LRU reclaim progress before retrying direct reclaim

From: Matt Fleming

Date: Thu Apr 16 2026 - 10:51:17 EST


On Wed, Apr 15, 2026 at 03:57:25PM +0100, Pedro Falcato wrote:
> On Fri, Apr 10, 2026 at 11:15:49AM +0100, Matt Fleming wrote:
> > From: Matt Fleming <mfleming@xxxxxxxxxxxxxx>
> >
> > should_reclaim_retry() uses zone_reclaimable_pages() to estimate whether
> > retrying reclaim could eventually satisfy an allocation. It's possible
> > for reclaim to make minimal or no progress on an LRU type despite having
> > ample reclaimable pages, e.g. anonymous pages when the only swap is
> > RAM-backed (zram). This can cause the reclaim path to loop indefinitely.
> >
> > Track LRU reclaim progress (anon vs file) through a new struct
> > reclaim_progress passed out of try_to_free_pages(), and only count a
> > type's reclaimable pages if at least reclaim_progress_pct% was actually
> > reclaimed in the last cycle.
>
> I think there is at least one problem with this heuristic: you are counting
> everything that hasn't made progress as "we cannot reclaim it". When in reality
> you can simply fail to make progress on any given folio as e.g it's referenced
> and we want to give it another spin in the LRU.

The intention was that the percentage threshold would avoid giving up
on reclaim as long as "sufficient" progress was made. This should allow
for some folios to need another trip through the LRU but...

> My theory (from merely reading the patch, maybe I missed something) is that
> a pathological case for this is a lot of folios added to the LRU in a row,
> that are set referenced (or dirty). Say SWAP_CLUSTER_MAX * MAX_RECLAIM_RETRIES
> - it will simply OOM too early.

OK yeah I think I see the problem now: this heuristic applies the
threshold against all reclaimable pages but that falls apart when doing
SWAP_CLUSTER_MAX chunks of reclaim.

> The other question is whether this effectively solves reclaim problems - some
> hard numbers would be great.

I shared some numbers in my reply to Vlastimil, but if there are other
cases you'd like measured I'm happy to run them.