From e7b47612c950716644abb0bda1590af958eb5045 Mon Sep 17 00:00:00 2001 From: Viresh Kumar Date: Mon, 30 Jun 2014 13:57:16 +0530 Subject: is-cpu-isolated: Move routines around Just for better readability. Change-Id: I59da04d24519c2fa50ca5dc19636256c7ed2d50d Signed-off-by: Viresh Kumar --- common/scripts/is-cpu-isolated.sh | 104 +++++++++++++++++++------------------- 1 file 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 " - 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 " + 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 -- cgit v1.2.3