[PATCH v7 0/8] selftests/cgroup: improve zswap tests robustness and support large page sizes

Li Wang
2026-04-24T04:01:15Z

This patchset aims to fix various spurious failures and improve the overall
robustness of the cgroup zswap selftests.

The primary motivation is to make the tests compatible with architectures
that use non-4K page sizes (such as 64K on ppc64le and arm64). Currently,
the tests rely heavily on hardcoded 4K page sizes and fixed memory limits.
On 64K page size systems, these hardcoded values lead to sub-page granularity
accesses, incorrect page count calculations, and insufficient memory pressure
to trigger zswap writeback, ultimately causing the tests to fail.

Additionally, this series addresses OOM kills occurring in test_swapin_nozswap
by dynamically scaling memory limits, and prevents spurious test failures
when zswap is built into the kernel but globally disabled.

Changes in v7:
Replace my work email by li.wang@linux.dev address.
Add Acked-by: Nhat Pham <nphamcs@gmail.com> to series.
Rebase to the latest branch (only one tiny conflict resolved).

Changes in v6:
Patch 4/8: Use page_size instead of BUF_SIZE
Declear page_size as int but not size_t
Patch 5/8: Use page_size replace the sysconf(_SC_PAGE_SIZE).
Patch 7/8: Adjust the code comments.
Patch 8/8: Declear long type for elapsed and count variables.

Changes in v5:
Patch 1/8: Defined PATH_ZSWAP and PATH_ZSWAP_ENABLED macros.
Patch 4/8: Merge Waiman's work into this patch (use page_size).
Patch 5/8: Change pagesize by the global page_size.
Patch 6/8: Swap data patterns: use getrandom() for wb_group and simple
memset for zw_group to fix the reversed allocation logic.
Patch 7/8: Setting zswap.max to zswap_usage/4 to increase writeback pressure.
Patch 8/8: New added. Just add loops for read zswpwb more times.

Test all passed on:
x86_64(4k), aarch64(4K, 64K), ppc64le(64K).

Li Wang (8):
selftests/cgroup: skip test_zswap if zswap is globally disabled
selftests/cgroup: avoid OOM in test_swapin_nozswap
selftests/cgroup: use runtime page size for zswpin check
selftests/cgroup: rename PAGE_SIZE to BUF_SIZE in cgroup_util
selftests/cgroup: replace hardcoded page size values in test_zswap
selftest/cgroup: fix zswap test_no_invasive_cgroup_shrink on large
pagesize system
selftest/cgroup: fix zswap attempt_writeback() on 64K pagesize system
selftests/cgroup: test_zswap: wait for asynchronous writeback

.../selftests/cgroup/lib/cgroup_util.c | 18 +-
.../cgroup/lib/include/cgroup_util.h | 4 +-
tools/testing/selftests/cgroup/test_core.c | 2 +-
tools/testing/selftests/cgroup/test_freezer.c | 2 +-
.../selftests/cgroup/test_memcontrol.c | 19 +-
tools/testing/selftests/cgroup/test_zswap.c | 181 ++++++++++++------
6 files changed, 152 insertions(+), 74 deletions(-)

--
2.53.0