controllers/cgroup_fj: fix and clean up
PATCH v2 1/1 controllers/cgroup_fj: fix and clean up
Many tests were failing on recent kernels because it is not possible to mount cgroup several times anymore. Now the test first checks if the cgroup exists. The cgroup will be mounted (and umounted) only if it doesn't exist at the start of the test.
It also checks that the subsystem exist before we run the tests.
A few minor typo mistakes were fixed (expectted instead of expected).
Most of the tests are now passing.
--- .../controllers/cgroup_fj/cgroup_fj_function.sh | 45 ++++++++------ .../controllers/cgroup_fj/cgroup_fj_stress.sh | 51 ++++++++++------ .../controllers/cgroup_fj/cgroup_fj_utility.sh | 70 +++++++++++++--------- 3 files changed, 102 insertions(+), 64 deletions(-)
testcases/kernel/controllers/cgroup_fj/cgroup_fj_function.sh +27 -18
@@ -37,6 +37,7 @@ noprefix_use_str=""; release_agent_para_str=""; notify_on_release_str=""; release_agent_str=""; +mounted=1; expected=1;
@@ -132,6 +133,12 @@ if [ "$#" -ne "9" ]; then exit -1; fi +mount_point=$(get_mount_point) +if [ "$mount_point" == "" ] ; then + mounted=0 + mount_point=/dev/cgroup +fi + check_para; if [ $? -ne 0 ]; then usage;
@@ -139,7 +146,9 @@ if [ $? -ne 0 ]; then fi setup; -mount_cgroup; +if [ $mounted -ne 1 ]; then + mount_cgroup; +fi $TESTROOT/cgroup_fj_proc & pid=$!
@@ -148,15 +157,15 @@ mkdir_subgroup; # cpuset.cpus and cpuset.mems should be specified with suitable value # before attaching operation if subsystem is cpuset -if [ "$subsystem" == "cpuset" ] || [ "$subsystem" == "all" ] || [ $subsystem == "none" ] ; then +if [ "$subsystem" == "cpuset" ] || [ "$subsystem" == "all" ] || [ "$subsystem" == "none" ] ; then exist=`grep -w cpuset /proc/cgroups | cut -f1`; if [ "$exist" != "" ]; then if [ "$noprefix_use" == "no" ]; then - do_echo 1 1 `cat /dev/cgroup/cpus` /dev/cgroup/subgroup_1/cpus; - do_echo 1 1 `cat /dev/cgroup/mems` /dev/cgroup/subgroup_1/mems; + do_echo 1 1 `cat $mount_point/cpus` $mount_point/subgroup_1/cpus; + do_echo 1 1 `cat $mount_point/mems` $mount_point/subgroup_1/mems; else - do_echo 1 1 `cat /dev/cgroup/cpuset.cpus` /dev/cgroup/subgroup_1/cpuset.cpus; - do_echo 1 1 `cat /dev/cgroup/cpuset.mems` /dev/cgroup/subgroup_1/cpuset.mems; + do_echo 1 1 `cat $mount_point/cpuset.cpus` $mount_point/subgroup_1/cpuset.cpus; + do_echo 1 1 `cat $mount_point/cpuset.mems` $mount_point/subgroup_1/cpuset.mems; fi fi fi
@@ -166,12 +175,12 @@ case $attach_operation in "1" ) ;; "2" ) - do_echo 1 1 $pid /dev/cgroup/subgroup_1/tasks; + do_echo 1 1 $pid $mount_point/subgroup_1/tasks; ;; "3" ) $TESTROOT/cgroup_fj_proc & pid2=$! - cat /dev/cgroup/tasks > $TMPFILE + cat $mount_point/tasks > $TMPFILE nlines=`cat $TMPFILE | wc -l` for i in `seq 1 $nlines` do
@@ -190,12 +199,12 @@ case $attach_operation in continue fi fi - do_echo 1 1 "$cur_pid" /dev/cgroup/subgroup_1/tasks + do_echo 1 1 "$cur_pid" $mount_point/subgroup_1/tasks fi done ;; "4" ) - do_echo 1 1 $pid /dev/cgroup/subgroup_1/tasks; + do_echo 1 1 $pid $mount_point/subgroup_1/tasks; sleep 1 do_kill 1 1 10 $pid ;;
@@ -214,18 +223,18 @@ esac #if [ $notify_on_release -ne 0 ] && [ $notify_on_release -ne 1 ] && [ $notify_on_release -ne 2 ];then # expected=0 #fi -do_echo 1 $expected $notify_on_release_str /dev/cgroup/subgroup_1/notify_on_release; +do_echo 1 $expected $notify_on_release_str $mount_point/subgroup_1/notify_on_release; # echo release_agent that analysed from parameter if [ $release_agent_echo -ne 1 ]; then - do_echo 1 1 $release_agent_str /dev/cgroup/release_agent; + do_echo 1 1 $release_agent_str $mount_point/release_agent; fi sleep 1 # pid could not be echoed from subgroup if subsystem is ( or include ) ns, # so we kill them here -if [ "$subsystem" == "ns" ] || [ "$subsystem" == "all" ] || [ $subsystem == "none" ] ; then +if [ "$subsystem" == "ns" ] || [ "$subsystem" == "all" ] || [ "$subsystem" == "none" ] ; then do_kill 1 1 9 $pid do_kill 1 1 9 $pid2 # removing operation
@@ -234,20 +243,20 @@ else "1" ) ;; "2" ) - do_echo 1 1 $pid /dev/cgroup/tasks + do_echo 1 1 $pid $mount_point/tasks if [ $pid2 -ne 0 ] ; then - do_echo 1 1 $pid2 /dev/cgroup/tasks + do_echo 1 1 $pid2 $mount_point/tasks fi ;; "3" ) - cat /dev/cgroup/subgroup_1/tasks > $TMPFILE + cat $mount_point/subgroup_1/tasks > $TMPFILE nlines=`cat $TMPFILE | wc -l` if [ $nlines -ne 0 ]; then for i in `seq 1 $nlines` do cur_pid=`sed -n "$i""p" $TMPFILE` if [ -e /proc/$cur_pid/ ];then - do_echo 1 1 "$cur_pid" /dev/cgroup/tasks + do_echo 1 1 "$cur_pid" $mount_point/tasks fi done fi
@@ -264,7 +273,7 @@ fi sleep 1 -do_rmdir 0 1 /dev/cgroup/subgroup_* +do_rmdir 0 1 $mount_point/subgroup_* cleanup; do_kill 1 1 9 $pid
testcases/kernel/controllers/cgroup_fj/cgroup_fj_stress.sh +32 -19
133 lines not on this page · raw message
testcases/kernel/controllers/cgroup_fj/cgroup_fj_utility.sh +43 -27
166 lines not on this page · raw message
Signature · 1 line
2.1.4
PATCH v2 1/1 controllers/cgroup_fj: fix and clean up
Hi!
Quoted 18 lines
testcases/kernel/controllers/cgroup_fj/cgroup_fj_function.sh +7
-0+mounted=1; expected=1;@@ -132,6 +133,12 @@ if [ "$#" -ne "9" ]; then exit -1; fi +mount_point=$(get_mount_point) +if [ "$mount_point" == "" ] ; then + mounted=0 + mount_point=/dev/cgroup +fi + check_para; if [ $? -ne 0 ]; then usage;
testcases/kernel/controllers/cgroup_fj/cgroup_fj_function.sh if [ $? -ne 0 ]; then · line 151
Quoted 7 lines
testcases/kernel/controllers/cgroup_fj/cgroup_fj_function.sh +3
-1@@ -139,7 +146,9 @@ if [ $? -ne 0 ]; then fi setup; -mount_cgroup; +if [ $mounted -ne 1 ]; then + mount_cgroup; +fi
It would be more elegant if this snippets of code that detect if cgroup is mounted and mount it if it isn't were part of the setup() function instead of being copied in each test.
...
testcases/kernel/controllers/cgroup_fj/cgroup_fj_utility.sh exist_subsystem() · line 55
Quoted 3 lines
testcases/kernel/controllers/cgroup_fj/cgroup_fj_utility.sh +3
-0+get_mount_point() +{ + check_point=`grep -w $subsystem /proc/mounts | cut -f 2 | cut -d " " -f2`
I would do even more specific:
grep -w "^$subsystem"
which would match only lines that begin with word "$subsystem".
Otherwise this looks good.
Signature · 2 lines
Cyril Hrubis [email protected]
PATCH v2 1/1 controllers/cgroup_fj: fix and clean up
Hi,
Quoted 6 lines · Cyril Hrubis
...
testcases/kernel/controllers/cgroup_fj/cgroup_fj_utility.sh exist_subsystem() · line 55
Quoted 3 lines
testcases/kernel/controllers/cgroup_fj/cgroup_fj_utility.sh +3
-0+get_mount_point() +{ + check_point=`grep -w $subsystem /proc/mounts | cut -f 2 | cut -d " " -f2`I would do even more specific:
Quoted 7 lines
grep -w "^$subsystem"
which would match only lines that begin with word "$subsystem".
Otherwise this looks good.
Thanks for the review.
The format of /proc/mounts is not stable so it might be better to keep things like they are.
Signature · 1 line
Cedric Hnyda