diff options
author | Santosh Shukla <santosh.shukla@linaro.org> | 2014-08-19 21:52:57 +0530 |
---|---|---|
committer | Viresh Kumar <viresh.kumar@linaro.org> | 2014-08-20 14:20:57 +0530 |
commit | e20acd7cbfb4d939a51e7e4bc012acd7f1dfe73b (patch) | |
tree | b46c8518d2af0367c47e3d790a7308d47ed402d3 /common | |
parent | 0cd22ef59ebd6d75aefd5c726612e5b43538b50d (diff) |
is-cpu-isolated.sh: use getopts for argument parsing
Currently argument list has to be passed in a specific order for it to work.
This isn't scalable as argument list grows. Lets parse arguments with getopts
instead to scale better.
New command format to test isolation.
./is-cpu-isolated.sh -hv -c <comma separated cpulist> -t <task_name> -f
<isolation_func_type> -s <sample count> -d <min isol duration>
By default <cpu=cpu1>, <task=stress>, <func_type=all>, <sample_count=1> and
<min isol duration =10>
Possible function types (-f)
1. isolate : Isolate core(s) for task
2. duration : Application isolation duration
3. clear : Clear cpuset rules used for step1
4. nonisol_list : Update list of all nonisol cpus
5. all : do step1,2,3
Examples :
1) run odp_isolation application on cpu no 1 and 2, function
type <isolation>
./is-cpu-isolated.sh -c 1,2 -t odp_isolation -f isolate
2) Get step1 isolate <duration>
./is-cpu-isolated.sh -c 1,2 -t odp_isolation -f duration
3) <clear> cpuset for step1
./is-cpu-isolated.sh -c 1,2 -t odp_isolation -f clear
4) "-f all" == do step1),2),3)
./is-cpu-isolated.sh -c 1,2 -t odp_isolation -f all
5) Update list of all nonisol cpus
./is-cpu-isolated.sh -c 1,2 -t odp_isolation -f nonisol_list
6) Running with no argument execute default
./is-cpu-isolated.sh
From now onwards is-cpu-isolated.sh script will run other isolation application
unlike default stress application.
Change-Id: Id9de13c1353cfc4e5f668a413c4ec666069e0b76
Signed-off-by: Santosh Shukla <santosh.shukla@linaro.org>
Acked-by: Viresh Kumar <viresh.kumar@linaro.org>
Not-Tested-by: Viresh Kumar <viresh.kumar@linaro.org>
Diffstat (limited to 'common')
-rwxr-xr-x | common/scripts/is-cpu-isolated.sh | 112 |
1 files changed, 84 insertions, 28 deletions
diff --git a/common/scripts/is-cpu-isolated.sh b/common/scripts/is-cpu-isolated.sh index d7dfb15..3c8d0b9 100755 --- a/common/scripts/is-cpu-isolated.sh +++ b/common/scripts/is-cpu-isolated.sh @@ -5,7 +5,7 @@ # This script is used for isolating $1 (comma separated list of CPUs) CPUs from # other kernel background activities. # -# This runs 'stress' test on the isolated CPUs and Figures out if CPUs are +# This runs task on the isolated CPUs and Figures out if CPUs are # isolated or not by reading 'cat /proc/interrupts' for all interrupts. # SCRIPT ARGUMENTS @@ -19,9 +19,11 @@ SAMPLE_COUNT=1 # How many samples to be taken MIN_ISOLATION=10 # Minimum isolation expected # Global variables -STRESS_DURATION=5000 # Run 'stress' for this duration +STRESS_DURATION=5000 # Run task 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" # Single threaded task to Run on Isolated CPUs +FUNC="all" # Perform complete isolation test by default RESULT="PASS" # Variables to keep an eye on total interrupt counts @@ -148,7 +150,7 @@ create_dplane_cpuset() { # Move shell to isolated CPU echo $$ > /dev/cpuset/dplane/cpu$1/tasks - # Start single cpu bound stress thread + # Start single cpu bound task stress -q --cpu 1 --timeout $STRESS_DURATION & # Move shell back to control plane CPU @@ -308,7 +310,7 @@ sense_infinite_isolation() { # process interrupts refresh_interrupts - ps h -C stress -o pid > /dev/null + ps h -C $TASK -o pid > /dev/null if [ $? != 0 ]; then T2="$(date +%s)" T=$(($T2-$T1)) @@ -395,8 +397,8 @@ clear_cpusets() { # Cleanup # - # kill all instances of stress - for i in `ps | grep stress | sed 's/^\ *//g' | cut -d' ' -f1`; + # kill all instances of task + for i in `ps | grep $TASK | sed 's/^\ *//g' | cut -d' ' -f1`; do kill -9 $i; done @@ -426,31 +428,85 @@ 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 - -# Parse arguments -[ $1 ] && ISOL_CPUS=$1 -[ $2 ] && SAMPLE_COUNT=$2 -[ $3 ] && MIN_ISOLATION=$3 +USAGE="Usage: $0 [-h] [-ctfsd args] [-c <Comma separated isol cpulist (default cpu1)>] [-t <Task name for isolation (default stress)>] [-f <Function type options - isolate, duration, clear, nonisol_list, all (default all)>] [-s <Number of samples to take (default 1)>] [-d <Min Isolation duration expected in seconds (default 10)>]" +# Run isolation test for $FUNC +run_func() +{ + isdebug echo "" + isdebug echo "Function type: $FUNC" -# Run tests -if [ $4 ]; then - if [ $4 -eq 1 ]; then + case "$FUNC" in + "isolate") isolate_cpu - elif [ $4 -eq 2 ]; then + ;; + + "duration") get_isolation_duration - elif [ $4 -eq 3 ]; then + ;; + + "clear") clear_cpusets - else + ;; + + "nonisol_list") update_non_isol_cpus - fi -else - isolate_cpu - get_isolation_duration - clear_cpusets -fi + ;; + + "all") + isolate_cpu + get_isolation_duration + clear_cpusets + ;; + + *) + echo "Invalid [-f] function type" + ;; + esac +} + +# Parse isol arguments +parse_arguments() +{ + while getopts hc:t:f:s:d: arguments 2>/dev/null + do + case $arguments in + h) # --help + echo "$USAGE" + exit 0 + ;; + + c) # --cpu (comma separated isol cpulist, default cpu1) + ISOL_CPUS=$OPTARG + ;; + + t) # --task (task to run, default stress) + TASK=$OPTARG + ;; + + f) # --func_type (Function to perform: Isolate, Duration, + # Clear, Nonisol_list, all. default all) + FUNC=$OPTARG + ;; + + s) # --sample_count (no of samples to take, default 1) + SAMPLE_COUNT=$OPTARG + ;; + + d) # --duration (min isolation time duration, default 10) + MIN_ISOLATION=$OPTARG + ;; + + \?) # getopts issues an error message + echo "$USAGE " + exit 1 + ;; + esac + done +} + +# Parse isol arguments +parse_arguments $@ + +# Run isolation test for requested functionality +run_func |