From: Xunlei Pang pang.xunlei@linaro.org
DVFS adds a latency in the execution of task because of the time to decide to move at max freq. We need to measure this latency and check that the governor stays in an acceptable range.
When workgen runs a json file, a log file is created for each thread. This log file records the number of loop that has been executed and the duration for executing these loops (per phase). We can use these figures to evaluate to latency that is added by a cpufreq governor and its "performance efficiency".
We use the run+sleep patten to do the measurement, for the run time per loop, the performance governor should run the expected duration as the CPU stays a max freq. At the opposite, the powersave governor will give use the longest duration (as it stays at lowest OPP). Other governor will be somewhere between the 2 previous duration as they will use several OPP and will go back to max frequency after a defined duration which depends on its monitoring period.
The formula:
duration of powersave gov - duration of the gov -------------------------------------------------------- x 100% duration of powersave gov - duration of performance gov
will give the efficiency of the governor. 100% means as efficient as the perf governor and 0% means as efficient as the powersave governor.
This patch offers json files and shell scripts to do the measurement,
Usage: ./test.sh <cpus> <runtime> <sleeptime> cpus: number of cpus in the CPU0's frequency domain runtime: running time in ms per loop of the workload pattern sleeptime: sleeping time in ms per loop of the workload patten
Example: "./test.sh 4 100 1000" means CPU0~CPU3 sharing frequency, "100ms run + 1000ms sleep" workload pattern.
test result on my machine: ~#./test.sh 4 100 1000 Frequency domain CPU0~CPU3, run 100ms, sleep 1000ms: conservative efficiency: 28% ondemand efficiency: 95%
NOTE: Make sure there are "sed", "cut", "grep", "rt-app" tools on your test machine, and run the script under root privilege.
Signed-off-by: Xunlei Pang pang.xunlei@linaro.org --- .../cpufreq_governor_efficiency/calibration.json | 27 ++++++++ .../cpufreq_governor_efficiency/calibration.sh | 9 +++ doc/examples/cpufreq_governor_efficiency/dvfs.json | 27 ++++++++ doc/examples/cpufreq_governor_efficiency/dvfs.sh | 38 ++++++++++++ doc/examples/cpufreq_governor_efficiency/test.sh | 71 ++++++++++++++++++++++ 5 files changed, 172 insertions(+) create mode 100644 doc/examples/cpufreq_governor_efficiency/calibration.json create mode 100755 doc/examples/cpufreq_governor_efficiency/calibration.sh create mode 100644 doc/examples/cpufreq_governor_efficiency/dvfs.json create mode 100755 doc/examples/cpufreq_governor_efficiency/dvfs.sh create mode 100755 doc/examples/cpufreq_governor_efficiency/test.sh
diff --git a/doc/examples/cpufreq_governor_efficiency/calibration.json b/doc/examples/cpufreq_governor_efficiency/calibration.json new file mode 100644 index 0000000..4377990 --- /dev/null +++ b/doc/examples/cpufreq_governor_efficiency/calibration.json @@ -0,0 +1,27 @@ +{ + "tasks" : { + "thread" : { + "instance" : 1, + "cpus" : [0], + "loop" : 1, + "phases" : { + "run" : { + "loop" : 1, + "run" : 200000, + }, + "sleep" : { + "loop" : 1, + "sleep" : 200000, + } + } + } + }, + "global" : { + "default_policy" : "SCHED_FIFO", + "calibration" : "CPU0", + "lock_pages" : true, + "ftrace" : true, + "logdir" : "./", + } +} + diff --git a/doc/examples/cpufreq_governor_efficiency/calibration.sh b/doc/examples/cpufreq_governor_efficiency/calibration.sh new file mode 100755 index 0000000..89fe5de --- /dev/null +++ b/doc/examples/cpufreq_governor_efficiency/calibration.sh @@ -0,0 +1,9 @@ +# !/bin/bash + +echo performance > /sys/devices/system/cpu/cpu0/cpufreq/scaling_governor + +sleep 1 + +pLoad=`rt-app calibration.json 2>&1 |grep pLoad |sed 's/.*= (.*)ns.*/\1/'` +sed 's/"calibration" : .*,/"calibration" : '$pLoad',/' -i dvfs.json + diff --git a/doc/examples/cpufreq_governor_efficiency/dvfs.json b/doc/examples/cpufreq_governor_efficiency/dvfs.json new file mode 100644 index 0000000..b413156 --- /dev/null +++ b/doc/examples/cpufreq_governor_efficiency/dvfs.json @@ -0,0 +1,27 @@ +{ + "tasks" : { + "thread" : { + "instance" : 1, + "cpus" : [0], + "loop" : 5, + "phases" : { + "running" : { + "loop" : 1, + "run" : 100000, + }, + "sleeping" : { + "loop" : 1, + "sleep" : 1000000, + } + } + } + }, + "global" : { + "default_policy" : "SCHED_OTHER", + "calibration" : 90, + "lock_pages" : true, + "ftrace" : true, + "logdir" : "./", + } +} + diff --git a/doc/examples/cpufreq_governor_efficiency/dvfs.sh b/doc/examples/cpufreq_governor_efficiency/dvfs.sh new file mode 100755 index 0000000..1772041 --- /dev/null +++ b/doc/examples/cpufreq_governor_efficiency/dvfs.sh @@ -0,0 +1,38 @@ +# !/bin/bash + +#echo $1 $2 $3 + +if [ $1 ] && [ $2 ] ; then + for i in `seq 0 1 $[$2-1]` + do + echo $1 > /sys/devices/system/cpu/cpu$i/cpufreq/scaling_governor + #cat /sys/devices/system/cpu/cpu$i/cpufreq/scaling_governor + done + + sleep 3 +fi + +if [ $3 ] ; then + sed 's/"run" : .*,/"run" : '$3',/' -i dvfs.json +fi + +if [ $4 ] ; then + sed 's/"sleep" : .*,/"sleep" : '$4',/' -i dvfs.json +fi + +#cat dvfs.json + +rt-app dvfs.json 2> /dev/null + +if [ $1 ] ; then + mv rt-app-thread-0.log rt-app_$1_run$3us_sleep$4us.log + + declare -i sum + sum=0 + for i in `cat rt-app_$1_run$3us_sleep$4us.log | sed '1~2!d' | sed '1d' |cut -d " " -f 3`; + do sum=sum+$i + done + sum=sum/5 + echo $sum +fi + diff --git a/doc/examples/cpufreq_governor_efficiency/test.sh b/doc/examples/cpufreq_governor_efficiency/test.sh new file mode 100755 index 0000000..6f41a1b --- /dev/null +++ b/doc/examples/cpufreq_governor_efficiency/test.sh @@ -0,0 +1,71 @@ +# !/bin/bash + +function set_calibration +{ + calibration.sh +} + +function test_efficiency +{ + declare -i performance + declare -i powersave + declare -i conservative + declare -i ondemand + declare -i denominator + declare -i numerator + + FILENAME="results_$RANDOM$$.txt" + + dvfs.sh performance $1 $2 $3> $FILENAME + dvfs.sh powersave $1 $2 $3 >> $FILENAME + dvfs.sh conservative $1 $2 $3 >> $FILENAME + dvfs.sh ondemand $1 $2 $3 >> $FILENAME + + performance=`cat $FILENAME |sed -n '1p'` + powersave=`cat $FILENAME |sed -n '2p'` + conservative=`cat $FILENAME |sed -n '3p'` + ondemand=`cat $FILENAME |sed -n '4p'` + + rm -f $FILENAME + + denominator=$powersave-$performance + numerator=($powersave-$conservative)*100 + + if [ $denominator -le 0 ] ; then + echo "Probably not input all the cpus in the same frequncy domain" + exit + fi + + if [ $numerator -lt 0 ] ; then + numerator=0 + fi + + conservative=$numerator/$denominator + echo "conservative efficiency: $conservative%" + + numerator=($powersave-$ondemand)*100 + if [ $numerator -lt 0 ] ; then + numerator=0 + fi + + ondemand=$numerator/$denominator + echo -e "ondemand efficiency: $ondemand%\n" +} + +if [ $# -lt 3 ]; then + echo "Usage: ./test.sh <cpus> <runtime> <sleeptime>" + echo "cpus: number of cpus in the CPU0's frequency domain" + echo "runtime: running time in ms per loop of the workload pattern" + echo "sleeptime: sleeping time in ms per loop of the workload patten" + echo -e "\nExample: \n"./test.sh 4 100 1000" means\nCPU0~CPU3 sharing frequency, "100ms run + 1000ms sleep" workload pattern.\n" + exit +fi + +echo "Frequency domain CPU0~CPU$[$1-1], run $2ms, sleep $3ms:" + +PATH=$PATH:. +set_calibration +test_efficiency $1 $[$2*1000] $[$3*1000] + +sleep 5 +
Hi Xunlei,
I can only comment on the syntax of your scripts and share the results after applying your patch. Other colleagues can give more useful feedback re: your calculations, but I still hope this helps. Comments are inline below.
Regards, Lisa
On 8 May 2015 at 07:55, Xunlei Pang xlpang@126.com wrote:
From: Xunlei Pang pang.xunlei@linaro.org
DVFS adds a latency in the execution of task because of the time to decide to move at max freq. We need to measure this latency and check that the governor stays in an acceptable range.
When workgen runs a json file, a log file is created for each thread. This log file records the number of loop that has been executed and the duration for executing these loops (per phase). We can use these figures to evaluate to latency that is added by a cpufreq governor and its "performance efficiency".
We use the run+sleep patten to do the measurement, for the run time per loop, the performance governor should run the expected duration as the CPU stays a max freq. At the opposite, the powersave governor will give use the longest duration (as it stays at lowest OPP). Other governor will be somewhere between the 2 previous duration as they will use several OPP and will go back to max frequency after a defined duration which depends on its monitoring period.
Nit: s/patten/pattern
The formula:
duration of powersave gov - duration of the gov
-------------------------------------------------------- x 100% duration of powersave gov - duration of performance gov
will give the efficiency of the governor. 100% means as efficient as the perf governor and 0% means as efficient as the powersave governor.
This patch offers json files and shell scripts to do the measurement,
Usage: ./test.sh <cpus> <runtime> <sleeptime> cpus: number of cpus in the CPU0's frequency domain runtime: running time in ms per loop of the workload pattern sleeptime: sleeping time in ms per loop of the workload patten
Example: "./test.sh 4 100 1000" means CPU0~CPU3 sharing frequency, "100ms run + 1000ms sleep" workload pattern.
test result on my machine: ~#./test.sh 4 100 1000 Frequency domain CPU0~CPU3, run 100ms, sleep 1000ms: conservative efficiency: 28% ondemand efficiency: 95%
NOTE: Make sure there are "sed", "cut", "grep", "rt-app" tools on your test machine, and run the script under root privilege.
Signed-off-by: Xunlei Pang pang.xunlei@linaro.org
.../cpufreq_governor_efficiency/calibration.json | 27 ++++++++ .../cpufreq_governor_efficiency/calibration.sh | 9 +++ doc/examples/cpufreq_governor_efficiency/dvfs.json | 27 ++++++++ doc/examples/cpufreq_governor_efficiency/dvfs.sh | 38 ++++++++++++ doc/examples/cpufreq_governor_efficiency/test.sh | 71 ++++++++++++++++++++++ 5 files changed, 172 insertions(+) create mode 100644 doc/examples/cpufreq_governor_efficiency/calibration.json create mode 100755 doc/examples/cpufreq_governor_efficiency/calibration.sh create mode 100644 doc/examples/cpufreq_governor_efficiency/dvfs.json create mode 100755 doc/examples/cpufreq_governor_efficiency/dvfs.sh create mode 100755 doc/examples/cpufreq_governor_efficiency/test.sh
diff --git a/doc/examples/cpufreq_governor_efficiency/calibration.json b/doc/examples/cpufreq_governor_efficiency/calibration.json new file mode 100644 index 0000000..4377990 --- /dev/null +++ b/doc/examples/cpufreq_governor_efficiency/calibration.json @@ -0,0 +1,27 @@ +{
"tasks" : {
"thread" : {
"instance" : 1,
"cpus" : [0],
"loop" : 1,
"phases" : {
"run" : {
"loop" : 1,
"run" : 200000,
},
"sleep" : {
"loop" : 1,
"sleep" : 200000,
}
}
}
},
"global" : {
"default_policy" : "SCHED_FIFO",
"calibration" : "CPU0",
"lock_pages" : true,
"ftrace" : true,
"logdir" : "./",
}
+}
diff --git a/doc/examples/cpufreq_governor_efficiency/calibration.sh b/doc/examples/cpufreq_governor_efficiency/calibration.sh new file mode 100755 index 0000000..89fe5de --- /dev/null +++ b/doc/examples/cpufreq_governor_efficiency/calibration.sh @@ -0,0 +1,9 @@ +# !/bin/bash
Remove the space between # and !. That was the cause of this error I encountered initially and took time to figure out:
~/repos/rt-app/doc/examples/cpufreq_governor_efficiency [master] $ sudo ./test.sh 4 100 1000 ./test.sh: 3: ./test.sh: function: not found ./test.sh: 5: ./test.sh: calibration.sh: not found ./test.sh: 8: ./test.sh: function: not found ./test.sh: 32: ./test.sh: Syntax error: "(" unexpected (expecting "}")
+echo performance > /sys/devices/system/cpu/cpu0/cpufreq/scaling_governor
+sleep 1
+pLoad=`rt-app calibration.json 2>&1 |grep pLoad |sed 's/.*= (.*)ns.*/\1/'` +sed 's/"calibration" : .*,/"calibration" : '$pLoad',/' -i dvfs.json
diff --git a/doc/examples/cpufreq_governor_efficiency/dvfs.json b/doc/examples/cpufreq_governor_efficiency/dvfs.json new file mode 100644 index 0000000..b413156 --- /dev/null +++ b/doc/examples/cpufreq_governor_efficiency/dvfs.json @@ -0,0 +1,27 @@ +{
"tasks" : {
"thread" : {
"instance" : 1,
"cpus" : [0],
"loop" : 5,
"phases" : {
"running" : {
"loop" : 1,
"run" : 100000,
},
"sleeping" : {
"loop" : 1,
"sleep" : 1000000,
}
}
}
},
"global" : {
"default_policy" : "SCHED_OTHER",
"calibration" : 90,
"lock_pages" : true,
"ftrace" : true,
"logdir" : "./",
}
+}
diff --git a/doc/examples/cpufreq_governor_efficiency/dvfs.sh b/doc/examples/cpufreq_governor_efficiency/dvfs.sh new file mode 100755 index 0000000..1772041 --- /dev/null +++ b/doc/examples/cpufreq_governor_efficiency/dvfs.sh @@ -0,0 +1,38 @@ +# !/bin/bash
Same interpreter issue here as I commented above.
+#echo $1 $2 $3
+if [ $1 ] && [ $2 ] ; then
- for i in `seq 0 1 $[$2-1]`
- do
echo $1 > /sys/devices/system/cpu/cpu$i/cpufreq/scaling_governor
#cat /sys/devices/system/cpu/cpu$i/cpufreq/scaling_governor
- done
- sleep 3
+fi
+if [ $3 ] ; then
- sed 's/"run" : .*,/"run" : '$3',/' -i dvfs.json
+fi
+if [ $4 ] ; then
- sed 's/"sleep" : .*,/"sleep" : '$4',/' -i dvfs.json
+fi
+#cat dvfs.json
+rt-app dvfs.json 2> /dev/null
+if [ $1 ] ; then
- mv rt-app-thread-0.log rt-app_$1_run$3us_sleep$4us.log
- declare -i sum
- sum=0
- for i in `cat rt-app_$1_run$3us_sleep$4us.log | sed '1~2!d' | sed '1d' |cut -d " " -f 3`;
- do sum=sum+$i
- done
- sum=sum/5
- echo $sum
+fi
diff --git a/doc/examples/cpufreq_governor_efficiency/test.sh b/doc/examples/cpufreq_governor_efficiency/test.sh new file mode 100755 index 0000000..6f41a1b --- /dev/null +++ b/doc/examples/cpufreq_governor_efficiency/test.sh @@ -0,0 +1,71 @@ +# !/bin/bash
Same as above.
+function set_calibration +{
- calibration.sh
+}
+function test_efficiency +{
- declare -i performance
- declare -i powersave
- declare -i conservative
- declare -i ondemand
- declare -i denominator
- declare -i numerator
- FILENAME="results_$RANDOM$$.txt"
- dvfs.sh performance $1 $2 $3> $FILENAME
- dvfs.sh powersave $1 $2 $3 >> $FILENAME
- dvfs.sh conservative $1 $2 $3 >> $FILENAME
- dvfs.sh ondemand $1 $2 $3 >> $FILENAME
- performance=`cat $FILENAME |sed -n '1p'`
- powersave=`cat $FILENAME |sed -n '2p'`
- conservative=`cat $FILENAME |sed -n '3p'`
- ondemand=`cat $FILENAME |sed -n '4p'`
- rm -f $FILENAME
- denominator=$powersave-$performance
- numerator=($powersave-$conservative)*100
- if [ $denominator -le 0 ] ; then
echo "Probably not input all the cpus in the same frequncy domain"
exit
- fi
- if [ $numerator -lt 0 ] ; then
numerator=0
- fi
- conservative=$numerator/$denominator
- echo "conservative efficiency: $conservative%"
- numerator=($powersave-$ondemand)*100
- if [ $numerator -lt 0 ] ; then
numerator=0
- fi
- ondemand=$numerator/$denominator
- echo -e "ondemand efficiency: $ondemand%\n"
+}
+if [ $# -lt 3 ]; then
- echo "Usage: ./test.sh <cpus> <runtime> <sleeptime>"
- echo "cpus: number of cpus in the CPU0's frequency domain"
- echo "runtime: running time in ms per loop of the workload pattern"
- echo "sleeptime: sleeping time in ms per loop of the workload patten"
- echo -e "\nExample: \n"./test.sh 4 100 1000" means\nCPU0~CPU3 sharing frequency, "100ms run + 1000ms sleep" workload pattern.\n"
- exit
+fi
+echo "Frequency domain CPU0~CPU$[$1-1], run $2ms, sleep $3ms:"
+PATH=$PATH:. +set_calibration +test_efficiency $1 $[$2*1000] $[$3*1000]
+sleep 5
-- 1.9.1
When I fixed the interpreter issue, I got the following output:
~/repos/rt-app/doc/examples/cpufreq_governor_efficiency [master] $ sudo ./test.sh 4 100 1000 Frequency domain CPU0~CPU3, run 100ms, sleep 1000ms: cut: the delimiter must be a single character Try 'cut --help' for more information. cut: the delimiter must be a single character Try 'cut --help' for more information. cut: the delimiter must be a single character Try 'cut --help' for more information. cut: the delimiter must be a single character Try 'cut --help' for more information. ./test.sh: line 32: ./calibration.json: Permission denied Probably not input all the cpus in the same frequncy domain
It seems to have a "problem" with the cut command, and I'm not sure what's the primary cause of the calibration.json permission denied error.
I enabled set -x to debug further, and saved the output in a link: http://hastebin.com/abotovuhov.md
Sched-tools mailing list Sched-tools@lists.linaro.org https://lists.linaro.org/mailman/listinfo/sched-tools
Hi Lisa,
"Sched-tools" sched-tools-bounces@lists.linaro.org wrote 2015-06-02 AM 06:53:30:
Re: [Sched-tools] [PATCH] [PATCH] measure the efficiency of cpufreq
governors
Hi Xunlei,
I can only comment on the syntax of your scripts and share the results after applying your patch. Other colleagues can give more useful feedback re: your calculations, but I still hope this helps. Comments are inline below.
Thanks for your reivew.
Regards, Lisa
On 8 May 2015 at 07:55, Xunlei Pang xlpang@126.com wrote:
From: Xunlei Pang pang.xunlei@linaro.org
DVFS adds a latency in the execution of task because of the time to decide to move at max freq. We need to measure this latency and check that the governor stays in an acceptable range.
When workgen runs a json file, a log file is created for each thread. This log file records the number of loop that has been executed and the duration for executing these loops (per phase). We can use these figures to evaluate to latency that is added by a cpufreq governor and its "performance efficiency".
We use the run+sleep patten to do the measurement, for the run time
per
loop, the performance governor should run the expected duration as the CPU stays a max freq. At the opposite, the powersave governor will
give
use the longest duration (as it stays at lowest OPP). Other governor
will
be somewhere between the 2 previous duration as they will use several
OPP
and will go back to max frequency after a defined duration which
depends
on its monitoring period.
Nit: s/patten/pattern
will do
The formula:
duration of powersave gov - duration of the gov
-------------------------------------------------------- x 100% duration of powersave gov - duration of performance gov
will give the efficiency of the governor. 100% means as efficient as the perf governor and 0% means as efficient as the powersave governor.
This patch offers json files and shell scripts to do the measurement,
Usage: ./test.sh <cpus> <runtime> <sleeptime> cpus: number of cpus in the CPU0's frequency domain runtime: running time in ms per loop of the workload pattern sleeptime: sleeping time in ms per loop of the workload patten
Example: "./test.sh 4 100 1000" means CPU0~CPU3 sharing frequency, "100ms run + 1000ms sleep" workload
pattern.
test result on my machine: ~#./test.sh 4 100 1000 Frequency domain CPU0~CPU3, run 100ms, sleep 1000ms: conservative efficiency: 28% ondemand efficiency: 95%
NOTE: Make sure there are "sed", "cut", "grep", "rt-app" tools on your
test
machine, and run the script under root privilege.
Signed-off-by: Xunlei Pang pang.xunlei@linaro.org
.../cpufreq_governor_efficiency/calibration.json | 27 ++++++++ .../cpufreq_governor_efficiency/calibration.sh | 9 +++ doc/examples/cpufreq_governor_efficiency/dvfs.json | 27 ++++++++ doc/examples/cpufreq_governor_efficiency/dvfs.sh | 38 ++++++++++++ doc/examples/cpufreq_governor_efficiency/test.sh | 71 +++++++++
+++++++++++++
5 files changed, 172 insertions(+) create mode 100644 doc/examples/cpufreq_governor_efficiency/
calibration.json
create mode 100755
doc/examples/cpufreq_governor_efficiency/calibration.sh
create mode 100644 doc/examples/cpufreq_governor_efficiency/dvfs.json create mode 100755 doc/examples/cpufreq_governor_efficiency/dvfs.sh create mode 100755 doc/examples/cpufreq_governor_efficiency/test.sh
diff --git a/doc/examples/cpufreq_governor_efficiency/
calibration.json
b/doc/examples/cpufreq_governor_efficiency/calibration.json
new file mode 100644 index 0000000..4377990 --- /dev/null +++ b/doc/examples/cpufreq_governor_efficiency/calibration.json @@ -0,0 +1,27 @@ +{
"tasks" : {
"thread" : {
"instance" : 1,
"cpus" : [0],
"loop" : 1,
"phases" : {
"run" : {
"loop" : 1,
"run" : 200000,
},
"sleep" : {
"loop" : 1,
"sleep" : 200000,
}
}
}
},
"global" : {
"default_policy" : "SCHED_FIFO",
"calibration" : "CPU0",
"lock_pages" : true,
"ftrace" : true,
"logdir" : "./",
}
+}
diff --git a/doc/examples/cpufreq_governor_efficiency/
calibration.sh b/doc/examples/cpufreq_governor_efficiency/calibration.sh
new file mode 100755 index 0000000..89fe5de --- /dev/null +++ b/doc/examples/cpufreq_governor_efficiency/calibration.sh @@ -0,0 +1,9 @@ +# !/bin/bash
Remove the space between # and !. That was the cause of this error I encountered initially and took time to figure out:
Yeah, this is more generic. Thanks!
~/repos/rt-app/doc/examples/cpufreq_governor_efficiency [master] $ sudo ./test.sh 4 100 1000 ./test.sh: 3: ./test.sh: function: not found ./test.sh: 5: ./test.sh: calibration.sh: not found ./test.sh: 8: ./test.sh: function: not found ./test.sh: 32: ./test.sh: Syntax error: "(" unexpected (expecting "}")
+echo performance >
/sys/devices/system/cpu/cpu0/cpufreq/scaling_governor
+sleep 1
+pLoad=`rt-app calibration.json 2>&1 |grep pLoad |sed 's/.*= (.*
)ns.*/\1/'`
+sed 's/"calibration" : .*,/"calibration" : '$pLoad',/' -i dvfs.json
diff --git a/doc/examples/cpufreq_governor_efficiency/dvfs.json b/
doc/examples/cpufreq_governor_efficiency/dvfs.json
new file mode 100644 index 0000000..b413156 --- /dev/null +++ b/doc/examples/cpufreq_governor_efficiency/dvfs.json @@ -0,0 +1,27 @@ +{
"tasks" : {
"thread" : {
"instance" : 1,
"cpus" : [0],
"loop" : 5,
"phases" : {
"running" : {
"loop" : 1,
"run" : 100000,
},
"sleeping" : {
"loop" : 1,
"sleep" : 1000000,
}
}
}
},
"global" : {
"default_policy" : "SCHED_OTHER",
"calibration" : 90,
"lock_pages" : true,
"ftrace" : true,
"logdir" : "./",
}
+}
diff --git a/doc/examples/cpufreq_governor_efficiency/dvfs.sh b/
doc/examples/cpufreq_governor_efficiency/dvfs.sh
new file mode 100755 index 0000000..1772041 --- /dev/null +++ b/doc/examples/cpufreq_governor_efficiency/dvfs.sh @@ -0,0 +1,38 @@ +# !/bin/bash
Same interpreter issue here as I commented above.
+#echo $1 $2 $3
+if [ $1 ] && [ $2 ] ; then
- for i in `seq 0 1 $[$2-1]`
- do
echo $1 >
/sys/devices/system/cpu/cpu$i/cpufreq/scaling_governor
#cat /sys/devices/system/cpu/cpu$i/cpufreq/scaling_governor
- done
- sleep 3
+fi
+if [ $3 ] ; then
- sed 's/"run" : .*,/"run" : '$3',/' -i dvfs.json
+fi
+if [ $4 ] ; then
- sed 's/"sleep" : .*,/"sleep" : '$4',/' -i dvfs.json
+fi
+#cat dvfs.json
+rt-app dvfs.json 2> /dev/null
+if [ $1 ] ; then
- mv rt-app-thread-0.log rt-app_$1_run$3us_sleep$4us.log
- declare -i sum
- sum=0
- for i in `cat rt-app_$1_run$3us_sleep$4us.log | sed '1~2!d' |
sed '1d' |cut -d " " -f 3`;
- do sum=sum+$i
- done
- sum=sum/5
- echo $sum
+fi
diff --git a/doc/examples/cpufreq_governor_efficiency/test.sh b/
doc/examples/cpufreq_governor_efficiency/test.sh
new file mode 100755 index 0000000..6f41a1b --- /dev/null +++ b/doc/examples/cpufreq_governor_efficiency/test.sh @@ -0,0 +1,71 @@ +# !/bin/bash
Same as above.
+function set_calibration +{
- calibration.sh
+}
+function test_efficiency +{
- declare -i performance
- declare -i powersave
- declare -i conservative
- declare -i ondemand
- declare -i denominator
- declare -i numerator
- FILENAME="results_$RANDOM$$.txt"
- dvfs.sh performance $1 $2 $3> $FILENAME
- dvfs.sh powersave $1 $2 $3 >> $FILENAME
- dvfs.sh conservative $1 $2 $3 >> $FILENAME
- dvfs.sh ondemand $1 $2 $3 >> $FILENAME
- performance=`cat $FILENAME |sed -n '1p'`
- powersave=`cat $FILENAME |sed -n '2p'`
- conservative=`cat $FILENAME |sed -n '3p'`
- ondemand=`cat $FILENAME |sed -n '4p'`
- rm -f $FILENAME
- denominator=$powersave-$performance
- numerator=($powersave-$conservative)*100
- if [ $denominator -le 0 ] ; then
echo "Probably not input all the cpus in the same frequncy
domain"
exit
- fi
- if [ $numerator -lt 0 ] ; then
numerator=0
- fi
- conservative=$numerator/$denominator
- echo "conservative efficiency: $conservative%"
- numerator=($powersave-$ondemand)*100
- if [ $numerator -lt 0 ] ; then
numerator=0
- fi
- ondemand=$numerator/$denominator
- echo -e "ondemand efficiency: $ondemand%\n"
+}
+if [ $# -lt 3 ]; then
- echo "Usage: ./test.sh <cpus> <runtime> <sleeptime>"
- echo "cpus: number of cpus in the CPU0's frequency domain"
- echo "runtime: running time in ms per loop of the workload
pattern"
- echo "sleeptime: sleeping time in ms per loop of the workload
patten"
- echo -e "\nExample: \n"./test.sh 4 100 1000" means
\nCPU0~CPU3 sharing frequency, "100ms run + 1000ms sleep" workload pattern.\n"
- exit
+fi
+echo "Frequency domain CPU0~CPU$[$1-1], run $2ms, sleep $3ms:"
+PATH=$PATH:. +set_calibration +test_efficiency $1 $[$2*1000] $[$3*1000]
+sleep 5
-- 1.9.1
When I fixed the interpreter issue, I got the following output:
~/repos/rt-app/doc/examples/cpufreq_governor_efficiency [master] $ sudo ./test.sh 4 100 1000 Frequency domain CPU0~CPU3, run 100ms, sleep 1000ms: cut: the delimiter must be a single character Try 'cut --help' for more information. cut: the delimiter must be a single character Try 'cut --help' for more information. cut: the delimiter must be a single character Try 'cut --help' for more information. cut: the delimiter must be a single character Try 'cut --help' for more information. ./test.sh: line 32: ./calibration.json: Permission denied Probably not input all the cpus in the same frequncy domain
It seems to have a "problem" with the cut command, and I'm not sure what's the primary cause of the calibration.json permission denied error.
In dvfs.sh: cut -d " " -f 3 the delimiter is actually a "tab", I suspect it was replaced with whitespaces during the transit. Maybe you can try to change it mannually to a "tab" in the shell script.
I used to run under root account, but just tested on another machine with "sudo ./test.sh 4 100 1000", and turns out to be ok.
Regards, -Xunlei
I enabled set -x to debug further, and saved the output in a link: http://hastebin.com/abotovuhov.md
Sched-tools mailing list Sched-tools@lists.linaro.org https://lists.linaro.org/mailman/listinfo/sched-tools
Sched-tools mailing list Sched-tools@lists.linaro.org https://lists.linaro.org/mailman/listinfo/sched-tools
-------------------------------------------------------- ZTE Information Security Notice: The information contained in this mail (and any attachment transmitted herewith) is privileged and confidential and is intended for the exclusive use of the addressee(s). If you are not an intended recipient, any disclosure, reproduction, distribution or other dissemination or use of the information contained is strictly prohibited. If you have received this mail in error, please delete it and notify us immediately.