diff mbox series

cgroup_fj_common.sh: Do not disable systemd related cgroup subsystems

Message ID 20240802082220.890830-1-maxj.fnst@fujitsu.com
State Superseded
Headers show
Series cgroup_fj_common.sh: Do not disable systemd related cgroup subsystems | expand

Commit Message

Ma Xinjian Aug. 2, 2024, 8:22 a.m. UTC
The cpu, io, memory, and pids subsystems under the root cgroup cannot be disabled
because they are used for systemd. Currently, the test of cpu and memory subsystems
in cgroup_fj_function.sh and cgroup_fj_stress.sh will report the error
"echo: write error: device or resource busy".

Signed-off-by: Ma Xinjian <maxj.fnst@fujitsu.com>
---
 testcases/kernel/controllers/cgroup_fj/cgroup_fj_common.sh | 5 ++++-
 1 file changed, 4 insertions(+), 1 deletion(-)

Comments

Petr Vorel Aug. 8, 2024, 9:32 a.m. UTC | #1
Hi Ma,

> The cpu, io, memory, and pids subsystems under the root cgroup cannot be disabled
> because they are used for systemd. Currently, the test of cpu and memory subsystems
> in cgroup_fj_function.sh and cgroup_fj_stress.sh will report the error
> "echo: write error: device or resource busy".

Reviewed-by: Petr Vorel <pvorel@suse.cz>

> -    [ "$cgroup_version" = "2" ] && ROD echo "-$subsystem" \> "/sys/fs/cgroup/cgroup.subtree_control"
> +    if [ "$cgroup_version" = "2" ] && [ "$subsystem" != "cpu" ] && [ "$subsystem" != "io" ] \
> +            && [ "$subsystem" != "memory" ] && [ "$subsystem" != "pids" ]; then
> +            ROD echo "-$subsystem" \> "/sys/fs/cgroup/cgroup.subtree_control"
> +    fi

I would personally wrote it as:

    if [ "$cgroup_version" = "2" ]; then
		case "$subsystem" in
			cpu|io|memory|pid)
				:;;
			*) ROD echo "-$subsystem" \> "/sys/fs/cgroup/cgroup.subtree_control";;
		esac
    fi

Kind regards,
Petr
Ma Xinjian Aug. 9, 2024, 7:35 a.m. UTC | #2
> Hi Ma,
> 
> > The cpu, io, memory, and pids subsystems under the root cgroup cannot
> > be disabled because they are used for systemd. Currently, the test of
> > cpu and memory subsystems in cgroup_fj_function.sh and
> > cgroup_fj_stress.sh will report the error
> > "echo: write error: device or resource busy".
> 
> Reviewed-by: Petr Vorel <pvorel@suse.cz>
> 
> > -    [ "$cgroup_version" = "2" ] && ROD echo "-$subsystem" \>
> "/sys/fs/cgroup/cgroup.subtree_control"
> > +    if [ "$cgroup_version" = "2" ] && [ "$subsystem" != "cpu" ] &&
> [ "$subsystem" != "io" ] \
> > +            && [ "$subsystem" != "memory" ] && [ "$subsystem" !=
> "pids" ]; then
> > +            ROD echo "-$subsystem" \>
> "/sys/fs/cgroup/cgroup.subtree_control"
> > +    fi
> 
> I would personally wrote it as:
> 
>     if [ "$cgroup_version" = "2" ]; then
> 		case "$subsystem" in
> 			cpu|io|memory|pid)
> 				:;;
> 			*) ROD echo "-$subsystem" \>
> "/sys/fs/cgroup/cgroup.subtree_control";;
> 		esac
>     fi
Hi Petr

Thanks for the code optimization. It looks much simpler.
I have submitted [PATCH v2], PTAL.

Best regards,
Ma
> 
> Kind regards,
> Petr
diff mbox series

Patch

diff --git a/testcases/kernel/controllers/cgroup_fj/cgroup_fj_common.sh b/testcases/kernel/controllers/cgroup_fj/cgroup_fj_common.sh
index e866641ba..bb4318c51 100755
--- a/testcases/kernel/controllers/cgroup_fj/cgroup_fj_common.sh
+++ b/testcases/kernel/controllers/cgroup_fj/cgroup_fj_common.sh
@@ -77,7 +77,10 @@  common_cleanup()
 
     cgroup_cleanup
 
-    [ "$cgroup_version" = "2" ] && ROD echo "-$subsystem" \> "/sys/fs/cgroup/cgroup.subtree_control"
+    if [ "$cgroup_version" = "2" ] && [ "$subsystem" != "cpu" ] && [ "$subsystem" != "io" ] \
+            && [ "$subsystem" != "memory" ] && [ "$subsystem" != "pids" ]; then
+            ROD echo "-$subsystem" \> "/sys/fs/cgroup/cgroup.subtree_control"
+    fi
 }
 
 . cgroup_lib.sh