OpenVZ / Virtuozzo kernel development (devel@openvz.org)
 help / color / mirror / Atom feed
From: Konstantin Khorenko <khorenko@virtuozzo.com>
To: devel@openvz.org, Konstantin Khorenko <khorenko@virtuozzo.com>
Subject: [Devel] [PATCH hci-8.1 1/2] ms/selftests: cgroup: skip test_memcg_sock under cgroup.memory=nosocket
Date: Mon, 19 Oct 2026 21:47:33 +0200	[thread overview]
Message-ID: <20261019-b4-prep-khorenko-vstor-149854-selftests-test_memcg_sock-v1-1-efbfa45dc967@virtuozzo.com> (raw)
In-Reply-To: <20261019-b4-prep-khorenko-vstor-149854-selftests-test_memcg_sock-v1-0-efbfa45dc967@virtuozzo.com>

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 <khorenko@virtuozzo.com>
Signed-off-by: Tejun Heo <tj@kernel.org>
(cherry picked from commit 216a983640bce942e25c62e9d2f901dfba888cca)

Conflict: cgroup_util.h here still calls the buffer size PAGE_SIZE, the
rename to BUF_SIZE in 6e9f5c2eecd1 ("selftests/cgroup: rename PAGE_SIZE
to BUF_SIZE in cgroup_util") is not in the tree, so
memcg_sockets_disabled() sizes its buffer with PAGE_SIZE. The value is
the same.

https://virtuozzo.atlassian.net/browse/VSTOR-149854

Feature: fix selftests
Signed-off-by: Konstantin Khorenko <khorenko@virtuozzo.com>
---
 tools/testing/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 7519aeff4dbd1..003c865d8db93 100644
--- a/tools/testing/selftests/cgroup/test_memcontrol.c
+++ b/tools/testing/selftests/cgroup/test_memcontrol.c
@@ -1356,6 +1356,24 @@ static int tcp_client(const char *cgroup, unsigned short port)
 	return ret;
 }
 
+static bool memcg_sockets_disabled(void)
+{
+	char buf[4 * PAGE_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
@@ -1370,6 +1388,9 @@ static int test_memcg_sock(const char *root)
 	unsigned short port;
 	char *memcg;
 
+	if (memcg_sockets_disabled())
+		return KSFT_SKIP;
+
 	memcg = cg_name(root, "memcg_test");
 	if (!memcg)
 		goto cleanup;

-- 
2.43.0

_______________________________________________
Devel mailing list
Devel@openvz.org
https://lists.openvz.org/mailman/listinfo/devel

  reply	other threads:[~2026-10-19 19:48 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-10-19 19:47 [Devel] [PATCH hci-8.1 0/2] selftests: cgroup: fix the flaky and vacuous test_memcg_sock Konstantin Khorenko
2026-10-19 19:47 ` Konstantin Khorenko [this message]
2026-10-19 19:50   ` [Devel] [PATCH hci-8.1 1/2] ms/selftests: cgroup: skip test_memcg_sock under cgroup.memory=nosocket no-reply
2026-10-19 19:47 ` [Devel] [PATCH hci-8.1 2/2] ms/selftests: cgroup: make test_memcg_sock check flushed sock stats Konstantin Khorenko
2026-10-19 19:50   ` no-reply
2026-10-19 19:59 ` [Devel] [PATCH hci-8.1 0/2] selftests: cgroup: fix the flaky and vacuous test_memcg_sock Konstantin Khorenko

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20261019-b4-prep-khorenko-vstor-149854-selftests-test_memcg_sock-v1-1-efbfa45dc967@virtuozzo.com \
    --to=khorenko@virtuozzo.com \
    --cc=devel@openvz.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox