From: Johannes Weiner <hannes@cmpxchg.org>
To: Kairui Song <ryncsn@gmail.com>
Cc: lsf-pc@lists.linux-foundation.org,
Axel Rasmussen <axelrasmussen@google.com>,
Yuanchu Xie <yuanchu@google.com>, Wei Xu <weixugc@google.com>,
linux-mm <linux-mm@kvack.org>
Subject: Re: [LSF/MM/BPF TOPIC] Improving MGLRU
Date: Fri, 20 Feb 2026 13:24:26 -0500 [thread overview]
Message-ID: <aZim2hT0nNjcRYVG@cmpxchg.org> (raw)
In-Reply-To: <CAMgjq7BoekNjg-Ra3C8M7=8=75su38w=HD782T5E_cxyeCeH_g@mail.gmail.com>
On Fri, Feb 20, 2026 at 01:25:33AM +0800, Kairui Song wrote:
> Hi All,
>
> Apologies I forgot to add the proper tag in the previous email so
> resending this.
>
> MGLRU has been introduced in the mainline for years, but we still have two LRUs
> today. There are many reasons MGLRU is still not the only LRU implementation in
> the kernel.
>
> And I've been looking at a few major issues here:
>
> 1. Page flag usage: MGLRU uses many more flags (3+ more) than Active/Inactive
> LRU.
> 2. Regressions: MGLRU might cause regression, even though in many workloads it
> outperforms Active/Inactive by a lot.
> 3. Metrics: MGLRU makes some metrics work differently, for example: PSI,
> /proc/meminfo.
> 4. Some reclaim behavior is less controllable.
I would be very interested in discussing this topic as well.
> 2. Regressions: Currently regression is a more major problem for us.
> From our perspective, almost all regressions are caused by an under- or
> overprotected file cache. MGLRU's PID protection either gets too aggressive
> or too passive or just have a too long latency. To fix that, I'd propose a
> LFU-like design and relax the PID's aggressiveness to make it much more
> proactive and effective for file folios. The idea is always use 3 bits in
> the page flags to count the referenced time (which would also replace
> PG_workingset and PG_referenced). Initial tests showed a 30% reduction of
> refaults, and many regressions are gone. A flow chart of how the MGLRU idea
> might work:
Are you referring to refaults on the page cache side, or swapins?
Last time we evaluated MGLRU on Meta workloads, we noticed that it
tends to do better with zswap, but worse with disk swap. It seemed to
just prefer reclaiming anon, period.
For the balancing between anon and file to work well in all
situations, it needs to have a notion of backend speed and factor in
the respective cost of misses on each side.
> 4. MGLRU's swappiness is kind of useless in some situations compared to
> Active / Inactive LRU, since its force protects the youngest two gen, so
> quite often we can only reclaim one type of folios. To workaround that, the
> user usually runs force aging before reclaim. So, can we just remove the
> force protection of the youngest two gens?
[...]
> 6. Other issues and discussion on whether the above improvements will help
> solve them or make them worse. e.g.
[...]
> Can we just ignore the shadow for anon folios? MGLRU basically activates
> anon folios unconditionally, especially if we combined with the LFU like
> idea above we might only want to track the 3 bit count, and get rid of
> the extra bit usage in the shadow. The eviction performance might be even
> better, and other components like swap table [3] will have more bits to use
> for better performance and more features.
On the face of it, both of these sounds problematic to me. Why are
anon pages special cased?
The cost of reclaiming a page is:
reuse frequency * cost of a miss
The *type* of the page is not all that meaningful for workload
performance. The wait time is qualitatively the same.
If you assume every refaulting anon is hot, it'll fall apart when the
anon set is huge and has little locality.
next prev parent reply other threads:[~2026-02-20 18:24 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-02-19 17:25 Kairui Song
2026-02-20 18:24 ` Johannes Weiner [this message]
2026-02-21 6:03 ` Kairui Song
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=aZim2hT0nNjcRYVG@cmpxchg.org \
--to=hannes@cmpxchg.org \
--cc=axelrasmussen@google.com \
--cc=linux-mm@kvack.org \
--cc=lsf-pc@lists.linux-foundation.org \
--cc=ryncsn@gmail.com \
--cc=weixugc@google.com \
--cc=yuanchu@google.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox