From: "Li Zhe" <lizhe.67@bytedance.com>
To: <gourry@gourry.net>
Cc: <akpm@linux-foundation.org>, <cgroups@vger.kernel.org>,
<david@kernel.org>, <joshua.hahnjy@gmail.com>,
<linux-doc@vger.kernel.org>, <linux-kernel@vger.kernel.org>,
<linux-mm@kvack.org>, <lizhe.67@bytedance.com>, <ljs@kernel.org>,
<mhocko@suse.com>, <muchun.song@linux.dev>, <rakie.kim@sk.com>,
<roman.gushchin@linux.dev>, <shakeel.butt@linux.dev>,
<weixugc@google.com>, <ying.huang@linux.alibaba.com>,
<ziy@nvidia.com>
Subject: Re: [RFC v2 1/1] mm: add source selector to memory.reclaim
Date: Fri, 13 Nov 2026 16:49:48 +0800 [thread overview]
Message-ID: <20261113084948.78661-1-lizhe.67@bytedance.com> (raw)
In-Reply-To: <179455442014.482102.4069329165987986914.b4-reply@b4>
On Fri, 13 Nov 2026 02:20:20 -0500, gourry@gourry.net wrote:
> > On 2026-11-02 15:04 +0800, Li Zhe wrote:
> > + Specifying a source value constrains where proactive reclaim applies
> > + pressure. Currently only source=nodes:<nodelist> is supported. For
> > + example::
> > +
> > + echo "1G source=nodes:0-1" > memory.reclaim
> > +
> > + This reclaims memory of the target cgroup resident on nodes 0-1.
>
> you buried the fact that you want to allow source=zswap in your cover
> letter. I was confused by nodes: was needed here until i re-read.
>
> As Joshua mentioned, i don't think you need the separate cover letter,
> and I agree this is far too long for the proposed change.
Agreed. The nodes: prefix was meant to keep source= a typed selector,
but I made the motivation and possible future extensions too long and
distracting. I will make v3 much clearer and shorter, and keep the focus
on source=nodes.
> ---
>
> When I asked for testing, I wasn't concerned with the functionality,
> I was asking what problem this actually solves. performance? fairness?
>
> Shaping the distribution of memory is neat and clearly works, but why
> does userspace want this?
>
> The interface "lacking flexibility" is not a problem in and of itself.
Thanks, this is a fair point. Sorry, I also made that earlier
explanation too long, so let me summarize the intended use cases here:
https://lore.kernel.org/all/67fcd8db-269d-43f1-aea2-8c41165747d0@bytedance.com/
In short, performance, fairness and cost are all part of the goal. One
target is mixed DRAM/CXL systems where user space keeps each memcg near
its own DRAM/CXL resident ratio target, based on the workload's
latency/throughput and cost requirements. Another target is the case you
described below, where user space wants memcg-scoped reclaim to apply
pressure to the desired tier first, rather than reclaiming from warmer
memory on the top tier. This is especially useful when a memcg is close
to its memory limit and user space wants charge-reducing reclaim to
start from colder/lower-tier memory first.
> I CAN see why you might want to proactively shape what data is swapped.
> Let me give you an example:
>
> ---
> The global node reclaim interfaces allow us to put pressure on distinct
> nodes - which lets us shape which node is swapped from first.
>
> Example: node0-1=DRAM, node2-3:CXL
>
> echo 1G > node2/reclaim # swap from CXL
> echo 1G > node3/reclaim # swap from CXL
> echo 1G > node0/reclaim # demote to CXL
> echo 1G > node1/reclaim # demote to CXL
>
> But the memcg.reclaim interface only allows us to pressure the complete
> set of cpuset.mems nodes for that memcg
>
> cat cpuset.mems # 0-3
> echo 1G > memory.reclaim # makes progress from any of 0-3
>
> Presently, proactive reclaim iterates nodes in node or fallback order,
> meaning it attempts to make progress from the fastest node possible
> first - which attempts to demote by default. If the lower nodes are
> full, this demotion will fail and we'll swap directly from the top tier,
> which is (presumably) warmer than the bottom tiers.
>
> Enable source-bound reclaim in the memory.reclaim interface so that user
> space can have the same control over memcg memory tiers that global
> proactive reclaim has.
>
> echo 2G source=nodes:2-3 > memory.reclaim # [z]swap from CXL
> echo 2G source=nodes:0-1 > memory.reclaim # demote to CXL
>
> This lets user proactive reclaim to target the coldest memory first
> rather than preferring to reclaim from node0 first and potentially
> swap out memory warmer than what is present on a CXL tier.
> ---
>
> With this, you might be able to demonstrate fewer refaults and less
> DRAM (node0) memory consumed by zswap. These are clear benefits.
Thanks for the example. It makes the problem much easier to discuss. I
will refer to it when reworking the v3 motivation, and will avoid
framing the issue as a generic flexibility problem.
> I would argue that memory.reclaim should operate this way anyway,
> and that would could make proactive reclaim do this by default, but
> I could see the policy bits in userland being useful as well
>
> Performance may not be the only reason you want this, but you need to
> help me understand what you're trying to accomplish.
Thanks again for the review and suggestions.
Thanks,
Zhe
next prev parent reply other threads:[~2026-11-13 8:50 UTC|newest]
Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-11-02 7:04 [RFC v2 0/1] " Li Zhe
2026-11-02 7:04 ` [RFC v2 1/1] " Li Zhe
2026-11-13 7:20 ` Gregory Price (Meta)
2026-11-13 8:49 ` Li Zhe [this message]
2026-11-12 23:48 ` [RFC v2 0/1] " Joshua Hahn
2026-11-13 3:36 ` Li Zhe
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=20261113084948.78661-1-lizhe.67@bytedance.com \
--to=lizhe.67@bytedance.com \
--cc=akpm@linux-foundation.org \
--cc=cgroups@vger.kernel.org \
--cc=david@kernel.org \
--cc=gourry@gourry.net \
--cc=joshua.hahnjy@gmail.com \
--cc=linux-doc@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-mm@kvack.org \
--cc=ljs@kernel.org \
--cc=mhocko@suse.com \
--cc=muchun.song@linux.dev \
--cc=rakie.kim@sk.com \
--cc=roman.gushchin@linux.dev \
--cc=shakeel.butt@linux.dev \
--cc=weixugc@google.com \
--cc=ying.huang@linux.alibaba.com \
--cc=ziy@nvidia.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
all inboxes | Powered by JetHome®