summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorViresh Kumar <viresh.kumar@linaro.org>2014-06-30 13:57:16 +0530
committerViresh Kumar <viresh.kumar@linaro.org>2014-07-02 11:18:00 +0530
commitd76f7f4cd9391349b71532cdf03a38ba38d75eab (patch)
tree8850ff654909ee296b8a52593ce42c1a546fc4a5
parentcbcf3c51ca381b9bd8a8afe81469b23ebac31b32 (diff)
is-cpu-isolated: Move routines around
Just for better readability. Change-Id: I59da04d24519c2fa50ca5dc19636256c7ed2d50d Signed-off-by: Viresh Kumar <viresh.kumar@linaro.org>
-rwxr-xr-xcommon/scripts/is-cpu-isolated.sh104
1 files changed, 53 insertions, 51 deletions
diff --git a/common/scripts/is-cpu-isolated.sh b/common/scripts/is-cpu-isolated.sh
index e5458b0..4e90279 100755
--- a/common/scripts/is-cpu-isolated.sh
+++ b/common/scripts/is-cpu-isolated.sh
@@ -16,17 +16,6 @@ STRESS_DURATION=5000
NON_ISOL_CPUS="0" #CPU not to isolate, zero will always be there as we can't stop ticks on boot CPU.
RESULT="PASS"
-if [ "$1" = "-h" -o "$1" = "--help" ]; then
- echo "Usage: $0 <CPU to isolate (default 1)> <number of samples to take (default 1)> <Min Isolation Time Expected in seconds (default 10)>"
- exit
-fi
-
-# Parse parameters
-[ $1 ] && ISOL_CPU=$1
-[ $2 ] && SAMPLE_COUNT=$2
-[ $3 ] && MIN_ISOLATION=$3
-
-
# ROUTINES
debug_script=1
isdebug() {
@@ -35,6 +24,46 @@ isdebug() {
fi
}
+# Calls routine $1 for each Isolated CPU with parameter CPU-number
+for_each_isol_cpu() {
+ for i in `echo $ISOL_CPU | sed 's/,/ /g'`; do
+ $1 $i
+ done
+}
+
+# Get rid of cpufreq-timer activities, pass CPU number in $1
+cpufreq_fix_governor() {
+ # Remove governor's background timers, i.e. use performance governor
+ if [ -d /sys/devices/system/cpu/cpu$1/cpufreq ]; then
+ echo performance > /sys/devices/system/cpu/cpu$1/cpufreq/scaling_governor
+ fi
+}
+
+# dump all interrupts on standard output
+dump_interrupts() {
+ [ ! $1 ] && printf "\nInitial dump of /proc/interrupts\n"
+ [ $1 ] && printf "\n\nInterrupted: new dump of /proc/interrupts\n"
+ echo "----------------------------------------------"
+
+ cat /proc/interrupts
+ printf "\n\n"
+}
+
+# update list of all non-ISOL CPUs
+update_non_isol_cpus() {
+ total_cpus=`nproc --all --ignore=1` #ignore CPU 0 as we already have that
+ cpu=1
+
+ while [ $cpu -le $total_cpus ]
+ do
+ [ $cpu != $ISOL_CPU ] && NON_ISOL_CPUS="$NON_ISOL_CPUS,$cpu"
+ let cpu=cpu+1
+ done
+
+ isdebug echo "Isolate: CPU "$ISOL_CPU" and leave others: "$NON_ISOL_CPUS
+ isdebug echo ""
+}
+
# Find total number of interrupts for
# - one CPU, pass cpu number as parameter
# - all CPUs, pass "ALL" as parameter
@@ -80,37 +109,6 @@ total_interrupts() {
' /proc/interrupts
}
-# update list of all non-ISOL CPUs
-update_non_isol_cpus() {
- total_cpus=`nproc --all --ignore=1` #ignore CPU 0 as we already have that
- cpu=1
-
- while [ $cpu -le $total_cpus ]
- do
- [ $cpu != $ISOL_CPU ] && NON_ISOL_CPUS="$NON_ISOL_CPUS,$cpu"
- let cpu=cpu+1
- done
-
- isdebug echo "Isolate: CPU "$ISOL_CPU" and leave others: "$NON_ISOL_CPUS
- isdebug echo ""
-}
-
-# Get rid of cpufreq-timer activities, pass CPU number in $1
-cpufreq_fix_governor() {
- # Remove governor's background timers, i.e. use performance governor
- if [ -d /sys/devices/system/cpu/cpu$1/cpufreq ]; then
- echo performance > /sys/devices/system/cpu/cpu$1/cpufreq/scaling_governor
- fi
-}
-
-# Calls routine $1 for each Isolated CPU with parameter CPU-number
-for_each_isol_cpu() {
- for i in `echo $ISOL_CPU | sed 's/,/ /g'`; do
- $1 $i
- done
-}
-
-
# Update sysfs tunables to isolate CPU
update_sysfs_tunables() {
# Call cpufreq_fix_governor for each isolated CPU
@@ -233,14 +231,6 @@ isolate_cpu() {
done
}
-dump_interrupts() {
- [ ! $1 ] && printf "\n\nInitial dump of /proc/interrupts\n"
- [ $1 ] && printf "\n\nInterrupted: new dump of /proc/interrupts\n"
-
- cat /proc/interrupts
- printf "\n\n"
-}
-
# routine to get CPU isolation time
get_isolation_duration() {
isdebug echo ""
@@ -377,7 +367,19 @@ clear_cpusets() {
rmdir /dev/cpuset/dplane
}
-# tests to run
+# Check validity of arguments
+if [ "$1" = "-h" -o "$1" = "--help" ]; then
+ echo "Usage: $0 <CPU to isolate (default 1)> <number of samples to take (default 1)> <Min Isolation Time Expected in seconds (default 10)>"
+ exit
+fi
+
+# Parse arguments
+[ $1 ] && ISOL_CPU=$1
+[ $2 ] && SAMPLE_COUNT=$2
+[ $3 ] && MIN_ISOLATION=$3
+
+
+# Run tests
if [ $4 ]; then
if [ $4 -eq 1 ]; then
isolate_cpu