Linux-mm Archive on lore.kernel.org
 help / color / mirror / Atom feed
* cgroup/test_zswap failed with "zswpout does not increase after test program"
@ 2026-07-07  9:38 Zenghui Yu
  2026-07-07 12:01 ` Michal Koutný
  2026-07-07 18:25 ` Yosry Ahmed
  0 siblings, 2 replies; 8+ messages in thread
From: Zenghui Yu @ 2026-07-07  9:38 UTC (permalink / raw)
  To: linux-mm, cgroups, linux-kselftest, linux-kernel
  Cc: hannes, yosry, nphamcs, chengming.zhou, tj, mkoutny, Shuah Khan,
	mhocko, Roman Gushchin, Shakeel Butt, Muchun Song, Andrew Morton

Hi,

Running cgroup/test_zswap on my arm64 box failed immediately with:

  [root@localhost cgroup]# ./test_zswap 
  TAP version 13
  1..8
  # zswpout does not increase after test program
  not ok 1 test_zswap_usage
  [...]

I'm sure that pages are successfully written into zswap by checking the
count_memcg_events(.., idx=ZSWPOUT, ..) trace events. But "zswpout_after"
in test_zswap_usage() is 0 and results in this failure.

I guess the problem is that (in this particular case) the memcg stats has
not been flushed when userspace reads it.

 memcg_stat_format()
   mem_cgroup_flush_stats()
     __mem_cgroup_flush_stats(.., force=false)
       needs_flush = memcg_vmstats_needs_flush();

 static bool memcg_vmstats_needs_flush(struct memcg_vmstats *vmstats)
 {
 	return atomic_long_read(&vmstats->stats_updates) >
 		MEMCG_CHARGE_BATCH * num_online_cpus();
 }

I can image that memcg_vmstats_needs_flush() will return false because I'm
testing a 16k-page-size kernel on a box with 96 cpus..

As we have a periodic flusher flushed all the stats every 2 seconds, I use
the following diff to wait the flusher to expose the accurate stats to
userspace.

diff --git a/tools/testing/selftests/cgroup/lib/cgroup_util.c b/tools/testing/selftests/cgroup/lib/cgroup_util.c
index 3ce134509041..9596f294da0b 100644
--- a/tools/testing/selftests/cgroup/lib/cgroup_util.c
+++ b/tools/testing/selftests/cgroup/lib/cgroup_util.c
@@ -95,6 +95,8 @@ int cg_read(const char *cgroup, const char *control, char *buf, size_t len)
 
 	snprintf(path, sizeof(path), "%s/%s", cgroup, control);
 
+	sleep(2);
+
 	ret = read_text(path, buf, len);
 	return ret >= 0 ? 0 : ret;
 }

I have no idea how to "fix" it properly. Please have a look!

Thanks,
Zenghui


^ permalink raw reply related	[flat|nested] 8+ messages in thread

end of thread, other threads:[~2026-07-07 21:50 UTC | newest]

Thread overview: 8+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-07-07  9:38 cgroup/test_zswap failed with "zswpout does not increase after test program" Zenghui Yu
2026-07-07 12:01 ` Michal Koutný
2026-07-07 12:14   ` Zenghui Yu
2026-07-07 18:25 ` Yosry Ahmed
2026-07-07 21:35   ` Nhat Pham
2026-07-07 21:36     ` Yosry Ahmed
2026-07-07 21:46       ` Nhat Pham
2026-07-07 21:49         ` Yosry Ahmed

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox