Skip to content

Commit

Permalink
selftests: cgroup: fix test_kmem_basic false positives
Browse files Browse the repository at this point in the history
This test fails routinely in our prod testing environment, and I can
reproduce it locally as well.

The test allocates dcache inside a cgroup, then drops the memory limit
and checks that usage drops correspondingly. The reason it fails is
because dentries are freed with an RCU delay - a debugging sleep shows
that usage drops as expected shortly after.

Insert a 1s sleep after dropping the limit. This should be good
enough, assuming that machines running those tests are otherwise not
very busy.

Link: https://lkml.kernel.org/r/20230801135632.1768830-1-hannes@cmpxchg.org
Signed-off-by: Johannes Weiner <hannes@cmpxchg.org>
Acked-by: Paul E. McKenney <paulmck@kernel.org>
Cc: Michal Hocko <mhocko@suse.com>
Cc: Roman Gushchin <roman.gushchin@linux.dev>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
  • Loading branch information
Johannes Weiner authored and Andrew Morton committed Aug 4, 2023
1 parent 1745778 commit fac2650
Showing 1 changed file with 4 additions and 0 deletions.
4 changes: 4 additions & 0 deletions tools/testing/selftests/cgroup/test_kmem.c
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,10 @@ static int test_kmem_basic(const char *root)
goto cleanup;

cg_write(cg, "memory.high", "1M");

/* wait for RCU freeing */
sleep(1);

slab1 = cg_read_key_long(cg, "memory.stat", "slab ");
if (slab1 <= 0)
goto cleanup;
Expand Down

0 comments on commit fac2650

Please sign in to comment.