On Tue, Aug 04, 2026 at 04:20:45AM +0000, Wilson Felipe Pereira wrote: > In test_no_kmem_bypass(), delta (stored_pages * page_size - zswapped) is > checked against stored_pages * page_size / 4 to verify that the pages > pushed to zswap belong to the test memory cgroup. > > Due to slight stat update timing differences, delta can evaluate to a small > negative number (e.g. -5MB out of 1GB). Because delta is declared as a > signed int and stored_pages is an unsigned size_t, C's usual arithmetic > conversions implicitly promote a negative delta to a large unsigned 64-bit > integer, causing `delta < stored_pages * page_size / 4` to falsely evaluate > to 0 and fail the test. Thanks for the breakdown. > Fix this by checking abs(delta), ensuring the test correctly compares the > absolute difference between system zswap and cgroup zswapped bytes. I still think the delta quantity has some meaning here and taking the abs() changes the semantics of the checked inequality. What about making both zswapped and delta `long`s? (Under similar reasoning, there's already a possible loss after squashing cg_read_key_long() result into the `int`.) In any way, also Fixes: a549f9f31561a ("selftests: cgroup: add test_zswap with no kmem bypass test") Thanks, Michal