From: "Barry Song (Xiaomi)" <baohua@kernel.org>
To: akpm@linux-foundation.org
Cc: hannes@cmpxchg.org, mhocko@kernel.org, qi.zheng@linux.dev,
shakeel.butt@linux.dev, kasong@tencent.com,
axelrasmussen@google.com, yuanchu@google.com, weixugc@google.com,
baoquan.he@linux.dev, baolin.wang@linux.alibaba.com,
mason@kernel.org, david@kernel.org, linux-mm@kvack.org,
linux-kernel@vger.kernel.org, ridong.chen@linux.dev,
yuzhao@google.com, Barry Song <baohua@kernel.org>
Subject: [PATCH 3/3] mm/mglru: report root reclaim to memory.pressure_level
Date: Sun, 29 Nov 2026 22:37:59 +0800 [thread overview]
Message-ID: <20261129143759.96221-4-baohua@kernel.org> (raw)
In-Reply-To: <20261129143759.96221-1-baohua@kernel.org>
From: Chris Mason <mason@kernel.org>
With MGLRU enabled, memory.pressure_level listeners on the cgroup v1
root can miss global reclaim: kswapd sends them no events, and direct
reclaim only "critical" ones.
On v1 the eventfds are only fed by vmpressure() calls with tree=true.
shrink_node() makes that call after walking the memcgs, but it hands
root reclaim to lru_gen_shrink_node() and returns first. The MGLRU walk
only calls vmpressure() from shrink_one(), with tree=false, which has no
consumer on v1. That leaves vmpressure_prio() in direct reclaim.
The fix used here is to make the same subtree report at the end of the
MGLRU walk of a node.
Listeners for "medium" and "critical" can miss events they got before,
since a vmpressure_prio() report is now averaged with the pages that the
walk freed in the same window.
Fixes: e4dde56cd208 ("mm: multi-gen LRU: per-node lru_gen_folio lists")
Signed-off-by: Chris Mason <mason@kernel.org>
Signed-off-by: David Hildenbrand (Arm) <david@kernel.org>
Signed-off-by: Barry Song (Xiaomi) <baohua@kernel.org>
---
mm/vmscan.c | 6 ++++++
1 file changed, 6 insertions(+)
diff --git a/mm/vmscan.c b/mm/vmscan.c
index 5fb3055a4302..99cb209797b4 100644
--- a/mm/vmscan.c
+++ b/mm/vmscan.c
@@ -5511,6 +5511,7 @@ static void lru_gen_shrink_lruvec(struct lruvec *lruvec, struct scan_control *sc
static void lru_gen_shrink_node(struct pglist_data *pgdat, struct scan_control *sc)
{
struct blk_plug plug;
+ unsigned long scanned = sc->nr_scanned;
unsigned long reclaimed = sc->nr_reclaimed;
VM_WARN_ON_ONCE(!root_reclaim(sc));
@@ -5545,6 +5546,11 @@ static void lru_gen_shrink_node(struct pglist_data *pgdat, struct scan_control *
clear_mm_walk();
blk_finish_plug(&plug);
+
+ /* Record the subtree's reclaim efficiency */
+ if (!sc->proactive)
+ vmpressure(sc->gfp_mask, sc->order, sc->target_mem_cgroup, true,
+ sc->nr_scanned - scanned, sc->nr_reclaimed - reclaimed);
done:
if (sc->nr_reclaimed > reclaimed)
kswapd_try_clear_hopeless(pgdat, sc->order, sc->reclaim_idx);
--
2.39.3 (Apple Git-146)
prev parent reply other threads:[~2026-11-29 14:38 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-11-29 14:37 [PATCH 0/3] mm/mglru: fix a few reclaim issues Barry Song (Xiaomi)
2026-11-29 14:37 ` [PATCH 1/3] mm/mglru: count all generations as evictable Barry Song (Xiaomi)
2026-11-29 14:37 ` [PATCH 2/3] mm/mglru: test PG_lru before taking a folio reference Barry Song (Xiaomi)
2026-11-29 14:37 ` Barry Song (Xiaomi) [this message]
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=20261129143759.96221-4-baohua@kernel.org \
--to=baohua@kernel.org \
--cc=akpm@linux-foundation.org \
--cc=axelrasmussen@google.com \
--cc=baolin.wang@linux.alibaba.com \
--cc=baoquan.he@linux.dev \
--cc=david@kernel.org \
--cc=hannes@cmpxchg.org \
--cc=kasong@tencent.com \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-mm@kvack.org \
--cc=mason@kernel.org \
--cc=mhocko@kernel.org \
--cc=qi.zheng@linux.dev \
--cc=ridong.chen@linux.dev \
--cc=shakeel.butt@linux.dev \
--cc=weixugc@google.com \
--cc=yuanchu@google.com \
--cc=yuzhao@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