Skip to content

Commit

Permalink
selftests: cgroup: fix unexpected failure on test_memcg_low
Browse files Browse the repository at this point in the history
Since commit f079a02 ("selftests: memcg: factor out common parts of
memory.{low,min} tests"), the value used in second alloc_anon has changed
from 148M to 170M.  Because memory.low allows reclaiming page cache in
child cgroups, so the memory.current is close to 30M instead of 50M. 
Therefore, adjust the expected value of parent cgroup.

Link: https://lkml.kernel.org/r/20230522095233.4246-2-haifeng.xu@shopee.com
Fixes: f079a02 ("selftests: memcg: factor out common parts of memory.{low,min} tests")
Signed-off-by: Haifeng Xu <haifeng.xu@shopee.com>
Cc: Johannes Weiner <hannes@cmpxchg.org>
Cc: Michal Hocko <mhocko@kernel.org>
Cc: Roman Gushchin <roman.gushchin@linux.dev>
Cc: Shakeel Butt <shakeelb@google.com>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
  • Loading branch information
Haifeng Xu authored and Andrew Morton committed Jun 9, 2023
1 parent 08e0f49 commit 19ab365
Showing 1 changed file with 3 additions and 1 deletion.
4 changes: 3 additions & 1 deletion tools/testing/selftests/cgroup/test_memcontrol.c
Original file line number Diff line number Diff line change
Expand Up @@ -292,6 +292,7 @@ static int test_memcg_protection(const char *root, bool min)
char *children[4] = {NULL};
const char *attribute = min ? "memory.min" : "memory.low";
long c[4];
long current;
int i, attempts;
int fd;

Expand Down Expand Up @@ -400,7 +401,8 @@ static int test_memcg_protection(const char *root, bool min)
goto cleanup;
}

if (!values_close(cg_read_long(parent[1], "memory.current"), MB(50), 3))
current = min ? MB(50) : MB(30);
if (!values_close(cg_read_long(parent[1], "memory.current"), current, 3))
goto cleanup;

if (!reclaim_until(children[0], MB(10)))
Expand Down

0 comments on commit 19ab365

Please sign in to comment.