diff options
author | Santosh Shukla <santosh.shukla@linaro.org> | 2014-08-11 14:53:33 +0530 |
---|---|---|
committer | santosh shukla <santosh.shukla@linaro.org> | 2014-08-11 15:29:11 +0530 |
commit | 4cf7f53be863053a65516f513ca07e8e76b7d423 (patch) | |
tree | 7008b6670793d8365012f8400d0aa7927014bdf6 | |
parent | d3503d5700c811260599ef70adfa2f9cfa120ddb (diff) |
is-isolate-cpu.sh : use getopts for agruement parsing
As arguement list will increase so use getopts for
argument parsing.
User to use below command to run task on isolated cpu:
./is-isolated-cpu.sh -c <comma separated cpulist> -t <task_name>
-f <isolation_func_type>
example
1) run odp_isolation application on cpu no 1 and 2, function
type <isolation>
./is-isolated-cpu.sh -c 1,2 -t odp_isolation -f isolate
2) Get step1 isolation duration
./is-isolated-cpu.sh -c 1,2 -t odp_isolation -f duration
3) clear cpuset for step1
./is-isolated-cpu.sh -c 1,2 -t odp_isolation -f clear
4) "-f all" == do step1),2),3)
./is-isolated-cpu.sh -c 1,2 -t odp_isolation -f all
By defauly Task_name = stress and minimum_isolation_duration
=10, sample_count=1
User can pass -s, -d option to configure min_isol_duration
and sample count from cmdline.
This patch support default option i.e. no need to pass
task name or sample count or min isol duration..
./is-isolate-cpu.sh -c 1,2 -f all
From nowonwards is-isolate-cpu script will run other isolation
application unlike default stress application. A step to make
isolation script more generic.
Signed-off-by: Santosh Shukla <santosh.shukla@linaro.org>
-rwxr-xr-x | common/scripts/is-cpu-isolated.sh | 125 |
1 files changed, 101 insertions, 24 deletions
diff --git a/common/scripts/is-cpu-isolated.sh b/common/scripts/is-cpu-isolated.sh index d7dfb15..f7a4efe 100755 --- a/common/scripts/is-cpu-isolated.sh +++ b/common/scripts/is-cpu-isolated.sh @@ -22,8 +22,12 @@ MIN_ISOLATION=10 # Minimum isolation expected STRESS_DURATION=5000 # Run 'stress' for this duration NON_ISOL_CPUS="0" # CPU not to isolate, zero will always be there as we can't stop ticks on boot CPU. DEBUG_SCRIPT=1 # Print debug messages, set 0 if not required +TASK=stress # default task to run for isolation duration +FUNC="all" # run TASK for all function includes isolation, duration and clear cpuset +SCRIPT_VERSION=1.0 # To track release version RESULT="PASS" + # Variables to keep an eye on total interrupt counts old_count=0 new_count=0 @@ -149,7 +153,8 @@ create_dplane_cpuset() { echo $$ > /dev/cpuset/dplane/cpu$1/tasks # Start single cpu bound stress thread - stress -q --cpu 1 --timeout $STRESS_DURATION & + echo "$TASK" + $TASK -q --cpu 1 --timeout $STRESS_DURATION & # Move shell back to control plane CPU echo $$ > /dev/cpuset/cplane/tasks @@ -308,7 +313,8 @@ sense_infinite_isolation() { # process interrupts refresh_interrupts - ps h -C stress -o pid > /dev/null + echo "$TASK" + ps h -C $TASK -o pid > /dev/null if [ $? != 0 ]; then T2="$(date +%s)" T=$(($T2-$T1)) @@ -396,7 +402,8 @@ clear_cpusets() { # # kill all instances of stress - for i in `ps | grep stress | sed 's/^\ *//g' | cut -d' ' -f1`; + echo "$TASK" + for i in `ps | grep $TASK | sed 's/^\ *//g' | cut -d' ' -f1`; do kill -9 $i; done @@ -426,31 +433,101 @@ clear_cpusets() { # Execution starts from HERE -# Check validity of arguments -if [ "$1" = "-h" -o "$1" = "--help" ]; then - echo "Usage: $0 <CPUs to isolate (default 1), comma separated list> <number of samples to take (default 1)> <Min Isolation Time Expected in seconds (default 10)>" - exit -fi +USAGE="Usage: filename $0 [-hv] [-ctfsd args] [-c <comma separated isol cpulist>] [-t <task name>] [-f <function type>] [s <number of samples to take (default 1)>] [d <Min Isolation duration Expected in seconds (default 10)>]" + +# Run isolation test for $1 (function_type) +run_func() +{ + echo $TASK + echo "Function type :" + case $1 in + "isolate") + echo " isolate_cpu" + isolate_cpu + ;; -# Parse arguments -[ $1 ] && ISOL_CPUS=$1 -[ $2 ] && SAMPLE_COUNT=$2 -[ $3 ] && MIN_ISOLATION=$3 + "duration") + echo " get_isolation_duration" + get_isolation_duration + ;; + + "clear") + echo " clear_cpusets" + clear_cpusets + ;; + "nonisol_list") + echo " update_non_isol_cpus" + update_non_isol_cpus + ;; -# Run tests -if [ $4 ]; then - if [ $4 -eq 1 ]; then + "all") + echo " all" + echo " isolate_cpu" + echo " get_isolation_duration" + echo " clear_cpusets" isolate_cpu - elif [ $4 -eq 2 ]; then get_isolation_duration - elif [ $4 -eq 3 ]; then clear_cpusets - else - update_non_isol_cpus - fi -else - isolate_cpu - get_isolation_duration - clear_cpusets + ;; + + *) + echo "Invalid [-f] function type" + return 0 + ;; + esac + + return 1 +} + + +# Parse argument +while getopts hvc:t:f:s:d: arguments 2>/dev/null +do + case $arguments in + h) # help + echo "$USAGE" + exit 0;; + + v) # script version + echo "filename $0 version $SCRIPT_VERSION" + exit 0;; + + c) # --cpu (comma separated isolated cpu) + ISOL_CPUS=$OPTARG + echo "iso cpulist $ISOL_CPUS.";; + + t) # --task (task to run) + TASK=$OPTARG + echo "task to run $TASK on isol cpus";; + + f) # --func_type (type of function to perform on binary out of 4 listed + # function, isolation, get_isolation, clear_cpuset) + FUNC=$OPTARG + + run_func $FUNC + ;; + + s) # --sample_count (no of samples to take default 1) + SAMPLE_COUNT=$OPTARG + echo "sample count $SAMPLE_COUNT.";; + + d) # --duration (min isolation time duration default 10) + MIN_ISOLATION==$OPTARG + echo "minimum isolation duration $MIN_ISOLATION=.";; + + \?) # getopts issues an error message + echo "$USAGE " + exit 1;; + + esac +done + + +## Check validity of arguments +#echo "the number of argument passed was $(( $OPTIND -1 ))" +if [ $# -eq 0 ]; then + echo $USAGE >&2 + exit 0 fi + |