summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorViresh Kumar <viresh.kumar@linaro.org>2014-04-24 11:09:36 +0530
committerViresh Kumar <viresh.kumar@linaro.org>2014-07-02 11:18:00 +0530
commit807edea3ceeda3f9342c556e4746686613362c31 (patch)
tree3182396234d296808bdea2cfa279b42f58d39ae8
parent57270414bb4d1b218fe14862b96b68ebf24e21b8 (diff)
is-cpu-isolated.sh: arrange routines in the order they are called
Just for readability. Change-Id: Idfbd4acc853038d108244a3ca79c73096350bc8c Signed-off-by: Viresh Kumar <viresh.kumar@linaro.org>
-rwxr-xr-xcommon/scripts/is-cpu-isolated.sh195
1 files changed, 98 insertions, 97 deletions
diff --git a/common/scripts/is-cpu-isolated.sh b/common/scripts/is-cpu-isolated.sh
index a78e76d..204b547 100755
--- a/common/scripts/is-cpu-isolated.sh
+++ b/common/scripts/is-cpu-isolated.sh
@@ -33,6 +33,104 @@ get_tick_count() { cat /proc/interrupts | grep arch_timer | grep 30 | sed 's/\s\
#For testing script on: x86
#get_tick_count() { cat /proc/interrupts | grep NMI | sed 's/\s\+/ /g' | cut -d' ' -f4 ; }
+# routine to isolate a CPU
+isolate_cpu1() {
+ isdebug echo ""
+ isdebug echo "Started Isolating CPUs - via CPUSETS"
+ isdebug echo "------------------------------------"
+ isdebug echo ""
+
+ # Check that we have cpusets enabled in the kernel
+ if ! grep -q -s cpuset /proc/filesystems ; then
+ echo "Error: Kernel is lacking support for cpuset!"
+ exit 1
+ fi
+
+ # Try to disable sched_tick_max_deferment
+ if [ -d /sys/kernel/debug -a -f /sys/kernel/debug/sched_tick_max_deferment ]; then
+ echo -1 > /sys/kernel/debug/sched_tick_max_deferment
+ echo "sched_tick_max_deferment set to:" `cat /sys/kernel/debug/sched_tick_max_deferment`
+ else
+ sysctl -e kernel.sched_tick_max_deferment=-1
+
+ fi
+
+ # Delay the annoying vmstat timer far away (in seconds)
+ sysctl vm.stat_interval=1000
+
+ # Delay the annoying vmstat timer far away (in centiseconds)
+ sysctl vm.dirty_writeback_centisecs=100000
+
+ # Delay the annoying vmstat timer far away (in centiseconds)
+ sysctl vm.dirty_expire_centisecs=100000
+
+ # Shutdown nmi watchdog as it uses perf events
+ sysctl -w kernel.watchdog=0
+
+ # Move bdi writeback workqueues to CPU0
+ echo 1 > /sys/bus/workqueue/devices/writeback/cpumask
+
+ # make sure that the /dev/cpuset dir exits
+ # and mount the cpuset filesystem if needed
+ [ -d /dev/cpuset ] || mkdir /dev/cpuset
+ mount | grep /dev/cpuset > /dev/null || mount -t cpuset none /dev/cpuset
+
+ # Create 2 cpusets. One GP and one NOHZ domain.
+ [ -d /dev/cpuset/gp ] || mkdir /dev/cpuset/gp
+ [ -d /dev/cpuset/rt ] || mkdir /dev/cpuset/rt
+
+ # Setup the GP domain: CPU0
+ echo 0 > /dev/cpuset/gp/mems
+ echo 0 > /dev/cpuset/gp/cpus
+
+ # Setup the NOHZ domain: CPU1
+ echo 0 > /dev/cpuset/rt/mems
+ echo 1 > /dev/cpuset/rt/cpus
+
+ # Try to move all processes in top set to the GP set.
+ for pid in `cat /dev/cpuset/tasks`; do
+ if [ -d /proc/$pid ]; then
+ echo $pid > /dev/cpuset/gp/tasks 2>/dev/null
+ if [ $? != 0 ]; then
+ isdebug echo -n "Cannot move PID $pid: "
+ isdebug echo "$(cat /proc/$pid/status | grep ^Name | cut -f2)"
+ fi
+ fi
+ done
+
+ # Disable load balancing on top level (otherwise the child-sets' setting
+ # won't take effect.)
+ echo 0 > /dev/cpuset/sched_load_balance
+
+ # Enable load balancing withing the GP domain
+ echo 1 > /dev/cpuset/gp/sched_load_balance
+
+ # But disallow load balancing within the NOHZ domain
+ echo 0 > /dev/cpuset/rt/sched_load_balance
+
+ # Quiesce CPU: i.e. migrate timers/hrtimers away
+ echo 1 > /dev/cpuset/rt/quiesce
+
+ stress -q --cpu 1 --timeout $STRESS_DURATION &
+
+ # Restart CPU1 to migrate all tasks to CPU0
+ echo 0 > /sys/devices/system/cpu/cpu1/online
+ echo 1 > /sys/devices/system/cpu/cpu1/online
+
+ # Setup the NOHZ domain again: CPU1
+ echo 0 > /dev/cpuset/rt/mems
+ echo 1 > /dev/cpuset/rt/cpus
+
+ # Try to move all processes in top set to the GP set.
+ for pid in `ps h -C stress -o pid`; do
+ echo $pid > /dev/cpuset/rt/tasks 2>/dev/null
+ if [ $? != 0 ]; then
+ isdebug echo -n "RT: Cannot move PID $pid: "
+ isdebug echo "$(cat /proc/$pid/status | grep ^Name | cut -f2)"
+ fi
+ done
+}
+
# routine to get CPU isolation time
get_isolation_duration() {
isdebug echo ""
@@ -131,103 +229,6 @@ get_isolation_duration() {
isdebug echo ""
}
-isolate_cpu1() {
- isdebug echo ""
- isdebug echo "Started Isolating CPUs - via CPUSETS"
- isdebug echo "------------------------------------"
- isdebug echo ""
-
- # Check that we have cpusets enabled in the kernel
- if ! grep -q -s cpuset /proc/filesystems ; then
- echo "Error: Kernel is lacking support for cpuset!"
- exit 1
- fi
-
- # Try to disable sched_tick_max_deferment
- if [ -d /sys/kernel/debug -a -f /sys/kernel/debug/sched_tick_max_deferment ]; then
- echo -1 > /sys/kernel/debug/sched_tick_max_deferment
- echo "sched_tick_max_deferment set to:" `cat /sys/kernel/debug/sched_tick_max_deferment`
- else
- sysctl -e kernel.sched_tick_max_deferment=-1
-
- fi
-
- # Delay the annoying vmstat timer far away (in seconds)
- sysctl vm.stat_interval=1000
-
- # Delay the annoying vmstat timer far away (in centiseconds)
- sysctl vm.dirty_writeback_centisecs=100000
-
- # Delay the annoying vmstat timer far away (in centiseconds)
- sysctl vm.dirty_expire_centisecs=100000
-
- # Shutdown nmi watchdog as it uses perf events
- sysctl -w kernel.watchdog=0
-
- # Move bdi writeback workqueues to CPU0
- echo 1 > /sys/bus/workqueue/devices/writeback/cpumask
-
- # make sure that the /dev/cpuset dir exits
- # and mount the cpuset filesystem if needed
- [ -d /dev/cpuset ] || mkdir /dev/cpuset
- mount | grep /dev/cpuset > /dev/null || mount -t cpuset none /dev/cpuset
-
- # Create 2 cpusets. One GP and one NOHZ domain.
- [ -d /dev/cpuset/gp ] || mkdir /dev/cpuset/gp
- [ -d /dev/cpuset/rt ] || mkdir /dev/cpuset/rt
-
- # Setup the GP domain: CPU0
- echo 0 > /dev/cpuset/gp/mems
- echo 0 > /dev/cpuset/gp/cpus
-
- # Setup the NOHZ domain: CPU1
- echo 0 > /dev/cpuset/rt/mems
- echo 1 > /dev/cpuset/rt/cpus
-
- # Try to move all processes in top set to the GP set.
- for pid in `cat /dev/cpuset/tasks`; do
- if [ -d /proc/$pid ]; then
- echo $pid > /dev/cpuset/gp/tasks 2>/dev/null
- if [ $? != 0 ]; then
- isdebug echo -n "Cannot move PID $pid: "
- isdebug echo "$(cat /proc/$pid/status | grep ^Name | cut -f2)"
- fi
- fi
- done
-
- # Disable load balancing on top level (otherwise the child-sets' setting
- # won't take effect.)
- echo 0 > /dev/cpuset/sched_load_balance
-
- # Enable load balancing withing the GP domain
- echo 1 > /dev/cpuset/gp/sched_load_balance
-
- # But disallow load balancing within the NOHZ domain
- echo 0 > /dev/cpuset/rt/sched_load_balance
-
- # Quiesce CPU: i.e. migrate timers/hrtimers away
- echo 1 > /dev/cpuset/rt/quiesce
-
- stress -q --cpu 1 --timeout $STRESS_DURATION &
-
- # Restart CPU1 to migrate all tasks to CPU0
- echo 0 > /sys/devices/system/cpu/cpu1/online
- echo 1 > /sys/devices/system/cpu/cpu1/online
-
- # Setup the NOHZ domain again: CPU1
- echo 0 > /dev/cpuset/rt/mems
- echo 1 > /dev/cpuset/rt/cpus
-
- # Try to move all processes in top set to the GP set.
- for pid in `ps h -C stress -o pid`; do
- echo $pid > /dev/cpuset/rt/tasks 2>/dev/null
- if [ $? != 0 ]; then
- isdebug echo -n "RT: Cannot move PID $pid: "
- isdebug echo "$(cat /proc/$pid/status | grep ^Name | cut -f2)"
- fi
- done
-}
-
clear_cpusets() {
isdebug echo ""
isdebug echo "Started cleaning CPUSETS"