Skip to contentSkip to conversation

cgroup_fj_common.sh: Do not disable systemd related cgroup subsystems

PATCH Superseded Ma Xinjian via ltp 2 participants 3 messages Aug 2, 2024 – Aug 9, 2024

v1 of 2 Superseded Latest is v2 →

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 cgroup_fj_common.sh: Do not disable systemd related cgroup subsystems

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".

---
 testcases/kernel/controllers/cgroup_fj/cgroup_fj_common.sh | 5 ++++-
 1 file changed, 4 insertions(+), 1 deletion(-)
testcases/kernel/controllers/cgroup_fj/cgroup_fj_common.sh +4 -1
index e866641ba..bb4318c51 100755
@@ -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
Signature · 5 lines
2.42.0


-- 
Mailing list info: https://lists.linux.it/listinfo/ltp
Reviewed-by on v1 1/1
#1 lore raw

Hi Ma,

Quoted 4 lines

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".

testcases/kernel/controllers/cgroup_fj/cgroup_fj_common.sh common_cleanup() · line 83

Quoted 5 lines
testcases/kernel/controllers/cgroup_fj/cgroup_fj_common.sh +4 -1
-    [ "$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

Signature · 1 line
Mailing list info: https://lists.linux.it/listinfo/ltp
#2 lore raw
Quoted 22 lines

Hi Ma,

Quoted 5 lines

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".

Quoted 1 line

- [ "$cgroup_version" = "2" ] && ROD echo "-$subsystem" \>

"/sys/fs/cgroup/cgroup.subtree_control"

Quoted 1 line

+ if [ "$cgroup_version" = "2" ] && [ "$subsystem" != "cpu" ] &&

[ "$subsystem" != "io" ] \

Quoted 1 line

+ && [ "$subsystem" != "memory" ] && [ "$subsystem" !=

"pids" ]; then

Quoted 1 line

+ ROD echo "-$subsystem" \>

"/sys/fs/cgroup/cgroup.subtree_control"

Quoted 1 line

+ fi

I would personally wrote it as:

Quoted 8 lines
    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

Quoted 3 lines

Kind regards,
Petr

Signature · 1 line
Mailing list info: https://lists.linux.it/listinfo/ltp