Re: [PATCH] mm/mglru: force aging the lruvec when min_seq pinned
From: Kairui Song
Date: Thu Jul 30 2026 - 08:38:04 EST
On Thu, Jul 30, 2026 at 5:33 PM Zhaoyang Huang <huangzhaoyang@xxxxxxxxx> wrote:
>
> On Thu, Jul 30, 2026 at 5:06 PM Barry Song <baohua@xxxxxxxxxx> wrote:
> >
> > On Thu, Jul 30, 2026 at 3:24 PM zhaoyang.huang
> > <zhaoyang.huang@xxxxxxxxxx> wrote:
> > >
> > > From: Zhaoyang Huang <zhaoyang.huang@xxxxxxxxxx>
> > >
> > > This submission addresses an issue where the memcg MGLRU's min_seq is
> > > pinned by an orphan page—a page that resides in the page cache but
> > > lacks a corresponding reference count, while the number of GENs has not
> > > yet met the criteria of aging. I believe such pages should be detected
> > > and handled elsewhere rather than affecting the LRU in this way(legacy
> > > LRU could move forward by bringing this kind of folio along with).
> > > Therefore, I propose moving these folios to the next generation when
> > > isolation makes no progress at all.
> > >
> > > Signed-off-by: Zhaoyang Huang <zhaoyang.huang@xxxxxxxxxx>
> > > ---
> > > include/linux/mmzone.h | 6 ++++++
> > > mm/vmscan.c | 45 +++++++++++++++++++++++++++++++++++++++++-
> > > 2 files changed, 50 insertions(+), 1 deletion(-)
> > >
> >
> > This is very weird. This seems like using a sledgehammer to kill a fly :-)
> >
> > Do you mean that isolate_folio() fails, the folio is put back
> > into the oldest generation, and the next time it is scanned, it
> > still fails to be isolated? As a result, scan_folios() makes
> > no progress at all?
> > And is it because the oldest generation contains only this
> > folio, leaving no other folios for scan_folios() to scan?
> >
> > Why can't you simply promote the folio?
> > Do you know why isolate_folio() keeps failing? I suspect it's
> > because folio_try_get(folio) fails repeatedly?
Hi Barry and Zhaoyang,
Thanks for the patch, but I agree with Barry, this is overkill for the problem
> Yes. As described in commit message, the orphan folio is an abnormal
> one as it is on page cache but has folio->refcount=0 which makes it
What? A folio stays in page cache but has folio->refcount == 0? You
mean a freezed refcount for a long time? Then that's a problem that
need to be fixed, but not on the MGLRU side. A lot of things could go
wrong of a folio like this stays there for a long time, e.g. a simple
filemap_get_folio call will just livelock, and many other parts too.
I've met this kind of problem several times and that's really whoever
froze the folio's fault, You'll keep hitting this if you just paper
over the symptom instead of fixing the root cause.