summaryrefslogtreecommitdiff
path: root/tools/testing
diff options
context:
space:
mode:
authorWilson Felipe Pereira <wfelipe@google.com>2026-08-28 03:37:31 +0000
committerAndrew Morton <akpm@linux-foundation.org>2026-10-06 17:38:58 -0700
commit5547ee3a76b2ec0c7f1a53547d83c4e5cc3bdbd4 (patch)
tree2989098d6115819bb18f0831156fb92b9567b3bb /tools/testing
parent4dffce1cc5abea2d8d37472557b8f941caa1d44f (diff)
downloadlinux-next-5547ee3a76b2ec0c7f1a53547d83c4e5cc3bdbd4.tar.gz
linux-next-5547ee3a76b2ec0c7f1a53547d83c4e5cc3bdbd4.zip
selftests/cgroup: test_zswap: wait for cgroup to unpopulate in test_zswap_writeback
Patch series "selftests/cgroup: fixes for test_zswap on single core VM", v4. This series fixes two test failures in test_zswap observed when running on a single-core VM (-smp 1) with 4GB of RAM. Patch 1 addresses a race condition in test_zswap_writeback() where waitpid() returns before the exiting child process is switched away by the kernel, causing an immediate write of "+memory" to cgroup.subtree_control to fail with -EBUSY. We fix this by waiting for cgroup.events to report "populated 0". Patch 2 fixes an implicit unsigned conversion bug in test_no_kmem_bypass() where small negative timing differences between debugfs stored_pages and cgroup zswapped bytes caused the comparison to falsely fail due to unsigned promotion. This patch (of 2): When running test_zswap on a single-core VM (-smp 1) with 4GB of RAM, test_zswap_writeback intermittently fails on the initial run after boot. In test_zswap_writeback(), after waitpid() reaps the child process created by test_zswap_writeback_one(), writing "+memory" to cgroup.subtree_control can fail with -EBUSY. Under cgroup v2, enabling domain subtree controllers is forbidden while any tasks remain in cgroup.procs. When a child process exits, exit_notify() wakes the parent process, allowing waitpid() to return immediately. However, the cgroup populated task count (nr_populated_csets) is only decremented when the exiting task is switched away via finish_task_switch() -> cgroup_task_dead(). On single-core systems, the parent runs before the dead child has been switched out, causing "+memory" to fail with -EBUSY if written immediately after waitpid() returns. Fix this by waiting for cgroup.events to report "populated 0\n" via cg_read_strcmp_wait() before enabling subtree control. Link: https://lore.kernel.org/20260828033741.2184560-1-wfelipe@google.com Link: https://lore.kernel.org/20260828033741.2184560-2-wfelipe@google.com Signed-off-by: Wilson Felipe Pereira <wfelipe@google.com> Signed-off-by: Andrew Morton <akpm@linux-foundation.org> Acked-by: Michal Koutný <mkoutny@suse.com> Cc: Chengming Zhou <chengming.zhou@linux.dev> Cc: Johannes Weiner <hannes@cmpxchg.org> Cc: Nhat Pham <nphamcs@gmail.com> Cc: Shuah Khan <shuah@kernel.org> Cc: Tejun Heo <tj@kernel.org>
Diffstat (limited to 'tools/testing')
-rw-r--r--tools/testing/selftests/cgroup/test_zswap.c2
1 files changed, 2 insertions, 0 deletions
diff --git a/tools/testing/selftests/cgroup/test_zswap.c b/tools/testing/selftests/cgroup/test_zswap.c
index 8df54b59513a..b1abc94317e4 100644
--- a/tools/testing/selftests/cgroup/test_zswap.c
+++ b/tools/testing/selftests/cgroup/test_zswap.c
@@ -409,6 +409,8 @@ static int test_zswap_writeback(const char *root, bool wb)
* Thus, the parent's setting shall be what's in effect. */
if (cg_write(test_group, "memory.zswap.max", "max"))
goto out;
+ if (cg_read_strcmp_wait(test_group, "cgroup.events", "populated 0\n"))
+ goto out;
if (cg_write(test_group, "cgroup.subtree_control", "+memory"))
goto out;