summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSantosh Shukla <santosh.shukla@linaro.org>2014-08-11 19:37:24 +0530
committersantosh shukla <santosh.shukla@linaro.org>2014-08-11 20:08:01 +0530
commit00d47ea9a538e3c36e93efa7b41f99566d0c06d0 (patch)
tree7dc66b9d0632f36707d2f651ff212b956ac1f0f6
parentcc16b6bda288a34a3a89d4989e90c72789b17503 (diff)
odp-on-isolated-cpu.sh : Initial script for odp isolationisol-v1
Tested for odp_isolation ./common/scripts/odp-on-isolated-cpu.sh 1,2 "odp_isolation -l 1,2" This script will use is-cpu-isolated.sh for cpu isolation, get_isolation_duration for odp application and clear the cpusets. Signed-off-by: Santosh Shukla <santosh.shukla@linaro.org>
-rwxr-xr-xcommon/scripts/odp-on-isolated-cpu.sh112
1 files changed, 112 insertions, 0 deletions
diff --git a/common/scripts/odp-on-isolated-cpu.sh b/common/scripts/odp-on-isolated-cpu.sh
new file mode 100755
index 0000000..c0b0d11
--- /dev/null
+++ b/common/scripts/odp-on-isolated-cpu.sh
@@ -0,0 +1,112 @@
+#!/bin/bash
+#
+# Author: Santosh Shukla <santosh.shukla@linaro.org>
+#
+# This script uses is-cpu-isolated.sh script (superset script) to isolate
+# a cpu or set of cpu (comma separated cpus list passed as arguement $1 to
+# this script, Migrate possible kernel background tasks to boot core or other
+# non-isolated cpus)
+#
+# We record odp app isolation time using is-cpu-isolated.sh script "duration" arguement.
+#
+# SCRIPT ARGUMENTS
+# $1: isolate cpu list comma separated
+# $2: Full odp_ command format look like
+# example
+#./common/scripts/odp-on-isolated-cpu.sh 1,2 "/home/santosh/my_project/odp/example/l2fwd/odp_l2fwd -i 0,2 -m 0 -c 2" &
+#./common/scripts/odp-on-isolated-cpu.sh 1,2 "/usr/local/bin/odp_isolation -l 1,2"
+#
+# note : it is assumed that odp_xxx bin copied to filesystem location /usr/local/bin
+#
+
+# Script arguments
+ISOL_CPUS=1 # comma separated isolated cpulist
+
+# Global Var
+ODP_APP=odp_isolation # odp test binary run default odp_isolation
+
+# Run odp thread on dplane core
+# argument - $1=odp thread_pid
+# $2=isol core
+run_odp_app() {
+
+ echo " cpu no "$2" and thd pid : "$1" "
+ cpu_mask=$2
+
+ # Move shell to isolated CPU
+ echo $1 > /dev/cpuset/dplane/cpu$cpu_mask/tasks
+}
+
+
+# Create odp setup
+odp_create_setup() {
+ # parse odp_ string and store them in variable
+ parsed=$(echo $ODP_APP | sed 's/*.,//g' | cut -d " " -f 2-)
+
+ # get actual binary name out from big parsed string
+ ODP_APP=`echo $parsed | cut -f1 -d " "`
+
+ # Isolate cpu
+ $(pwd)/common/scripts/is-cpu-isolated.sh -c 1,2 -t $ODP_APP -f "isolate"
+
+ #echo " "$ODP_APP" :: "$ISOL_CPUS" "
+
+ # Run odp application
+ $parsed &
+
+
+ # retreive main odp process list in proc_pid var
+ proc_pid=$!
+
+ echo "$poc_pid"
+
+ # move main odp process to boot core
+ taskset -p 1 $proc_pid
+
+ # list odp thread pid in var thd_pid_list
+ thd_pid_list=$(ls /proc/$proc_pid/task | grep -v $proc_pid)
+
+ echo $thd_pid_list
+
+ # fill odp threads pid into arr[]
+ k=0
+ for i in `echo $thd_pid_list | sed 's/ / /g'`; do
+ arr[k]=$i;
+ let k++
+ done
+
+ k=0
+ for i in `echo $ISOL_CPUS | sed 's/,/ /g'`; do
+ run_odp_app ${arr[$k]} $i
+ let k++
+ done
+
+ echo " Data plane application running duration "
+ $(pwd)/common/scripts/is-cpu-isolated.sh -c 1,2 -t $ODP_APP -f "duration"
+
+ echo " Data plane application clear cpuset "
+ $(pwd)/common/scripts/is-cpu-isolated.sh -c 1,2 -t $ODP_APP -f "clear"
+}
+
+# Parse argument
+[ $1 ] && ISOL_CPUS=$1
+
+# odp_* binary complete comand
+ODP_APP=$@
+
+## Check validity of arguments
+USAGE="Usage: $0 <CPUs to isolate (default 1), comma separated list> <odp_* binary full command in double quote>"
+
+if [ "$1" = "-h" -o "$1" = "--help" ]; then
+ echo $USAGE >&2
+ exit 0
+fi
+
+if [ $# -eq 0 ]; then
+ echo $USAGE >&2
+ exit 0
+fi
+
+odp_create_setup
+
+