From: Kairui Song <ryncsn@gmail.com>
To: Tianyi Chen <hi@tychen.cc>
Cc: Maxim Muzafarov <maxmuzaf@gmail.com>,
linux-mm@kvack.org, Kairui Song <kasong@tencent.com>
Subject: Re: [RFC PATCH 0/1] mm/mglru: MADV_RANDOM page cache never ages and thrashes the oldest generation
Date: Thu, 19 Nov 2026 02:45:05 +0800 [thread overview]
Message-ID: <av3vMMhFbiaop7zA@KASONG-MC4> (raw)
In-Reply-To: <179502478384.194898.8139869410612997037.streamfolio@tychen.cc>
On Wed, Nov 18, 2026 at 05:59:43PM +0800, Tianyi Chen wrote:
> Hi Maxim,
>
> I can still reproduce this on mm-unstable (1b697248a755). I used a
> scaled-down version of your fio script: a 120 MiB vector file, a 38 MiB
> scan file, and a 128 MiB memcg without swap in a KVM guest (scan at
> about 5 seconds, vector readers for 14 seconds).
>
> It looks like vma_has_recency() is why the hot pages aren't promoted.
Hi Tianyi,
Yeah I also described that here:
https://lore.kernel.org/linux-mm/20261016-mglru-fg-v4-0-2106750c0bfa@tencent.com/
And in previous reply:
https://lore.kernel.org/linux-mm/CAMgjq7AEf_cJsLw4fxs7m5ntYPW9mjCOC_-w5j6ihk8F=xLRWA@mail.gmail.com/
> It returns false for VM_RAND_READ, so the MGLRU page-table walk and rmap
> skip the accessed bits for those mappings. Letting reclaim see those
> accesses again stops the thrashing. I don't think that's the right fix,
> though. In a single-pass random read test (warm a 64 MiB file, then read
> a 352 MiB file once in random order with MADV_RANDOM, in an 88 MiB memcg),
> that change evicted the whole hot set every time. I suspect that's the
> kind of case the check is meant to protect.
>
> Your threshold stops the thrashing too, with more faults before things
> settle. Your patch no longer applies as-is, so I ported just the
> threshold to the current code. It never fired in the same single-pass
> test, and the hot set stayed resident. I'd fix this on the recovery
> side, along the lines of your patch or Kairui's refault-distance idea.
>
> Major faults/s over the last four seconds or so, median of five runs:
>
> Configuration Major faults/s
> Stock MGLRU 27,283
> MGLRU, count mapped accesses again 0
> MGLRU, ported threshold 0
> MGLRU, no random advice 0
> Classic LRU, keep random advice 0
>
> I saw the same difference between MGLRU and classic LRU in a small
> synthetic OpenSearch 3.6 test. The median post-scan p99 was 109 ms
> with MGLRU and 5.5 ms with classic LRU.
Can you share the test step on that one? I'm working on the long
term goal of bring back refault distance:
https://lwn.net/Articles/945266
And the recent RFC:
https://lore.kernel.org/linux-mm/20260502-mglru-fg-v1-0-913619b014d9@tencent.com/
And previous test with it:
https://lore.kernel.org/linux-mm/avd5bI-b9y1nKWw5@KASONG-MC4/
(Basically bring back refault distance will increase certain
DB performance by 5X, fio by >60%, and it should resolve the
workingset shift issue too).
MGLRU not performing well with certain over committed or workingset
shift is a known problem. Unfortunately bring back refault distance
is not that easy, the model doesn't simply fit and I'm trying to make
more space in the shadow for both distance and gen marker so it
won't break the planned readahead support.
The threshold of of refault distance re-activation is also very
tricky to tune for MGLRU, I hope we can do that after the FG series,
as demostrated by the RFC above (that RFC wasn't in the final shape
either though, that's why it's RFC).
I'll include your case to be covered and help fix these in the upstream
ASAP if you can help provide that :)
next prev parent reply other threads:[~2026-11-18 18:45 UTC|newest]
Thread overview: 7+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-11-01 16:04 [RFC PATCH 0/1] mm/mglru: MADV_RANDOM page cache never ages and thrashes the oldest generation Maxim Muzafarov
2026-11-01 16:04 ` [RFC PATCH 1/1] mm/mglru: age when the oldest generation is thrashing Maxim Muzafarov
2026-11-02 16:04 ` sashiko-bot
2026-11-01 18:02 ` [RFC PATCH 0/1] mm/mglru: MADV_RANDOM page cache never ages and thrashes the oldest generation Kairui Song
2026-11-18 17:59 ` Tianyi Chen
2026-11-18 18:45 ` Kairui Song [this message]
2026-11-19 8:24 ` Tianyi Chen
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=av3vMMhFbiaop7zA@KASONG-MC4 \
--to=ryncsn@gmail.com \
--cc=hi@tychen.cc \
--cc=kasong@tencent.com \
--cc=linux-mm@kvack.org \
--cc=maxmuzaf@gmail.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