mm/zswap: Implement per-cgroup proactive writeback
Get series with b4
b4 am [email protected]Versions newest first · linked by author and title
- v5 Latest6 patches 20 repliesIn review
- v45 patches 20 repliesSuperseded
- v34 patches 71 repliesSuperseded
Earlier versions · 2
| Version | Posted | Patches | Replies | Status |
|---|---|---|---|---|
| v2 | 4 patches | 6 replies | Superseded | |
| v1 | 3 patches | 17 replies | Superseded |
Changes in v5 from the cover letter
- Add a new patch to fix missing global shrinker when memory cgroup is disabled.
- Simplify batch writeback logic in shrink_memcg() and improve comments.
- Refactor the writeback retry helper out of shrink_worker().
- Replace the "zswap_writeback_only" memory.reclaim key with a more extensible "source=zswap" key, leaving room for selecting other reclaim sources in the future.
Patches in v5 No applies recorded yet
| # | Subject and files | Size | Replies | Applied |
|---|---|---|---|---|
| 1/6 | mm/zswap: Fix global shrinker when memory cgroup is disabledmm/ | +14 | 5 replies | |
| 2/6 | mm/zswap: Support batch writeback in shrink_memcg()mm/ | +69 | 2 replies | |
| 3/6 | mm/zswap: Extract a reusable writeback helper from shrink_worker()mm/ | +69 | 0 replies | |
| 4/6 | mm/zswap: Implement proactive writebackDocumentation/ Documentation/ include/ +2 more | +106 | 13 replies | |
| 5/6 | mm/zswap: Add per-memcg stat for proactive writebackDocumentation/ include/ mm/ +1 more | +11 | 0 replies | |
| 6/6 | selftests/cgroup: Add tests for zswap proactive writebacktools/ | +160 | 0 replies |
Reviews trailers per patch
1 of 6 patches has a Reviewed-by or Acked-by.
| Patch | Yosry Ahmed | Nhat Pham |
|---|---|---|
| 1/6 | A-b | A-b |
| 2/6 | ||
| 3/6 | ||
| 4/6 | ||
| 5/6 | ||
| 6/6 |
Trailers given in replies are filled; those carried in the patches from earlier versions are outlined with dashes.
Cover letter [PATCH v5 0/6] mm/zswap: Implement per-cgroup proactive writeback
From: Hao Jia <[email protected]>
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 "source=zswap" 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 source=zswap" > memory.reclaim
Patch 1: Fix missing global shrinker when memory cgroup is disabled. Patch 2: Extend shrink_memcg() to support batch writeback and update its
return value semantics, thereby improving the writeback efficiency in the shrink_worker() path.
Patch 3: Extract a reusable writeback helper zswap_shrink_one_memcg() from
shrink_worker().
Patch 4: Extend the memory.reclaim cgroup v2 interface with a new
"source=zswap" key, allowing users to trigger proactive zswap writeback up to a requested budget.
Patch 5: Add the zswpwb_proactive_b stat to track the compressed bytes
of proactive writeback for better monitoring and tuning.
Patch 6: Add tests for zswap proactive writeback.
v4->v5:
- Add a new patch to fix missing global shrinker when memory cgroup is disabled.
- Simplify batch writeback logic in shrink_memcg() and improve comments.
- Refactor the writeback retry helper out of shrink_worker().
- Replace the "zswap_writeback_only" memory.reclaim key with a more extensible "source=zswap" key, leaving room for selecting other reclaim sources in the future.
v3->v4:
- Drop the per-memcg cursor and keep the root cgroup cursor (zswap_next_shrink) logic intact.
- Stick to using the zswap_writeback_only key, and change the proactive writeback size to use the compressed size.
- Consolidate and reuse the logic between shrink_worker() and shrink_memcg(). Enable batch writeback in the shrink_worker() path, while maintaining a low writeback budget in the zswap_store() path.
v2->v3:
- Align the return value of zswap_proactive_writeback() with memory.reclaim and update the corresponding documentation accordingly.
- Resolve conflicts in test_zswap.c on the mm-unstable branch.
- Enhance the zswap proactive writeback selftests to guard against potential future regressions.
v1->v2:
- As suggested by Yosry and Nhat, extend the memory.reclaim cgroup v2 interface with a "zswap_writeback_only" key instead of adding a new dedicated cgroup interface.
- Update the zswap documentation and add selftests for proactive writeback.
[v4] https://lore.kernel.org/all/[email protected]
[v3] https://lore.kernel.org/all/[email protected]
[v2] https://lore.kernel.org/all/[email protected]
[v1] https://lore.kernel.org/all/[email protected]
Hao Jia (6):
mm/zswap: Fix global shrinker when memory cgroup is disabled mm/zswap: Support batch writeback in shrink_memcg() mm/zswap: Extract a reusable writeback helper from shrink_worker() mm/zswap: Implement proactive writeback
mm/zswap: Add per-memcg stat for proactive writeback selftests/cgroup: Add tests for zswap proactive writeback
Documentation/admin-guide/cgroup-v2.rst | 22 +- Documentation/admin-guide/mm/zswap.rst | 11 +- include/linux/memcontrol.h | 1 + include/linux/zswap.h | 7 + mm/memcontrol.c | 3 + mm/vmscan.c | 24 +- mm/zswap.c | 239 +++++++++++++++----- tools/testing/selftests/cgroup/test_zswap.c | 161 ++++++++++++- 8 files changed, 410 insertions(+), 58 deletions(-)
Signature · 1 line
2.34.1