.../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 | 174 +++++++++++++----- 6 files changed, 148 insertions(+), 71 deletions(-)
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 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 | 174 +++++++++++++-----
6 files changed, 148 insertions(+), 71 deletions(-)
--
2.53.0
On Thu, 26 Mar 2026 11:26:50 +0800 Li Wang <liwang@redhat.com> wrote: > 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. Thanks. AI review flagged a few potential issues. https://sashiko.dev/#/patchset/20260326032658.96819-1-liwang%40redhat.com Please take a look - I'm interested in learning how may of these you feel are worth addressing. The sysconf retval one is real, pretty minor. I'd be inclined to ignore the unchecked-malloc-return one. It's userspace, it's selftests. If a malloc() fails then gee, fix your machine and run it again. Plese understand that I'm serious trying to slow things down now (https://lkml.kernel.org/r/20260323202941.08ddf2b0411501cae801ab4c@linux-foundation.org). Maybe we can weasel out of that for selftests but I'd rather not. That means post-7.1-r1 for this patchset, so please plan to resend at that time. If memcg maintainers decide that this material should target the upcoming merge window then OK,
On Thu, Mar 26, 2026 at 11:26:50AM +0800, Li Wang wrote: > 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 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). Hi Andrew, All, I see that Sashiko still points out minor issues in this patchset, That seems very tiny in selftest programming. I can correct all that in a new version if you'd like a perfect patchset. Sashiko comments: https://sashiko.dev/#/patchset/20260326032658.96819-1-liwang%40redhat.com -- Regards, Li Wang
On Thu, 26 Mar 2026 14:29:20 +0800 Li Wang <liwang@redhat.com> wrote: > > Test all passed on: > > x86_64(4k), aarch64(4K, 64K), ppc64le(64K). > > Hi Andrew, All, > > I see that Sashiko still points out minor issues in this patchset, > That seems very tiny in selftest programming. > > I can correct all that in a new version if you'd like a perfect patchset. > > Sashiko comments: > https://sashiko.dev/#/patchset/20260326032658.96819-1-liwang%40redhat.com Ah, OK, you already looked. If you say they're too minor then I'm OK with that. If there are any you feel you'd like to address then go for it. That's my opinion, others might differ! I suggest you leave things as-is for a while (a week?), give the memcg maintainers time to take a look (please). Thanks.
On Thu, Mar 26, 2026 at 4:06 PM Andrew Morton <akpm@linux-foundation.org> wrote: > > On Thu, 26 Mar 2026 14:29:20 +0800 Li Wang <liwang@redhat.com> wrote: > > > > Test all passed on: > > > x86_64(4k), aarch64(4K, 64K), ppc64le(64K). > > > > Hi Andrew, All, > > > > I see that Sashiko still points out minor issues in this patchset, > > That seems very tiny in selftest programming. > > > > I can correct all that in a new version if you'd like a perfect patchset. > > > > Sashiko comments: > > https://sashiko.dev/#/patchset/20260326032658.96819-1-liwang%40redhat.com > > Ah, OK, you already looked. > > If you say they're too minor then I'm OK with that. If there are any > you feel you'd like to address then go for it. That's my opinion, > others might differ! > > I suggest you leave things as-is for a while (a week?), give the memcg > maintainers time to take a look (please). I think some of the comments are worth addressing, especially: Patch 4: Using BUF_SIZE in the allocation helpers is wrong, we should use the actual page size. Patch 6: Zero initialization of zw_allocation. But yeah as Andrew said, it may be worth waiting for memcg maintainers to take a look before sending a new version.
On Thu, Mar 26, 2026 at 04:10:42PM -0700, Yosry Ahmed wrote: > On Thu, Mar 26, 2026 at 4:06 PM Andrew Morton <akpm@linux-foundation.org> wrote: > > > > On Thu, 26 Mar 2026 14:29:20 +0800 Li Wang <liwang@redhat.com> wrote: > > > > > > Test all passed on: > > > > x86_64(4k), aarch64(4K, 64K), ppc64le(64K). > > > > > > Hi Andrew, All, > > > > > > I see that Sashiko still points out minor issues in this patchset, > > > That seems very tiny in selftest programming. > > > > > > I can correct all that in a new version if you'd like a perfect patchset. > > > > > > Sashiko comments: > > > https://sashiko.dev/#/patchset/20260326032658.96819-1-liwang%40redhat.com > > > > Ah, OK, you already looked. > > > > If you say they're too minor then I'm OK with that. If there are any > > you feel you'd like to address then go for it. That's my opinion, > > others might differ! > > > > I suggest you leave things as-is for a while (a week?), give the memcg > > maintainers time to take a look (please). Sounds reasonable! > I think some of the comments are worth addressing, especially: +1 > Patch 4: > Using BUF_SIZE in the allocation helpers is wrong, we should use the > actual page size. > > Patch 6: > Zero initialization of zw_allocation. Thanks, and plus: Patch 7: Adjust the code comments. Patch 8: Declear long type for elapsed and count variables > But yeah as Andrew said, it may be worth waiting for memcg maintainers > to take a look before sending a new version. Sure, I will allow a week for others to review it. -- Regards, Li Wang
© 2016 - 2026 Red Hat, Inc.