<div dir="ltr"><div dir="ltr"><div class="gmail_default" style="font-size:small"><br></div></div><br><div class="gmail_quote"><div dir="ltr" class="gmail_attr">On Mon, Jun 22, 2020 at 6:05 PM Li Wang <<a href="mailto:liwang@redhat.com">liwang@redhat.com</a>> wrote:<br></div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex"> * system doesn't support any cgroup(v1, v2): TCONF<br>
* system only support cgroup v1: choose v1<br>
* system only support cgroup v2: choose v2<br>
* system support v1 & v2 but mounting v1: chosse v1<br>
* systep support v1 & v2 but mounting v2: choose v2<br>
<br>
Signed-off-by: Li Wang <<a href="mailto:liwang@redhat.com" target="_blank">liwang@redhat.com</a>><br>
---<br>
lib/tst_cgroup.c | 19 ++++++++++---------<br>
1 file changed, 10 insertions(+), 9 deletions(-)<br>
<br>
diff --git a/lib/tst_cgroup.c b/lib/tst_cgroup.c<br>
index 0118dd7b2..010baa69e 100644<br>
--- a/lib/tst_cgroup.c<br>
+++ b/lib/tst_cgroup.c<br>
@@ -38,18 +38,19 @@ static int tst_cgroup_check(const char *cgroup)<br>
<br>
enum tst_cgroup_ver tst_cgroup_version(void)<br>
{<br>
- if (tst_cgroup_check("cgroup2")) {<br>
- if (!tst_is_mounted("cgroup2") && tst_is_mounted("cgroup"))<br>
- return TST_CGROUP_V1;<br>
- else<br>
- return TST_CGROUP_V2;<br>
- }<br>
+ enum tst_cgroup_ver cg_ver;<br>
<br>
if (tst_cgroup_check("cgroup"))<br>
- return TST_CGROUP_V1;<br>
+ cg_ver = TST_CGROUP_V1;<br></blockquote><div><br></div><div><div class="gmail_default" style="font-size:small">Ah sorry, it seems we shouldn't searching "cgroup" first, because that will be misled by "cgroup2" too. Plz ignore this patch</div><div class="gmail_default" style="font-size:small"><br></div><div class="gmail_default" style="font-size:small">This is a little bit tricky, let me think over.</div><br></div><div> </div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex">
+<br>
+ if (tst_cgroup_check("cgroup2"))<br>
+ if (!cg_ver || tst_is_mounted("cgroup2"))<br>
+ cg_ver = TST_CGROUP_V2;<br>
+<br>
+ if (!cg_ver)<br>
+ tst_brk(TCONF, "Cgroup is not configured");<br>
<br>
- tst_brk(TCONF, "Cgroup is not configured");<br>
- return TST_CGROUP_V1; /* fix -Werror=return-type */<br>
+ return cg_ver;<br>
}<br>
<br>
static void tst_cgroup1_mount(const char *name, const char *option,<br>
-- <br>
2.21.1<br>
<br>
<br>
-- <br>
Mailing list info: <a href="https://lists.linux.it/listinfo/ltp" rel="noreferrer" target="_blank">https://lists.linux.it/listinfo/ltp</a><br>
<br>
</blockquote></div><br clear="all"><div><br></div>-- <br><div dir="ltr" class="gmail_signature"><div dir="ltr"><div>Regards,<br></div><div>Li Wang<br></div></div></div></div>