From 216a983640bce942e25c62e9d2f901dfba888cca Mon Sep 17 00:00:00 2001 From: Konstantin Khorenko Date: Mon, 12 Oct 2026 20:59:05 +0200 Subject: [PATCH] selftests: cgroup: skip test_memcg_sock under cgroup.memory=nosocket With cgroup.memory=nosocket the memory controller does not charge socket memory, so the "sock " entry of memory.stat stays 0 and memory.current moves only by the kernel objects accept() allocates. tcp_client() then passes on 0 == 0 without having checked any accounting, or fails if those objects took a fresh charge batch. Look for nosocket among the cgroup.memory= options on the kernel command line and skip the test there. Assisted-by: LLM Signed-off-by: Konstantin Khorenko Signed-off-by: Tejun Heo --- .../selftests/cgroup/test_memcontrol.c | 21 +++++++++++++++++++ 1 file changed, 21 insertions(+) diff --git a/tools/testing/selftests/cgroup/test_memcontrol.c b/tools/testing/selftests/cgroup/test_memcontrol.c index 7bcf772bcea2..a88241d14b7d 100644 --- a/tools/testing/selftests/cgroup/test_memcontrol.c +++ b/tools/testing/selftests/cgroup/test_memcontrol.c @@ -1379,6 +1379,24 @@ free_ainfo: return ret; } +static bool memcg_sockets_disabled(void) +{ + char buf[4 * BUF_SIZE], *opt; + + if (read_text("/proc/cmdline", buf, sizeof(buf)) <= 0) + return false; + + for (opt = strstr(buf, "cgroup.memory="); opt; + opt = strstr(opt + 1, "cgroup.memory=")) { + char *end = strchrnul(opt, ' '); + char *ns = strstr(opt, "nosocket"); + + if (ns && ns < end) + return true; + } + return false; +} + /* * This test checks socket memory accounting. * The test forks a TCP server listens on a random port between 1000 @@ -1394,6 +1412,9 @@ static int test_memcg_sock(const char *root) char *memcg; long sock_post = -1; + if (memcg_sockets_disabled()) + return KSFT_SKIP; + memcg = cg_name(root, "memcg_test"); if (!memcg) goto cleanup; -- knotmirror 0.0.1