From: Baolin Wang <baolin.wang@linux.alibaba.com>
To: Max Kellermann <max.kellermann@ionos.com>,
akpm@linux-foundation.org, kasong@tencent.com,
qi.zheng@linux.dev, shakeel.butt@linux.dev, baohua@kernel.org,
axelrasmussen@google.com, yuanchu@google.com, weixugc@google.com,
baoquan.he@linux.dev, david@kernel.org, ljs@kernel.org,
liam@infradead.org, vbabka@kernel.org, rppt@kernel.org,
surenb@google.com, mhocko@suse.com, hannes@cmpxchg.org,
linux-mm@kvack.org, linux-kernel@vger.kernel.org,
rcu@vger.kernel.org
Subject: Re: [PATCH v3 3/5] mm/mglru: cache the last memcg node, make tail insertion constant time
Date: Mon, 23 Nov 2026 17:59:54 +0800 [thread overview]
Message-ID: <92bc11db-ef40-48e3-8768-9af36bfb5a7e@linux.alibaba.com> (raw)
In-Reply-To: <20261116081403.216452-4-max.kellermann@ionos.com>
On 11/16/26 4:14 PM, Max Kellermann wrote:
> Rotating or onlining a memcg currently uses hlist_nulls_add_tail_rcu()
> which walks the destination bin to find its tail while holding
> `memcg_lru.lock` with interrupts disabled. With thousands of cgroups,
> this takes a long time and causes severe lock contention.
>
> Cache a pointer to each bin's last node, making tail insertion O(1).
> This requires remembering the bin number (but the new struct field
> occupies a hole, so it does not grow).
>
> In a micro benchmark that creates 1500 cgroups and repeatedly writes
> `1024M swappiness=0` to `memory.reclaim` in 8 threads, the request
> rate increases by a factor of 9.5 and the average duration of each
> write request is reduced by 89%.
>
> All writes return EAGAIN in both runs; the benchmark measures the cost
> of reclaim attempts that cannot meet their requested target, not
> reclaimed throughput.
>
> Fixes: e4dde56cd208 ("mm: multi-gen LRU: per-node lru_gen_folio lists")
I don't think this fixes anything, right?
> Signed-off-by: Max Kellermann <max.kellermann@ionos.com>
> ---
Thanks. We hit the same issue in our stress tests and confirmed that
this optimization works.
Reviewed-by: Baolin Wang <baolin.wang@linux.alibaba.com>
next prev parent reply other threads:[~2026-11-23 10:00 UTC|newest]
Thread overview: 15+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-11-16 8:13 [PATCH v3 0/5] mm: multi-gen LRU: reduce memcg rotation overhead Max Kellermann
2026-11-16 8:13 ` [PATCH v3 1/5] include/linux/rculist_nulls: add hlist_nulls_add_behind_rcu() Max Kellermann
2026-11-17 8:14 ` sashiko-bot
2026-11-19 19:55 ` Barry Song
2026-11-16 8:14 ` [PATCH v3 2/5] mm/vmscan: move code to lru_gen_{add,del}_memcg() Max Kellermann
2026-11-23 1:35 ` Barry Song
2026-11-23 9:40 ` Baolin Wang
2026-11-16 8:14 ` [PATCH v3 3/5] mm/mglru: cache the last memcg node, make tail insertion constant time Max Kellermann
2026-11-23 1:53 ` Barry Song
2026-11-23 9:59 ` Baolin Wang [this message]
2026-11-16 8:14 ` [PATCH v3 4/5] mm/mglru: avoid redundant rotations of young memcgs Max Kellermann
2026-11-23 2:01 ` Barry Song
2026-11-16 8:14 ` [PATCH v3 5/5] mm/mglru: reschedule between memcg reclaim attempts Max Kellermann
2026-11-23 2:24 ` Barry Song
2026-11-23 10:09 ` Baolin Wang
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=92bc11db-ef40-48e3-8768-9af36bfb5a7e@linux.alibaba.com \
--to=baolin.wang@linux.alibaba.com \
--cc=akpm@linux-foundation.org \
--cc=axelrasmussen@google.com \
--cc=baohua@kernel.org \
--cc=baoquan.he@linux.dev \
--cc=david@kernel.org \
--cc=hannes@cmpxchg.org \
--cc=kasong@tencent.com \
--cc=liam@infradead.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-mm@kvack.org \
--cc=ljs@kernel.org \
--cc=max.kellermann@ionos.com \
--cc=mhocko@suse.com \
--cc=qi.zheng@linux.dev \
--cc=rcu@vger.kernel.org \
--cc=rppt@kernel.org \
--cc=shakeel.butt@linux.dev \
--cc=surenb@google.com \
--cc=vbabka@kernel.org \
--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