Re: [RFC 0/2] mm: add source selectors to memory.reclaim
From: Gregory Price (Meta)
Date: Wed Oct 21 2026 - 23:56:32 EST
On 2026-10-20 21:01 +0800, Li Zhe wrote:
> On 10/20/26 12:10 AM, Gregory Price wrote:
>
> I agree that the kernel reclaim and demotion behavior still has room for
> improvement, and the watermark changes and the bottom-up proactive/async
> reclaim idea you mentioned may be useful to explore for some tiering
> scenarios. But I think there is also an unavoidable userspace policy
> component here. The kernel can improve whole-cgroup reclaim, but it
> cannot know every controller's placement goal.
>
> For example, one controller may want to keep a specific per-tier
> resident ratio for a cgroup. Another use case, as Joshua pointed out in
> another reply, is reclaiming from a lower tier first so that later
> top-tier reclaim has room for demotion. A single default memory.reclaim
> algorithm cannot express these per-cgroup policy choices.
>
The latter of these should probably be some level of the system default,
that's why I brought it up as well. (proactive reclaim should prefer to
make progress from the coldest tier first, then work its way up).
I'm not convinced a reclaim interface is the right way to affect a
per-tier resident ratio policy. That feels like a hack to get around
solving the harder problem of something like tiered memcg counters
(which would otherwise drive reclaim to work exactly the way you
describe for resident ratios).
> I am not sure whether changing the default whole-cgroup reclaim behavior
> in this direction could affect existing userspace dependencies. In the
> old nodes= discussion, Mina mentioned that Meta's reclaim stack relied on
> memory.reclaim triggering demotion [1].
>
Yes and on its surface this is something I could see Meta using, however
I question whether we're simply trying to find a convenient way around
fixing reclaim to do the right thing (not invert the LRU, apply per-tier
memcg limits, etc).
> I also do not intend source= to lock in current reclaim implementation
> details. It should stay consistent with the current design: source= only
> selects the resident source to which reclaim pressure is applied, while
> the kernel remains free to change the reclaim policy.
>
Well, sort of, you get exposed to the implementation details by having
to negotiate what is considered progress under different scenarios.
Lets take one example - what should happen when:
- 2 node system, node0=DRAM, node1=CXL
- zswap is configured
- echo 1G source=nodelist:1 > memory.reclaim
- node 1 is pressured, zsmalloc falls back to node0 to allocate
Should that be considered progress? We reclaimed from node1, but
increased pressure on node0 - which might have kicked kswapd or memcg
accounting to demote memory from node0 to node1.
Should zswap also take that nodelist as a constraint?
At the very least i think you need to add details in your cover that
demonstrates the process of doing something like per-node resident
ratios, and show that it works as you intend.
--
~Gregory