controllers/cpuset:check for cpuset mount status and prefix
PATCH v2 1/1 controllers/cpuset:check for cpuset mount status and prefix
From: Shuang Qiu <[email protected]>
* Update to handle the env that cpuset subsystem is already mounted
* Similar with commit 6ce94db5bbff0be40813f3fdfe61a55b3186c49a,need to check for cpuset prefix
[ I've updated the patch so that it applies cleany and did a few minor fixes. It
fixes the main problem for me i.e. permission errors. Some of the tests fail though. But still these tests works better with the patch. ]
Signed-off-by Shuang Qiu <[email protected]>
Signed-off-by Cyril Hrubis <[email protected]>
--- .../cpuset_base_ops_testset.sh | 28 +- .../cpuset_exclusive_test/cpuset_exclusive_test.sh | 168 ++++----- .../kernel/controllers/cpuset/cpuset_funcs.sh | 37 +- .../cpuset_hierarchy_test/cpuset_hierarchy_test.sh | 416 ++++++++++----------- .../cpuset_hotplug_test/cpuset_hotplug_test.sh | 4 +- .../cpuset_inherit_test/cpuset_inherit_testset.sh | 12 +- .../cpuset_memory_pressure_testset.sh | 32 +- .../cpuset_memory_spread_testset.sh | 2 +- .../cpuset_memory_test/cpuset_memory_testset.sh | 22 +- .../cpuset_syscall_test/cpuset_syscall_testset.sh | 8 +- 10 files changed, 368 insertions(+), 361 deletions(-)
testcases/kernel/controllers/cpuset/cpuset_base_ops_test/cpuset_base_ops_testset.sh +14 -14
@@ -105,7 +105,7 @@ test_cpus() cfile_name="cpus" while read cpus result do - base_op_test "$CPUSET/1/cpus" "$cpus" "$result" + base_op_test "$CPUSET/1/${PREFIX}cpus" "$cpus" "$result" done <<- EOF NULL EMPTY 0 0
@@ -124,14 +124,14 @@ test_cpus() # while read cpus result if [ $nr_cpus -ge 3 ]; then - base_op_test "$CPUSET/1/cpus" "0,1-$((nr_cpus-2)),$((nr_cpus-1))" "0-$((nr_cpus-1))" - base_op_test "$CPUSET/1/cpus" "0,1-$((nr_cpus-2))," "0-$((nr_cpus-2))" + base_op_test "$CPUSET/1/${PREFIX}cpus" "0,1-$((nr_cpus-2)),$((nr_cpus-1))" "0-$((nr_cpus-1))" + base_op_test "$CPUSET/1/${PREFIX}cpus" "0,1-$((nr_cpus-2))," "0-$((nr_cpus-2))" fi if tst_kvcmp -lt "3.0 RHEL6:2.6.32"; then - base_op_test "$CPUSET/1/cpus" "0-" "WRITE_ERROR" + base_op_test "$CPUSET/1/${PREFIX}cpus" "0-" "WRITE_ERROR" else - base_op_test "$CPUSET/1/cpus" "0-" "0" + base_op_test "$CPUSET/1/${PREFIX}cpus" "0-" "0" fi }
@@ -140,7 +140,7 @@ test_mems() cfile_name="mems" while read mems result do - base_op_test "$CPUSET/1/mems" "$mems" "$result" + base_op_test "$CPUSET/1/${PREFIX}mems" "$mems" "$result" done <<- EOF NULL EMPTY 0 0
@@ -159,14 +159,14 @@ test_mems() # while read mems result if [ $nr_mems -ge 3 ]; then - base_op_test "$CPUSET/1/mems" "0,1-$((nr_mems-2)),$((nr_mems-1))" "0-$((nr_mems-1))" - base_op_test "$CPUSET/1/mems" "0,1-$((nr_mems-2))," "0-$((nr_mems-2))" + base_op_test "$CPUSET/1/${PREFIX}mems" "0,1-$((nr_mems-2)),$((nr_mems-1))" "0-$((nr_mems-1))" + base_op_test "$CPUSET/1/${PREFIX}mems" "0,1-$((nr_mems-2))," "0-$((nr_mems-2))" fi if tst_kvcmp -lt "3.0 RHEL6:2.6.32"; then - base_op_test "$CPUSET/1/mems" "0-" "WRITE_ERROR" + base_op_test "$CPUSET/1/${PREFIX}mems" "0-" "WRITE_ERROR" else - base_op_test "$CPUSET/1/mems" "0-" "0" + base_op_test "$CPUSET/1/${PREFIX}mems" "0-" "0" fi }
@@ -179,7 +179,7 @@ test_flags() cfile_name="$filename" while read flags result do - base_op_test "$CPUSET/$filename" "$flags" "$result" + base_op_test "$CPUSET/${PREFIX}$filename" "$flags" "$result" done <<- EOF 0 0 1 1
@@ -219,10 +219,10 @@ attach_task_test() fi if [ "$cpus" != "NULL" ]; then - echo $cpus > "$CPUSET/sub_cpuset/cpus" + echo $cpus > "$CPUSET/sub_cpuset/${PREFIX}cpus" fi if [ "$mems" != "NULL" ]; then - echo $mems > "$CPUSET/sub_cpuset/mems" + echo $mems > "$CPUSET/sub_cpuset/${PREFIX}mems" fi cat /dev/zero > /dev/null &
@@ -265,7 +265,7 @@ test_readonly_cfiles() for filename in cpus mems memory_pressure do cfile_name="$filename(READONLY)" - base_op_test "$CPUSET/$filename" "0" "WRITE_ERROR" + base_op_test "$CPUSET/${PREFIX}$filename" "0" "WRITE_ERROR" done # for filename in readonly cfiles }
testcases/kernel/controllers/cpuset/cpuset_exclusive_test/cpuset_exclusive_test.sh +84 -84
270 lines not on this page · raw message
testcases/kernel/controllers/cpuset/cpuset_funcs.sh +22 -15
@@ -35,7 +35,8 @@ fi N_NODES=${N_NODES#*-*} N_NODES=$(($N_NODES + 1)) -CPUSET="/dev/cpuset" +CPUSET=$(awk '/cpuset/ {print $2}' /proc/mounts) +[ -z "$CPUSET" ] || CPUSET="/dev/cpuset" CPUSET_TMP="/tmp/cpuset_tmp" HOTPLUG_CPU="1"
@@ -120,20 +121,25 @@ check() # clean any group created eralier (if any) setup() { - if [ -e "$CPUSET" ] - then - tst_resm TWARN "$CPUSET already exist.. overwriting" - cleanup || tst_brkm TFAIL "Can't cleanup... Exiting" - fi + mounted=0 + if [ "$CPUSET" = "/dev/cpuset" ]; then + if [ -e "$CPUSET" ];then + tst_resm TWARN "$CPUSET already exist.. overwriting" + cleanup || tst_brkm TFAIL "Can't cleanup... Exiting" + fi - mkdir -p "$CPUSET_TMP" - mkdir "$CPUSET" - mount -t cpuset cpuset "$CPUSET" 2> /dev/null - if [ $? -ne 0 ]; then - cleanup - tst_brkm TFAIL "Could not mount cgroup filesystem with"\ + mkdir -p "$CPUSET_TMP" + mkdir "$CPUSET" + mount -t cpuset cpuset "$CPUSET" 2> /dev/null + if [ $? -ne 0 ]; then + cleanup + tst_brkm TFAIL "Could not mount cgroup filesystem with"\ " cpuset on $CPUSET..Exiting test" + else + mounted=1 + fi fi + [ -e "$CPUSET/cpuset.cpus" ] && PREFIX="cpuset." } # Write the cleanup function
@@ -161,6 +167,7 @@ cleanup() fi done + [ "$mounted" -ne 1 ] && return umount "$CPUSET" if [ $? -ne 0 ]; then tst_brkm TFAIL "Couldn't umount cgroup filesystem with"\
@@ -186,19 +193,19 @@ cpuset_set() if [ "$path" != "$CPUSET" ]; then if [ "$cpus" != "-" ]; then - /bin/echo $cpus > $path/cpus + /bin/echo $cpus > $path/${PREFIX}cpus if [ $? -ne 0 ]; then return 1 fi fi - /bin/echo $mems > $path/mems + /bin/echo $mems > $path/${PREFIX}mems if [ $? -ne 0 ]; then return 1 fi fi - /bin/echo $load_balance > $path/sched_load_balance + /bin/echo $load_balance > $path/${PREFIX}sched_load_balance if [ $? -ne 0 ]; then return 1 fi
testcases/kernel/controllers/cpuset/cpuset_hierarchy_test/cpuset_hierarchy_test.sh +208 -208
612 lines not on this page · raw message
testcases/kernel/controllers/cpuset/cpuset_hotplug_test/cpuset_hotplug_test.sh +2 -2
@@ -86,7 +86,7 @@ root_cpu_hotplug_test() return 1 fi - root_cpus="`cat $CPUSET/cpus`" + root_cpus="`cat $CPUSET/${PREFIX}cpus`" task_cpus="`cat /proc/$tst_pid/status | grep Cpus_allowed_list`" task_cpus="`echo $task_cpus | sed -e 's/Cpus_allowed_list: //'`"
@@ -155,7 +155,7 @@ general_cpu_hotplug_test() return 1 fi - cpus="`cat $path/cpus`" + cpus="`cat $path/${PREFIX}cpus`" task_cpus="`cat /proc/$tst_pid/status | grep Cpus_allowed_list`" task_cpus="`echo $task_cpus | sed -e 's/Cpus_allowed_list: //'`"
testcases/kernel/controllers/cpuset/cpuset_inherit_test/cpuset_inherit_testset.sh +6 -6
@@ -105,7 +105,7 @@ test_cpus() cfile_name="cpus" while read cpus result do - inherit_test "$CPUSET/1/cpus" "$cpus" "$result" + inherit_test "$CPUSET/1/${PREFIX}cpus" "$cpus" "$result" done <<- EOF NULL EMPTY 0 EMPTY
@@ -119,7 +119,7 @@ test_mems() cfile_name="mems" while read mems result do - inherit_test "$CPUSET/1/mems" "$mems" "$result" + inherit_test "$CPUSET/1/${PREFIX}mems" "$mems" "$result" done <<- EOF NULL EMPTY 0 EMPTY
@@ -137,7 +137,7 @@ test_three_result_similar_flags() cfile_name="$filename" while read flags result do - inherit_test "$CPUSET/1/$filename" "$flags" "$result" + inherit_test "$CPUSET/1/${PREFIX}$filename" "$flags" "$result" done <<- EOF 0 0 1 0
@@ -154,7 +154,7 @@ test_spread_flags() cfile_name="$filename" while read flags result do - inherit_test "$CPUSET/1/$filename" "$flags" "$result" + inherit_test "$CPUSET/1/${PREFIX}$filename" "$flags" "$result" done <<- EOF 0 0 1 1
@@ -168,7 +168,7 @@ test_sched_load_balance_flag() cfile_name="sched_load_balance" while read flag result do - inherit_test "$CPUSET/1/sched_load_balance" "$flag" "$result" + inherit_test "$CPUSET/1/${PREFIX}sched_load_balance" "$flag" "$result" done <<- EOF 0 1 1 1
@@ -181,7 +181,7 @@ test_domain() cfile_name="sched_relax_domain_level" while read domain_level result do - inherit_test "$CPUSET/1/sched_relax_domain_level" "$domain_level" "$result" + inherit_test "$CPUSET/1/${PREFIX}sched_relax_domain_level" "$domain_level" "$result" done <<- EOF -1 -1 0 -1
testcases/kernel/controllers/cpuset/cpuset_memory_pressure_test/cpuset_memory_pressure_testset.sh +16 -16
@@ -43,7 +43,7 @@ usemem=$((py_mem - 20)) test1() { - echo 0 > "$CPUSET/memory_pressure_enabled" 2> $CPUSET_TMP/stderr + echo 0 > "$CPUSET/${PREFIX}memory_pressure_enabled" 2> $CPUSET_TMP/stderr if [ $? -ne 0 ]; then cpuset_log_error $CPUSET_TMP/stderr tst_resm TFAIL "Closing memory_pressure_enabled failed."
@@ -53,7 +53,7 @@ test1() local i for i in $(seq 0 9) do - if [ $(cat "$CPUSET/memory_pressure") -ne 0 ]; then + if [ $(cat "$CPUSET/${PREFIX}memory_pressure") -ne 0 ]; then tst_resm TFAIL "Memory_pressure had memory pressure rate." return 1 fi
@@ -62,7 +62,7 @@ test1() test2() { - echo 0 > "$CPUSET/memory_pressure_enabled" 2> $CPUSET_TMP/stderr + echo 0 > "$CPUSET/${PREFIX}memory_pressure_enabled" 2> $CPUSET_TMP/stderr if [ $? -ne 0 ]; then cpuset_log_error $CPUSET_TMP/stderr tst_resm TFAIL "Closing memory_pressure_enabled failed."
@@ -74,7 +74,7 @@ test2() local i for i in $(seq 0 9) do - if [ $(cat "$CPUSET/memory_pressure") -ne 0 ]; then + if [ $(cat "$CPUSET/${PREFIX}memory_pressure") -ne 0 ]; then tst_resm TFAIL "Memory_pressure had memory pressure rate." return 1 fi
@@ -83,7 +83,7 @@ test2() test3() { - echo 1 > "$CPUSET/memory_pressure_enabled" 2> $CPUSET_TMP/stderr + echo 1 > "$CPUSET/${PREFIX}memory_pressure_enabled" 2> $CPUSET_TMP/stderr if [ $? -ne 0 ]; then cpuset_log_error $CPUSET_TMP/stderr tst_resm TFAIL "Opening memory_pressure_enabled failed."
@@ -100,11 +100,11 @@ test3() local i for i in $(seq 0 9) do - if [ $(cat "$CPUSET/memory_pressure") -ne 0 ]; then + if [ $(cat "$CPUSET/${PREFIX}memory_pressure") -ne 0 ]; then tst_resm TFAIL "root group's memory_pressure had memory pressure rate." return 1 fi - if [ $(cat "$CPUSET/sub_cpuset/memory_pressure") -ne 0 ]; then + if [ $(cat "$CPUSET/sub_cpuset/${PREFIX}memory_pressure") -ne 0 ]; then tst_resm TFAIL "sub group's memory_pressure had memory pressure rate." return 1 fi
@@ -114,7 +114,7 @@ test3() test4() { - echo 1 > "$CPUSET/memory_pressure_enabled" 2> $CPUSET_TMP/stderr + echo 1 > "$CPUSET/${PREFIX}memory_pressure_enabled" 2> $CPUSET_TMP/stderr if [ $? -ne 0 ]; then cpuset_log_error $CPUSET_TMP/stderr tst_resm TFAIL "Opening memory_pressure_enabled failed."
@@ -147,11 +147,11 @@ test4() local i for i in $(seq 0 9) do - if [ $(cat "$CPUSET/memory_pressure") -ne 0 ]; then + if [ $(cat "$CPUSET/${PREFIX}memory_pressure") -ne 0 ]; then tst_resm TFAIL "root group's memory_pressure had memory pressure rate." return 1 fi - if [ $(cat "$CPUSET/sub_cpuset/memory_pressure") -eq 0 ]; then + if [ $(cat "$CPUSET/sub_cpuset/${PREFIX}memory_pressure") -eq 0 ]; then tst_resm TFAIL "sub group's memory_pressure didn't have memory pressure rate." return 1 fi
@@ -160,7 +160,7 @@ test4() test5() { - echo 1 > "$CPUSET/memory_pressure_enabled" 2> $CPUSET_TMP/stderr + echo 1 > "$CPUSET/${PREFIX}memory_pressure_enabled" 2> $CPUSET_TMP/stderr if [ $? -ne 0 ]; then cpuset_log_error $CPUSET_TMP/stderr tst_resm TFAIL "Opening memory_pressure_enabled failed."
@@ -178,11 +178,11 @@ test5() local i for i in $(seq 0 9) do - if [ $(cat "$CPUSET/memory_pressure") -eq 0 ]; then + if [ $(cat "$CPUSET/${PREFIX}memory_pressure") -eq 0 ]; then tst_resm TFAIL "root group's memory_pressure didn't have memory pressure rate." return 1 fi - if [ $(cat "$CPUSET/sub_cpuset/memory_pressure") -ne 0 ]; then + if [ $(cat "$CPUSET/sub_cpuset/${PREFIX}memory_pressure") -ne 0 ]; then tst_resm TFAIL "sub group's memory_pressure had memory pressure rate." return 1 fi
@@ -191,7 +191,7 @@ test5() test6() { - echo 1 > "$CPUSET/memory_pressure_enabled" 2> $CPUSET_TMP/stderr + echo 1 > "$CPUSET/${PREFIX}memory_pressure_enabled" 2> $CPUSET_TMP/stderr if [ $? -ne 0 ]; then cpuset_log_error $CPUSET_TMP/stderr tst_resm TFAIL "Opening memory_pressure_enabled failed."
@@ -224,11 +224,11 @@ test6() local i for i in $(seq 0 9) do - if [ $(cat "$CPUSET/memory_pressure") -eq 0 ]; then + if [ $(cat "$CPUSET/${PREFIX}memory_pressure") -eq 0 ]; then tst_resm TFAIL "root group's memory_pressure didn't have memory pressure rate." return 1 fi - if [ $(cat "$CPUSET/sub_cpuset/memory_pressure") -eq 0 ]; then + if [ $(cat "$CPUSET/sub_cpuset/${PREFIX}memory_pressure") -eq 0 ]; then tst_resm TFAIL "sub group's memory_pressure didn't have memory pressure rate." return 1 fi
testcases/kernel/controllers/cpuset/cpuset_memory_spread_test/cpuset_memory_spread_testset.sh +1 -1
@@ -207,7 +207,7 @@ general_memory_spread_test() return 1 fi - /bin/echo "$is_spread" > "$cpusetpath/memory_spread_page" 2> $CPUSET_TMP/stderr + /bin/echo "$is_spread" > "$cpusetpath/${PREFIX}memory_spread_page" 2> $CPUSET_TMP/stderr if [ $? -ne 0 ]; then cpuset_log_error $CPUSET_TMP/stderr tst_resm TFAIL "set spread value failed."
testcases/kernel/controllers/cpuset/cpuset_memory_test/cpuset_memory_testset.sh +11 -11
@@ -345,7 +345,7 @@ test11() return 1 fi - echo 1 > "$CPUSET/2/memory_migrate" 2> $CPUSET_TMP/stderr + echo 1 > "$CPUSET/2/${PREFIX}memory_migrate" 2> $CPUSET_TMP/stderr if [ $? -ne 0 ]; then cpuset_log_error $CPUSET_TMP/stderr tst_resm TFAIL "set general group2's memory_migrate failed."
@@ -384,7 +384,7 @@ talk2memory_test_for_case_12_13() echo $1 > "$2/tasks" /bin/kill -s SIGUSR1 $1 - echo 0 > "$2/mems" || return 1 + echo 0 > "$2/${PREFIX}mems" || return 1 sleep 1 /bin/kill -s SIGUSR1 $1 sleep 1
@@ -432,7 +432,7 @@ test13() return 1 fi - echo 1 > "$CPUSET/0/memory_migrate" 2> $CPUSET_TMP/stderr + echo 1 > "$CPUSET/0/${PREFIX}memory_migrate" 2> $CPUSET_TMP/stderr if [ $? -ne 0 ]; then cpuset_log_error $CPUSET_TMP/stderr tst_resm TFAIL "set general group's memory_migrate failed."
@@ -543,7 +543,7 @@ test15() return 1 fi - echo 1 > "$CPUSET/2/memory_migrate" 2> $CPUSET_TMP/stderr + echo 1 > "$CPUSET/2/${PREFIX}memory_migrate" 2> $CPUSET_TMP/stderr if [ $? -ne 0 ]; then cpuset_log_error $CPUSET_TMP/stderr tst_resm TFAIL "set general group2's memory_migrate failed."
@@ -599,7 +599,7 @@ test16() return 1 fi - echo 1 > "$CPUSET/2/memory_migrate" 2> $CPUSET_TMP/stderr + echo 1 > "$CPUSET/2/${PREFIX}memory_migrate" 2> $CPUSET_TMP/stderr if [ $? -ne 0 ]; then cpuset_log_error $CPUSET_TMP/stderr tst_resm TFAIL "set general group2's memory_migrate failed."
@@ -618,7 +618,7 @@ test16() echo $testtid > "$CPUSET/2/tasks" sleep 1 - echo 1 > "$CPUSET/1/memory_migrate" + echo 1 > "$CPUSET/1/${PREFIX}memory_migrate" sleep 1 /bin/kill -s SIGUSR2 $testpid sleep 1
@@ -666,7 +666,7 @@ test17() return 1 fi - echo 1 > "$CPUSET/2/memory_migrate" 2> $CPUSET_TMP/stderr + echo 1 > "$CPUSET/2/${PREFIX}memory_migrate" 2> $CPUSET_TMP/stderr if [ $? -ne 0 ]; then cpuset_log_error $CPUSET_TMP/stderr tst_resm TFAIL "set general group2's memory_migrate failed."
@@ -684,7 +684,7 @@ test17() echo $testtid > "$CPUSET/2/tasks" sleep 1 - echo 0 > "$CPUSET/1/mems" + echo 0 > "$CPUSET/1/${PREFIX}mems" sleep 1 /bin/kill -s SIGUSR2 $testpid sleep 1
@@ -734,7 +734,7 @@ test18() return 1 fi - echo 1 > "$CPUSET/1/memory_migrate" 2> $CPUSET_TMP/stderr + echo 1 > "$CPUSET/1/${PREFIX}memory_migrate" 2> $CPUSET_TMP/stderr if [ $? -ne 0 ]; then cpuset_log_error $CPUSET_TMP/stderr tst_resm TFAIL "set general group1's memory_migrate failed."
@@ -748,7 +748,7 @@ test18() return 1 fi - echo 1 > "$CPUSET/2/memory_migrate" 2> $CPUSET_TMP/stderr + echo 1 > "$CPUSET/2/${PREFIX}memory_migrate" 2> $CPUSET_TMP/stderr if [ $? -ne 0 ]; then cpuset_log_error $CPUSET_TMP/stderr tst_resm TFAIL "set general group2's memory_migrate failed."
@@ -766,7 +766,7 @@ test18() echo $testtid > "$CPUSET/2/tasks" sleep 1 - echo 0 > "$CPUSET/1/mems" + echo 0 > "$CPUSET/1/${PREFIX}mems" sleep 1 /bin/kill -s SIGUSR2 $testpid sleep 1
testcases/kernel/controllers/cpuset/cpuset_syscall_test/cpuset_syscall_testset.sh +4 -4
@@ -57,14 +57,14 @@ do_syscall_test() tst_resm TFAIL "mkdir -p $TEST_CPUSET fail." return 1 fi - echo "$1" > "$TEST_CPUSET/cpus" + echo "$1" > "$TEST_CPUSET/${PREFIX}cpus" if [ $? -ne 0 ]; then - tst_resm TFAIL "set $TEST_CPUSET/cpus as $1 fail." + tst_resm TFAIL "set $TEST_CPUSET/${PREFIX}cpus as $1 fail." return 1 fi - echo "$2" > "$TEST_CPUSET/mems" + echo "$2" > "$TEST_CPUSET/${PREFIX}mems" if [ $? -ne 0 ]; then - tst_resm TFAIL "set $TEST_CPUSET/mems as $2 fail." + tst_resm TFAIL "set $TEST_CPUSET/${PREFIX}mems as $2 fail." return 1 fi cpuset_syscall_test $3 >"$TEST_OUTPUT" &
Signature · 1 line
2.13.5