linux/tools/testing/selftests/cgroup
Jiayuan Chen 4e89004eeb selftests/cgroup: add test for zswap incompressible pages
Add test_zswap_incompressible() to verify that the zswap_incomp memcg stat
correctly tracks incompressible pages.

The test allocates memory filled with random data from /dev/urandom, which
cannot be effectively compressed by zswap.  When this data is swapped out
to zswap, it should be stored as-is and tracked by the zswap_incomp
counter.

The test verifies that:
1. Pages are swapped out to zswap (zswpout increases)
2. Incompressible pages are tracked (zswap_incomp increases)

test:
dd if=/dev/zero of=/swapfile bs=1M count=2048
chmod 600 /swapfile
mkswap /swapfile
swapon /swapfile
echo Y > /sys/module/zswap/parameters/enabled

./test_zswap
 TAP version 13
 1..8
 ok 1 test_zswap_usage
 ok 2 test_swapin_nozswap
 ok 3 test_zswapin
 ok 4 test_zswap_writeback_enabled
 ok 5 test_zswap_writeback_disabled
 ok 6 test_no_kmem_bypass
 ok 7 test_no_invasive_cgroup_shrink
 ok 8 test_zswap_incompressible
 Totals: pass:8 fail:0 xfail:0 xpass:0 skip:0 error:0

Link: https://lkml.kernel.org/r/20260213071827.5688-3-jiayuan.chen@linux.dev
Signed-off-by: Jiayuan Chen <jiayuan.chen@shopee.com>
Acked-by: Shakeel Butt <shakeel.butt@linux.dev>
Acked-by: Nhat Pham <nphamcs@gmail.com>
Reviewed-by: SeongJae Park <sj@kernel.org>
Cc: Chengming Zhou <chengming.zhou@linux.dev>
Cc: Johannes Weiner <hannes@cmpxchg.org>
Cc: Jonathan Corbet <corbet@lwn.net>
Cc: Michal Hocko <mhocko@kernel.org>
Cc: Michal Koutný <mkoutny@suse.com>
Cc: Muchun Song <muchun.song@linux.dev>
Cc: Roman Gushchin <roman.gushchin@linux.dev>
Cc: Shuah Khan <shuah@kernel.org>
Cc: Tejun Heo <tj@kernel.org>
Cc: Yosry Ahmed <yosry.ahmed@linux.dev>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
History 2026-04-05 13:53:00 -07:00
..
lib selftests: cgroup: Add cg_read_key_long_poll() to poll a cgroup key with retries 2025-12-08 08:44:54 -10:00
.gitignore selftests: cgroup: Add basic tests for pids controller 2024-05-26 08:45:10 -10:00
config mm: remove CONFIG_MEMCG_KMEM 2024-07-10 12:14:54 -07:00
Makefile cgroup: selftests: Move cgroup_util into its own library 2025-05-16 11:45:15 -07:00
memcg_protection.m selftests: memcg: adjust expected reclaim values of protected cgroups 2022-05-27 09:33:45 -07:00
test_core.c Significant patch series in this pull request: 2025-12-06 14:01:20 -08:00
test_cpu.c Significant patch series in this pull request: 2025-12-06 14:01:20 -08:00
test_cpuset.c Significant patch series in this pull request: 2025-12-06 14:01:20 -08:00
test_cpuset_prs.sh cgroup/cpuset: Defer housekeeping_update() calls from CPU hotplug to workqueue 2026-02-23 10:42:11 -10:00
test_cpuset_v1_base.sh cgroup/cpuset: add sefltest for cpuset v1 2024-08-30 10:00:17 -10:00
test_cpuset_v1_hp.sh selftests/cgroup: use bash in test_cpuset_v1_hp.sh 2025-02-04 09:36:54 -10:00
test_freezer.c Significant patch series in this pull request: 2025-12-06 14:01:20 -08:00
test_hugetlb_memcg.c selftests: complete kselftest include centralization 2025-11-27 14:24:31 -08:00
test_kill.c Significant patch series in this pull request: 2025-12-06 14:01:20 -08:00
test_kmem.c selftests: cgroup: Replace sleep with cg_read_key_long_poll() for waiting on nr_dying_descendants 2025-12-08 08:44:54 -10:00
test_memcontrol.c selftests: cgroup: make test_memcg_sock robust against delayed sock stats 2025-12-08 08:44:54 -10:00
test_pids.c selftests: complete kselftest include centralization 2025-11-27 14:24:31 -08:00
test_stress.sh kseltest/cgroup: Make test_stress.sh work if run interactively 2022-05-13 09:33:21 -10:00
test_zswap.c selftests/cgroup: add test for zswap incompressible pages 2026-04-05 13:53:00 -07:00
wait_inotify.c kselftest/cgroup: Add cpuset v2 partition root state test 2022-09-04 10:47:28 -10:00
with_stress.sh selftests: cgroup: Run test_core under interfering stress 2019-10-07 07:11:54 -07:00