From: Ridong Chen <ridong.chen@linux.dev>
To: Andrew Morton <akpm@linux-foundation.org>
Cc: Johannes Weiner <hannes@cmpxchg.org>,
David Hildenbrand <david@kernel.org>,
Michal Hocko <mhocko@kernel.org>, Qi Zheng <qi.zheng@linux.dev>,
Shakeel Butt <shakeel.butt@linux.dev>,
Lorenzo Stoakes <ljs@kernel.org>,
Kairui Song <kasong@tencent.com>, Barry Song <baohua@kernel.org>,
Axel Rasmussen <axelrasmussen@google.com>,
Yuanchu Xie <yuanchu@google.com>, Wei Xu <weixugc@google.com>,
Yu Zhao <yuzhao@google.com>,
linux-mm@kvack.org, linux-kernel@vger.kernel.org,
Ridong Chen <chenridong@xiaomi.com>
Subject: Re: [PATCH] mm/mglru: fix memcg protection for global proactive reclaim
Date: Fri, 24 Jul 2026 11:47:15 +0800 [thread overview]
Message-ID: <02c1c551-0a0a-4cc2-96c3-5ec0d9f71086@linux.dev> (raw)
In-Reply-To: <20260723165804.f4899595c0523bb16af292fd@linux-foundation.org>
On 7/24/2026 7:58 AM, Andrew Morton wrote:
> On Thu, 23 Jul 2026 21:05:59 +0800 Ridong <ridong.chen@linux.dev> wrote:
>
>> memory.min/low is silently bypassed for MGLRU during global proactive
>> reclaim (writing to the root memory.reclaim). It can be reproduced as
>> follows:
>>
>> ...
>>
>> Factor the tree traversal out into update_memcg_protection() and call
>> it from lru_gen_shrink_node() for the non-kswapd path, so the protection
>> is computed before shrinking. kswapd keeps computing it in
>> lru_gen_age_node(), which also needs it for the min_ttl OOM check.
>>
>> Fixes: e4dde56cd208 ("mm: multi-gen LRU: per-node lru_gen_folio lists")
>
> Do we want cc:stable on this fix?
>
> Sashiko said a couple of things - the memcg ref leak looks real:
> https://sashiko.dev/#/patchset/20260723130559.2343690-1-ridong.chen@linux.dev
>
Sashiko said:
When breaking out of the loop early here, do we need to call
mem_cgroup_iter_break(NULL, memcg) to release the reference?
Since mem_cgroup_iter() holds a reference to the active cgroup css, exiting
without dropping it could cause memory cgroups to leak and accumulate over
time, eventually leading to kernel memory exhaustion.
[ ... ]
This is a bug introduced by this patch, and we will fix it.
Regarding the performance regression:
Placing update_memcg_protection() inside the lru_gen_shrink_node()
non-kswapd path forces every direct reclaimer into an unbounded full
cgroup tree walk.
Will this cause severe performance regressions during global memory pressure?
All allocating tasks entering global direct reclaim would concurrently
traverse the entire memcg tree. This could lead to massive css->refcnt
cacheline bouncing and system latency spikes, scaling negatively with
the number of memory cgroups.
Could this full tree walk be optimized or deferred so direct reclaimers avoid
iterating every single cgroup?
Since MGLRU global reclaim does not iterate over memcgs in the same way
traditional LRU does (which traverses the hierarchy from top to bottom), it
appears we are currently required to walk the full tree, similar to what kswapd
reclaim does.
Does anyone have a better approach in mind?
--
Best regards
Ridong
prev parent reply other threads:[~2026-07-24 3:47 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-07-23 13:05 [PATCH] mm/mglru: fix memcg protection for global proactive reclaim Ridong
2026-07-23 23:58 ` Andrew Morton
2026-07-24 3:47 ` Ridong Chen [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=02c1c551-0a0a-4cc2-96c3-5ec0d9f71086@linux.dev \
--to=ridong.chen@linux.dev \
--cc=akpm@linux-foundation.org \
--cc=axelrasmussen@google.com \
--cc=baohua@kernel.org \
--cc=chenridong@xiaomi.com \
--cc=david@kernel.org \
--cc=hannes@cmpxchg.org \
--cc=kasong@tencent.com \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-mm@kvack.org \
--cc=ljs@kernel.org \
--cc=mhocko@kernel.org \
--cc=qi.zheng@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