Skip to content

Commit 8303168

Browse files
Byte-Labakpm00
authored andcommitted
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/[email protected] Signed-off-by: David Vernet <[email protected]> Acked-by: Roman Gushchin <[email protected]> Cc: Johannes Weiner <[email protected]> Cc: Michal Hocko <[email protected]> Cc: Shakeel Butt <[email protected]> Cc: Tejun Heo <[email protected]> Signed-off-by: Andrew Morton <[email protected]>
1 parent 72b1e03 commit 8303168

File tree

1 file changed

+0
-3
lines changed

1 file changed

+0
-3
lines changed

tools/testing/selftests/cgroup/test_memcontrol.c

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1102,9 +1102,6 @@ static int tcp_client(const char *cgroup, unsigned short port)
11021102
if (current < 0 || sock < 0)
11031103
goto close_sk;
11041104

1105-
if (current < sock)
1106-
goto close_sk;
1107-
11081105
if (values_close(current, sock, 10)) {
11091106
ret = KSFT_PASS;
11101107
break;

0 commit comments

Comments
 (0)