Hello Mina, On Tue, Nov 22, 2022 at 12:38:45PM -0800, Mina Almasry wrote: > Since commit 3f1509c57b1b ("Revert "mm/vmscan: never demote for memcg > reclaim""), the proactive reclaim interface memory.reclaim does both > reclaim and demotion. This is likely fine for us for latency critical > jobs where we would want to disable proactive reclaim entirely, and is > also fine for latency tolerant jobs where we would like to both > proactively reclaim and demote. > > However, for some latency tiers in the middle we would like to demote but > not reclaim. This is because reclaim and demotion incur different latency > costs to the jobs in the cgroup. Demoted memory would still be addressable > by the userspace at a higher latency, but reclaimed memory would need to > incur a pagefault. > > To address this, I propose having reclaim-only and demotion-only > mechanisms in the kernel. There are a couple possible > interfaces to carry this out I considered: > > 1. Disable demotion in the memory.reclaim interface and add a new > demotion interface (memory.demote). > 2. Extend memory.reclaim with a "demote=<int>" flag to configure the demotion > behavior in the kernel like so: > - demote=0 would disable demotion from this call. > - demote=1 would allow the kernel to demote if it desires. > - demote=2 would only demote if possible but not attempt any > other form of reclaim. Unfortunately, our proactive reclaim stack currently relies on memory.reclaim doing both. It may not stay like that, but I'm a bit wary of changing user-visible semantics post-facto. In patch 2, you're adding a node interface to memory.demote. Can you add this to memory.reclaim instead? This would allow you to control demotion and reclaim independently as you please: if you call it on a node with demotion targets, it will demote; if you call it on a node without one, it'll reclaim. And current users will remain unaffected.