summaryrefslogtreecommitdiff
path: root/tools/testing/selftests/cgroup/test_memcontrol.c
diff options
context:
space:
mode:
authorDavid Vernet <void@manifault.com>2022-05-13 06:22:57 +0300
committerAndrew Morton <akpm@linux-foundation.org>2022-05-13 17:20:12 +0300
commit830316807e0275146cbd5d2ae66fd338d0dfd09e (patch)
tree98907fefd7b12fcb40517747ccadd74130da2b61 /tools/testing/selftests/cgroup/test_memcontrol.c
parent72b1e03aa7255094d15752952a7e56c5f39b6e37 (diff)
downloadlinux-830316807e0275146cbd5d2ae66fd338d0dfd09e.tar.xz
cgroup: remove racy check in test_memcg_sock()
test_memcg_sock() in the cgroup memcg tests, verifies expected memory accounting for sockets. The test forks a process which functions as a TCP server, and sends large buffers back and forth between itself (as the TCP client) and the forked TCP server. While doing so, it verifies that memory.current and memory.stat.sock look correct. There is currently a check in tcp_client() which asserts memory.current >= memory.stat.sock. This check is racy, as between memory.current and memory.stat.sock being queried, a packet could come in which causes mem_cgroup_charge_skmem() to be invoked. This could cause memory.stat.sock to exceed memory.current. Reversing the order of querying doesn't address the problem either, as memory may be reclaimed between the two calls. Instead, this patch just removes that assertion altogether, and instead relies on the values_close() check that follows to validate the expected accounting. Link: https://lkml.kernel.org/r/20220423155619.3669555-5-void@manifault.com Signed-off-by: David Vernet <void@manifault.com> Acked-by: Roman Gushchin <roman.gushchin@linux.dev> Cc: Johannes Weiner <hannes@cmpxchg.org> Cc: Michal Hocko <mhocko@kernel.org> Cc: Shakeel Butt <shakeelb@google.com> Cc: Tejun Heo <tj@kernel.org> Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Diffstat (limited to 'tools/testing/selftests/cgroup/test_memcontrol.c')
-rw-r--r--tools/testing/selftests/cgroup/test_memcontrol.c3
1 files changed, 0 insertions, 3 deletions
diff --git a/tools/testing/selftests/cgroup/test_memcontrol.c b/tools/testing/selftests/cgroup/test_memcontrol.c
index 31d5c3f9b2b2..6d3aace6be53 100644
--- a/tools/testing/selftests/cgroup/test_memcontrol.c
+++ b/tools/testing/selftests/cgroup/test_memcontrol.c
@@ -1102,9 +1102,6 @@ static int tcp_client(const char *cgroup, unsigned short port)
if (current < 0 || sock < 0)
goto close_sk;
- if (current < sock)
- goto close_sk;
-
if (values_close(current, sock, 10)) {
ret = KSFT_PASS;
break;