cgroup: fix mount errors on cgroup subsys
PATCH 1/1 cgroup: fix mount errors on cgroup subsys
This patch is on target to fix tiny errors:
mount: xxx is already mounted or /opt/ltp/testcases/bin/cgroup busy
cgroup_regression_test 3 TFAIL : ltpapicmd.c:190: Failed to mount cpu subsys cgroup_regression_test 4 TCONF : ltpapicmd.c:190: CONFIG_LOCKDEP is not enabled mount: xxx is already mounted or /opt/ltp/testcases/bin/cgroup busy cgroup_regression_test 5 TFAIL : ltpapicmd.c:190: mount net_prio and pids failed cgroup_regression_test 6 TCONF : ltpapicmd.c:190: CONFIG_CGROUP_NS
mount: xxx is already mounted or /opt/ltp/testcases/bin/cgroup busycgroup_regression_test 7 TFAIL : ltpapicmd.c:190: failed to mount net_prio
Test Environment: 23G RAM, 24 CPUS, x86_64, RHEL7.3GA
--- .../controllers/cgroup/cgroup_regression_test.sh | 46 +++++++++++++++++++++- 1 file changed, 44 insertions(+), 2 deletions(-)
testcases/kernel/controllers/cgroup/cgroup_regression_test.sh +44 -2
@@ -181,10 +181,17 @@ test_3() return fi + local cpu=cpu + + # For rhel7.3 or later, cpu is always binding with cpuacct subsys + if grep -w cpu /proc/mounts ; then + cpu=$(basename $(grep -w cpu /proc/mounts | cut -d ' ' -f 2)) + fi + # Run the test for 30 secs - mount -t cgroup -o cpu xxx cgroup/ + mount -t cgroup -o $cpu xxx cgroup/ if [ $? -ne 0 ]; then - tst_resm TFAIL "Failed to mount cpu subsys" + tst_resm TFAIL "Failed to mount $cpu subsys" failed=1 return fi
@@ -262,6 +269,20 @@ test_5() subsys1=`tail -n 1 /proc/cgroups | awk '{ print $1 }'` subsys2=`tail -n 2 /proc/cgroups | head -1 | awk '{ print $1 }'` + # On rhel7.3, cgroup subsystem is mounted automatically + # Here just unmout these two target temporarily for test + if grep -w $subsys1 /proc/mounts ; then + subsys1_orig=$(basename $(grep -w $subsys1 /proc/mounts | cut -d ' ' -f 2)) + subsys1_path=$(grep -w $subsys1 /proc/mounts | cut -d ' ' -f 2) + umount $subsys1_path + fi + + if grep -w $subsys2 /proc/mounts ; then + subsys2_orig=$(basename $(grep -w $subsys2 /proc/mounts | cut -d ' ' -f 2)) + subsys2_path=$(grep -w $subsys2 /proc/mounts | cut -d ' ' -f 2) + umount $subsys2_path + fi + mount -t cgroup -o $subsys1,$subsys2 xxx cgroup/ if [ $? -ne 0 ]; then tst_resm TFAIL "mount $subsys1 and $subsys2 failed"
@@ -298,6 +319,17 @@ test_5() wait $! rmdir cgroup/0 umount cgroup/ + + # waiting for cgroup/ unmout successfuly + tst_sleep 100ms + + if [ -n "$subsys1_path" ]; then + mount -t cgroup -o $subsys1_orig cgroup $subsys1_path + fi + + if [ -n "$subsys2_path" ]; then + mount -t cgroup -o $subsys2_orig cgroup $subsys2_path + fi } #---------------------------------------------------------------------------
@@ -411,6 +443,12 @@ test_7() subsys=`tail -n 1 /proc/cgroups | awk '{ print $1 }'` + if grep -w $subsys /proc/mounts ; then + subsys_orig=$(basename $(grep -w $subsys /proc/mounts | cut -d ' ' -f 2)) + subsys_path=$(grep -w $subsys /proc/mounts | cut -d ' ' -f 2) + umount $subsys_path + fi + # remount to add new subsystems to the hierarchy i=1 while [ $i -le 2 ] ; do
@@ -426,6 +464,10 @@ test_7() : $(( i += 1 )) done + if [ -n "$subsys_path" ]; then + mount -t cgroup -o $subsys_orig cgroup $subsys_path + fi + tst_resm TPASS "no kernel bug was found" }
Signature · 1 line
1.8.3.1
PATCH 1/1 cgroup: fix mount errors on cgroup subsys
Hi!
Quoted 18 lines
--- .../controllers/cgroup/cgroup_regression_test.sh | 46 +++++++++++++++++++++- 1 file changed, 44 insertions(+), 2 deletions(-)testcases/kernel/controllers/cgroup/cgroup_regression_test.sh +6
-0@@ -181,10 +181,17 @@ test_3() return fi + local cpu=cpu + + # For rhel7.3 or later, cpu is always binding with cpuacct subsys + if grep -w cpu /proc/mounts ; then + cpu=$(basename $(grep -w cpu /proc/mounts | cut -d ' ' -f 2)) + fi
testcases/kernel/controllers/cgroup/cgroup_regression_test.sh test_3() · line 197
Quoted 10 lines
testcases/kernel/controllers/cgroup/cgroup_regression_test.sh +3
-2+ # Run the test for 30 secs - mount -t cgroup -o cpu xxx cgroup/ + mount -t cgroup -o $cpu xxx cgroup/ if [ $? -ne 0 ]; then - tst_resm TFAIL "Failed to mount cpu subsys" + tst_resm TFAIL "Failed to mount $cpu subsys" failed=1 return fi
Why can't we mount the cgroup only when it's not mounted yet and use the path it's mounted on otherwise? We do that for the functional tetscases already.
And I do not think that umounting system cgroups is a good idea either. I would say that the test should use whatever is mounted on the system and if that is not possible I would rather produce TCONF than fiddle with umounting cgroups from the standard system path.
Signature · 2 lines
Cyril Hrubis [email protected]
PATCH 1/1 cgroup: fix mount errors on cgroup subsys
Quoted 25 lines · Cyril Hrubis
Hi!
Quoted 24 lines
--- .../controllers/cgroup/cgroup_regression_test.sh | 46 +++++++++++++++++++++- 1 file changed, 44 insertions(+), 2 deletions(-)testcases/kernel/controllers/cgroup/cgroup_regression_test.sh +8
-2@@ -181,10 +181,17 @@ test_3() return fi + local cpu=cpu + + # For rhel7.3 or later, cpu is always binding with cpuacct subsys + if grep -w cpu /proc/mounts ; then + cpu=$(basename $(grep -w cpu /proc/mounts | cut -d ' ' -f 2)) + fi + # Run the test for 30 secs - mount -t cgroup -o cpu xxx cgroup/ + mount -t cgroup -o $cpu xxx cgroup/ if [ $? -ne 0 ]; then - tst_resm TFAIL "Failed to mount cpu subsys"
Quoted 8 lines
testcases/kernel/controllers/cgroup/cgroup_regression_test.sh test_3() · line 197
Quoted 4 lines
testcases/kernel/controllers/cgroup/cgroup_regression_test.sh +1
-0+ tst_resm TFAIL "Failed to mount $cpu subsys" failed=1 return fiWhy can't we mount the cgroup only when it's not mounted yet and use the path it's mounted on otherwise? We do that for the functional tetscases already.
I thought that the original case including cgroup mounted test, so I unmount the system cgroup and do itself mount & testing there.
Quoted 5 lines
And I do not think that umounting system cgroups is a good idea either. I would say that the test should use whatever is mounted on the system and if that is not possible I would rather produce TCONF than fiddle with umounting cgroups from the standard system path.
Using system cgroups is not a bad idea, I hesitated about doing that or just doing tiny fix. now you help me make a decision.
Thanks for your comments, I will rewrite this PATCH.
Signature · 3 lines
Regards, Li Wang Email: [email protected]
PATCH 1/1 cgroup: fix mount errors on cgroup subsys
Hi!
Quoted 6 lines
Quoted 3 lines
Why can't we mount the cgroup only when it's not mounted yet and use the path it's mounted on otherwise? We do that for the functional tetscases already.
I thought that the original case including cgroup mounted test, so I unmount the system cgroup and do itself mount & testing there.
Well the original test was written at times where cgroups were shiny and new and were not mounted by default on some well defined location...
Signature · 2 lines
Cyril Hrubis [email protected]