From: Li Wang <liwang@redhat.com>
To: ltp@lists.linux.it
Subject: [LTP] [RFC PATCH] tst_cgroup: Avoid mixing mounts V1 and V2 simultaneously
Date: Fri, 28 Apr 2023 16:49:22 +0800 [thread overview]
Message-ID: <20230428084922.9834-1-liwang@redhat.com> (raw)
There is a tiny problem with the test logic of this tst_cgroup library,
that it potentially mixes Cgroup V1 and V2 together to be mounted at
the same time. The scenario happens once people just requests CTRL_BASE
(or a V2 controller not enabled) on a only V1-mounted system.
Cgroup community always objected to enabling Cgroup like that (V1&V2),
which may bring unexpected issues along the way.
So this patch cancels LTP mount V1&V2 simultaneously even if there is
no overlap in specific controller files.
Note:
This patch is a follow-up on GAO Wei's work about adding CTRL_BASE.
So we need to apply after that patchset.
Signed-off-by: Li Wang <liwang@redhat.com>
Cc: Richard Palethorpe <rpalethorpe@suse.de>
Cc: Wei Gao <wegao@suse.com>
---
lib/tst_cgroup.c | 9 +++++++--
1 file changed, 7 insertions(+), 2 deletions(-)
diff --git a/lib/tst_cgroup.c b/lib/tst_cgroup.c
index d08a31651..bceb10d1d 100644
--- a/lib/tst_cgroup.c
+++ b/lib/tst_cgroup.c
@@ -786,6 +786,10 @@ static void cgroup_copy_cpuset(const struct cgroup_root *const root)
* If we can't mount V2 or the controller is not on V2, then we try
* mounting it on its own V1 tree.
*
+ * The worth mentioning here is that once there detect V1 mounted,
+ * we skip mounting V2 because LTP doesn't allow V1 and V2 mixes to
+ * be tested in any scenario, and vice versa.
+ *
* Once we have mounted the controller somehow, we create a hierarchy
* of cgroups. If we are on V2 we first need to enable the controller
* for all children of root. Then we create hierarchy described in
@@ -828,13 +832,14 @@ void tst_cg_require(const char *const ctrl_name,
if (ctrl->ctrl_root)
goto mkdirs;
- if (!cgroup_v2_mounted() && options->needs_ver != TST_CG_V1)
+ if (!cgroup_v2_mounted() && options->needs_ver != TST_CG_V1
+ && !cgroup_v1_mounted())
cgroup_mount_v2();
if (ctrl->ctrl_root)
goto mkdirs;
- if (options->needs_ver != TST_CG_V2)
+ if (options->needs_ver != TST_CG_V2 && !cgroup_v2_mounted())
cgroup_mount_v1(ctrl);
if (base)
--
2.40.0
--
Mailing list info: https://lists.linux.it/listinfo/ltp
next reply other threads:[~2023-04-28 8:49 UTC|newest]
Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top
2023-04-28 8:49 Li Wang [this message]
2023-04-28 10:25 ` [LTP] [RFC PATCH] tst_cgroup: Avoid mixing mounts V1 and V2 simultaneously Cyril Hrubis
2023-04-28 12:56 ` Li Wang
2023-04-28 13:13 ` Cyril Hrubis
2023-04-28 13:30 ` Li Wang
2023-04-29 6:47 ` Li Wang
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=20230428084922.9834-1-liwang@redhat.com \
--to=liwang@redhat.com \
--cc=ltp@lists.linux.it \
/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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.