On Fri, Apr 24, 2026 at 12:00:57PM +0800, Li Wang <[email protected]> wrote: > test_no_invasive_cgroup_shrink sets up two cgroups: wb_group, which is > expected to trigger zswap writeback, and a control group (renamed to > zw_group),
Aha, it should stand for zswap writeback? Then zwb_group to avoid (my) confusion with zsw_group :-) Although the original names were already well descriptive (both groups are expected to have some zswap). > which should only have pages sitting in zswap without any > writeback. > > There are two problems with the current test: > > 1) The data patterns are reversed. wb_group uses allocate_bytes(), which > writes only a single byte per page — trivially compressible, > especially by zstd — so compressed pages fit within zswap.max and > writeback is never triggered. Meanwhile, the control group uses > getrandom() to produce hard-to-compress data, but it is the group > that does *not* need writeback. > > 2) The test uses fixed sizes (10K zswap.max, 10MB allocation) that are > too small on systems with large PAGE_SIZE (e.g. 64K), failing to > build enough memory pressure to trigger writeback reliably. > > Fix both issues by: > - Swapping the data patterns: fill wb_group pages with partially > random data (getrandom for page_size/4 bytes) to resist compression > and trigger writeback, and fill zw_group pages with simple repeated > data to stay compressed in zswap. I'd have expected that having both equal (i.e. both random to fill up more easily) is what tests the effect zswap.max upon writeback most precisely. > - Making all size parameters PAGE_SIZE-aware: set allocation size to > PAGE_SIZE * 1024, memory.zswap.max to PAGE_SIZE, and memory.max to > allocation_size / 2 for both cgroups. Makes sense. > - Allocating memory inline instead of via cg_run() so the pages > remain resident throughout the test. What is the residency good for? (It doesn't matter AFAICS, so the change seems gratuitous and code diverges from test_zswap_usage().)
signature.asc
Description: PGP signature

