* [PATCH] selftests/cgroup: test_zswap: skip test_no_kmem_bypass if debugfs is unavailable
@ 2026-08-01 4:12 Wilson Felipe Pereira
2026-08-03 5:34 ` Anshuman Khandual
0 siblings, 1 reply; 2+ messages in thread
From: Wilson Felipe Pereira @ 2026-08-01 4:12 UTC (permalink / raw)
To: Johannes Weiner, Yosry Ahmed, Nhat Pham, Andrew Morton,
Shuah Khan
Cc: Tejun Heo, Michal Koutný, Chengming Zhou, linux-mm, cgroups,
linux-kselftest, Wilson Felipe Pereira
test_no_kmem_bypass() needs to read
/sys/kernel/debug/zswap/stored_pages via get_zswap_stored_pages() to
verify that compressed pages are charged to the memcg.
When running in an environment where debugfs is not mounted or
CONFIG_DEBUG_FS is disabled, get_zswap_stored_pages() fails, causing the
loop to terminate early and report a false negative (KSFT_FAIL).
Selftests should not fail when if debugfs is unavailable, and it
should print a message when it is skipped.
Signed-off-by: Wilson Felipe Pereira <wfelipe@google.com>
---
tools/testing/selftests/cgroup/test_zswap.c | 10 ++++++++--
1 file changed, 8 insertions(+), 2 deletions(-)
diff --git a/tools/testing/selftests/cgroup/test_zswap.c b/tools/testing/selftests/cgroup/test_zswap.c
index 49b36ee791606..c4f7b66f1b206 100644
--- a/tools/testing/selftests/cgroup/test_zswap.c
+++ b/tools/testing/selftests/cgroup/test_zswap.c
@@ -566,12 +566,19 @@ static int test_no_kmem_bypass(const char *root)
int child_status;
char *test_group = NULL;
pid_t child_pid;
+ size_t stored_pages;
/* Read sys info and compute test values accordingly */
if (sysinfo(&sys_info) != 0)
return KSFT_FAIL;
- if (sys_info.totalram > 5000000000)
+ if (sys_info.totalram > 5000000000) {
+ ksft_print_msg("requires less than 5000000000 total ram\n");
return KSFT_SKIP;
+ }
+ if (get_zswap_stored_pages(&stored_pages)) {
+ ksft_print_msg("debugfs at /sys/kernel/debug is required\n");
+ return KSFT_SKIP;
+ }
values = mmap(0, sizeof(struct no_kmem_bypass_child_args), PROT_READ |
PROT_WRITE, MAP_SHARED | MAP_ANONYMOUS, -1, 0);
if (values == MAP_FAILED)
@@ -604,7 +611,6 @@ static int test_no_kmem_bypass(const char *root)
/* Try to wakeup kswapd and let it push child memory to zswap */
set_min_free_kb(min_free_kb_high);
for (int i = 0; i < 20; i++) {
- size_t stored_pages;
char *trigger_allocation = malloc(trigger_allocation_size);
if (!trigger_allocation)
--
2.55.0.508.g3f0d502094-goog
^ permalink raw reply related [flat|nested] 2+ messages in thread* Re: [PATCH] selftests/cgroup: test_zswap: skip test_no_kmem_bypass if debugfs is unavailable
2026-08-01 4:12 [PATCH] selftests/cgroup: test_zswap: skip test_no_kmem_bypass if debugfs is unavailable Wilson Felipe Pereira
@ 2026-08-03 5:34 ` Anshuman Khandual
0 siblings, 0 replies; 2+ messages in thread
From: Anshuman Khandual @ 2026-08-03 5:34 UTC (permalink / raw)
To: Wilson Felipe Pereira
Cc: Johannes Weiner, Yosry Ahmed, Nhat Pham, Andrew Morton,
Shuah Khan, Tejun Heo, Michal Koutný, Chengming Zhou,
linux-mm, cgroups, linux-kselftest
On Sat, Aug 01, 2026 at 04:12:46AM +0000, Wilson Felipe Pereira wrote:
> test_no_kmem_bypass() needs to read
> /sys/kernel/debug/zswap/stored_pages via get_zswap_stored_pages() to
> verify that compressed pages are charged to the memcg.
>
> When running in an environment where debugfs is not mounted or
> CONFIG_DEBUG_FS is disabled, get_zswap_stored_pages() fails, causing the
> loop to terminate early and report a false negative (KSFT_FAIL).
>
> Selftests should not fail when if debugfs is unavailable, and it
> should print a message when it is skipped.
Agreed.
>
> Signed-off-by: Wilson Felipe Pereira <wfelipe@google.com>
> ---
> tools/testing/selftests/cgroup/test_zswap.c | 10 ++++++++--
> 1 file changed, 8 insertions(+), 2 deletions(-)
>
> diff --git a/tools/testing/selftests/cgroup/test_zswap.c b/tools/testing/selftests/cgroup/test_zswap.c
> index 49b36ee791606..c4f7b66f1b206 100644
> --- a/tools/testing/selftests/cgroup/test_zswap.c
> +++ b/tools/testing/selftests/cgroup/test_zswap.c
> @@ -566,12 +566,19 @@ static int test_no_kmem_bypass(const char *root)
> int child_status;
> char *test_group = NULL;
> pid_t child_pid;
> + size_t stored_pages;
>
> /* Read sys info and compute test values accordingly */
> if (sysinfo(&sys_info) != 0)
> return KSFT_FAIL;
> - if (sys_info.totalram > 5000000000)
> + if (sys_info.totalram > 5000000000) {
> + ksft_print_msg("requires less than 5000000000 total ram\n");
Agreed - should not silently just skip the test.
> return KSFT_SKIP;
> + }
> + if (get_zswap_stored_pages(&stored_pages)) {
> + ksft_print_msg("debugfs at /sys/kernel/debug is required\n");
Could the error message here match that in gup_test.c for consistency
and probably later on these could be factored out in a macro constant
ksft_print_msg("mount debugfs at /sys/kernel/debug\n");
> + return KSFT_SKIP;
> + }
> values = mmap(0, sizeof(struct no_kmem_bypass_child_args), PROT_READ |
> PROT_WRITE, MAP_SHARED | MAP_ANONYMOUS, -1, 0);
> if (values == MAP_FAILED)
> @@ -604,7 +611,6 @@ static int test_no_kmem_bypass(const char *root)
> /* Try to wakeup kswapd and let it push child memory to zswap */
> set_min_free_kb(min_free_kb_high);
> for (int i = 0; i < 20; i++) {
> - size_t stored_pages;
> char *trigger_allocation = malloc(trigger_allocation_size);
>
> if (!trigger_allocation)
> --
> 2.55.0.508.g3f0d502094-goog
>
Otherwise LGTM.
Reviewed-by: Anshuman Khandual <anshuman.khandual@arm.com>
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2026-08-03 5:34 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-08-01 4:12 [PATCH] selftests/cgroup: test_zswap: skip test_no_kmem_bypass if debugfs is unavailable Wilson Felipe Pereira
2026-08-03 5:34 ` Anshuman Khandual
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.