Re: [PATCH v4 0/5] mm/zswap: Implement per-cgroup proactive writeback
From: Hao Jia
Date: Mon Jun 22 2026 - 02:09:14 EST
On 2026/6/21 12:20, Muchun Song wrote:
On Jun 18, 2026, at 12:48, Hao Jia <jiahao.kernel@xxxxxxxxx> wrote:
From: Hao Jia <jiahao1@xxxxxxxxxxx>
Zswap currently writes back pages to backing swap reactively, triggered
either by the shrinker or by the pool reaching its size limit. Although
proactive memory reclaim can automatically write back a portion of zswap
pages via the shrinker, it cannot explicitly control the amount of
writeback for a specific memory cgroup. Moreover, proactive memory reclaim
may not always be triggered during a steady state.
In certain scenarios, it is desirable to trigger writeback in advance to
free up memory. For example, users may want to prepare for an upcoming
memory-intensive workload by flushing cold memory to the backing storage
when the system is relatively idle.
This patch series introduces a "zswap_writeback_only" key to memory.reclaim
cgroup interface, allowing users to proactively write back cold compressed
data from zswap to the backing swap device. When specified, this key
bypasses standard memory reclaim and exclusively performs proactive zswap
writeback up to the requested budget. If omitted, the default reclaim
behavior remains unchanged.
Example usage:
# Write back 10MB of compressed data from zswap to the backing swap
echo "10M zswap_writeback_only" > memory.reclaim
I’m not entirely sure if other candidate names were already brought up
in previous discussions, so my apologies if I'm repeating something here!
I do think expanding memory.reclaim is a great approach. That said, I
was wondering if we could make the interface a bit more concise while
keeping it flexible for future extensions.
Essentially, what we want is to control the specific targets of the reclaim
process—such as file, anon, or zswap. What do you think about using
something like "source=zswap"? For instance, if we want to reclaim 10M from
zswap, the command would look like this:
echo "10M source=zswap" > memory.reclaim
Thanks for the suggestion. TBH, I personally think your approach makes more sense than "zswap_writeback_only".
Hi YoungJun and Yosry,
I am not sure if this suggestion from Muchun could decouple zswap proactive writeback from the swap tiers, or make it easier to migrate to swap tiers in the future:
echo "10M source=zswap" > memory.reclaim
For now, we only specify the source. Later on, the swap tiers feature could extend this to control whether to demote to SSD swap, HDD swap, or other tiers.
Thanks,
Hao
If we only want to reclaim 10M from file pages, we could easily extend the
syntax:
echo "10M source=file" > memory.reclaim
And of course, we could even combine them down the road:
echo "10M source=anon,file" > memory.reclaim
to only reclaim anon and file but bypass zswap.
Just some thoughts of mine.
Muchun,
Thanks