selftests: cgroup: add tests to verify the zswap writeback path
authorUsama Arif <usamaarif642@gmail.com>
Wed, 8 May 2024 17:13:59 +0000 (18:13 +0100)
committerAndrew Morton <akpm@linux-foundation.org>
Sat, 11 May 2024 22:41:36 +0000 (15:41 -0700)
commit158863e5d7cc6c9ee7e6c998ef84625caa2e88b3
tree3e0a35d59573e9e53fa930e6b2051ecf4478eaee
parenta8248bb72fed5888bc3a0c7a4c97eb358906d7ea
selftests: cgroup: add tests to verify the zswap writeback path

Attempt writeback with the below steps and check using memory.stat.zswpwb
if zswap writeback occurred:

1. Allocate memory.
2. Reclaim memory equal to the amount that was allocated in step 1.
   This will move it into zswap.
3. Save current zswap usage.
4. Move the memory allocated in step 1 back in from zswap.
5. Set zswap.max to half the amount that was recorded in step 3.
6. Attempt to reclaim memory equal to the amount that was allocated,
   this will either trigger writeback if it's enabled, or reclamation
   will fail if writeback is disabled as there isn't enough zswap
   space.

Link: https://lkml.kernel.org/r/20240508171359.1545744-1-usamaarif642@gmail.com
Signed-off-by: Usama Arif <usamaarif642@gmail.com>
Suggested-by: Nhat Pham <nphamcs@gmail.com>
Acked-by: Yosry Ahmed <yosryahmed@google.com>
Acked-by: Nhat Pham <nphamcs@gmail.com>
Cc: Chengming Zhou <chengming.zhou@linux.dev>
Cc: Johannes Weiner <hannes@cmpxchg.org>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
tools/testing/selftests/cgroup/test_zswap.c