aboutsummaryrefslogtreecommitdiffstats
path: root/tools/power/cpupower/bench
diff options
context:
space:
mode:
authorLinus Torvalds <torvalds@linux-foundation.org>2011-07-31 12:23:40 -0400
committerLinus Torvalds <torvalds@linux-foundation.org>2011-07-31 12:23:40 -0400
commit4d8a93c7e542c364b1c2ad1dd406ede85080eab9 (patch)
tree313d1dd3dec890b79b98a9ee420b17f6967db9fc /tools/power/cpupower/bench
parentf33c596a2f921696391801b637ed50d514634079 (diff)
parent029e9f73667f9b4661ac9886f706d75d26850260 (diff)
Merge git://git.kernel.org/pub/scm/linux/kernel/git/brodo/cpupowerutils
* git://git.kernel.org/pub/scm/linux/kernel/git/brodo/cpupowerutils: cpupower: Do detect IDA (opportunistic processor performance) via cpuid cpupower: Show Intel turbo ratio support via ./cpupower frequency-info cpupowerutils: increase MAX_LINE_LEN cpupower: Rename package from cpupowerutils to cpupower cpupowerutils: Rename: libcpufreq->libcpupower cpupowerutils: use kernel version-derived version string cpupowerutils: utils - ConfigStyle bugfixes cpupowerutils: helpers - ConfigStyle bugfixes cpupowerutils: idle_monitor - ConfigStyle bugfixes cpupowerutils: lib - ConfigStyle bugfixes cpupowerutils: bench - ConfigStyle bugfixes cpupowerutils: do not update po files on each and every compile cpupowerutils: remove ccdv, use kernel quiet/verbose mechanism cpupowerutils: use COPYING, CREDITS from top-level directory cpupowerutils - cpufrequtils extended with quite some features
Diffstat (limited to 'tools/power/cpupower/bench')
-rw-r--r--tools/power/cpupower/bench/Makefile29
-rw-r--r--tools/power/cpupower/bench/README-BENCH124
-rw-r--r--tools/power/cpupower/bench/benchmark.c194
-rw-r--r--tools/power/cpupower/bench/benchmark.h29
-rw-r--r--tools/power/cpupower/bench/config.h36
-rw-r--r--tools/power/cpupower/bench/cpufreq-bench_plot.sh104
-rw-r--r--tools/power/cpupower/bench/cpufreq-bench_script.sh101
-rw-r--r--tools/power/cpupower/bench/example.cfg11
-rw-r--r--tools/power/cpupower/bench/main.c202
-rw-r--r--tools/power/cpupower/bench/parse.c225
-rw-r--r--tools/power/cpupower/bench/parse.h53
-rw-r--r--tools/power/cpupower/bench/system.c191
-rw-r--r--tools/power/cpupower/bench/system.h29
13 files changed, 1328 insertions, 0 deletions
diff --git a/tools/power/cpupower/bench/Makefile b/tools/power/cpupower/bench/Makefile
new file mode 100644
index 000000000000..2b67606fc3e3
--- /dev/null
+++ b/tools/power/cpupower/bench/Makefile
@@ -0,0 +1,29 @@
1LIBS = -L../ -lm -lcpupower
2
3OBJS = main.o parse.o system.o benchmark.o
4CFLAGS += -D_GNU_SOURCE -I../lib -DDEFAULT_CONFIG_FILE=\"$(confdir)/cpufreq-bench.conf\"
5
6%.o : %.c
7 $(ECHO) " CC " $@
8 $(QUIET) $(CC) -c $(CFLAGS) $< -o $@
9
10cpufreq-bench: $(OBJS)
11 $(ECHO) " CC " $@
12 $(QUIET) $(CC) -o $@ $(CFLAGS) $(OBJS) $(LIBS)
13
14all: cpufreq-bench
15
16install:
17 mkdir -p $(DESTDIR)/$(sbindir)
18 mkdir -p $(DESTDIR)/$(bindir)
19 mkdir -p $(DESTDIR)/$(docdir)
20 mkdir -p $(DESTDIR)/$(confdir)
21 install -m 755 cpufreq-bench $(DESTDIR)/$(sbindir)/cpufreq-bench
22 install -m 755 cpufreq-bench_plot.sh $(DESTDIR)/$(bindir)/cpufreq-bench_plot.sh
23 install -m 644 README-BENCH $(DESTDIR)/$(docdir)/README-BENCH
24 install -m 755 cpufreq-bench_script.sh $(DESTDIR)/$(docdir)/cpufreq-bench_script.sh
25 install -m 644 example.cfg $(DESTDIR)/$(confdir)/cpufreq-bench.conf
26
27clean:
28 rm -f *.o
29 rm -f cpufreq-bench
diff --git a/tools/power/cpupower/bench/README-BENCH b/tools/power/cpupower/bench/README-BENCH
new file mode 100644
index 000000000000..8093ec738170
--- /dev/null
+++ b/tools/power/cpupower/bench/README-BENCH
@@ -0,0 +1,124 @@
1This is cpufreq-bench, a microbenchmark for the cpufreq framework.
2
3Purpose
4=======
5
6What is this benchmark for:
7 - Identify worst case performance loss when doing dynamic frequency
8 scaling using Linux kernel governors
9 - Identify average reaction time of a governor to CPU load changes
10 - (Stress) Testing whether a cpufreq low level driver or governor works
11 as expected
12 - Identify cpufreq related performance regressions between kernels
13 - Possibly Real time priority testing? -> what happens if there are
14 processes with a higher prio than the governor's kernel thread
15 - ...
16
17What this benchmark does *not* cover:
18 - Power saving related regressions (In fact as better the performance
19 throughput is, the worse the power savings will be, but the first should
20 mostly count more...)
21 - Real world (workloads)
22
23
24Description
25===========
26
27cpufreq-bench helps to test the condition of a given cpufreq governor.
28For that purpose, it compares the performance governor to a configured
29powersave module.
30
31
32How it works
33============
34You can specify load (100% CPU load) and sleep (0% CPU load) times in us which
35will be run X time in a row (cycles):
36
37 sleep=25000
38 load=25000
39 cycles=20
40
41This part of the configuration file will create 25ms load/sleep turns,
42repeated 20 times.
43
44Adding this:
45 sleep_step=25000
46 load_step=25000
47 rounds=5
48Will increase load and sleep time by 25ms 5 times.
49Together you get following test:
5025ms load/sleep time repeated 20 times (cycles).
5150ms load/sleep time repeated 20 times (cycles).
52..
53100ms load/sleep time repeated 20 times (cycles).
54
55First it is calibrated how long a specific CPU intensive calculation
56takes on this machine and needs to be run in a loop using the performance
57governor.
58Then the above test runs are processed using the performance governor
59and the governor to test. The time the calculation really needed
60with the dynamic freq scaling governor is compared with the time needed
61on full performance and you get the overall performance loss.
62
63
64Example of expected results with ondemand governor:
65
66This shows expected results of the first two test run rounds from
67above config, you there have:
68
69100% CPU load (load) | 0 % CPU load (sleep) | round
70 25 ms | 25 ms | 1
71 50 ms | 50 ms | 2
72
73For example if ondemand governor is configured to have a 50ms
74sampling rate you get:
75
76In round 1, ondemand should have rather static 50% load and probably
77won't ever switch up (as long as up_threshold is above).
78
79In round 2, if the ondemand sampling times exactly match the load/sleep
80trigger of the cpufreq-bench, you will see no performance loss (compare with
81below possible ondemand sample kick ins (1)):
82
83But if ondemand always kicks in in the middle of the load sleep cycles, it
84will always see 50% loads and you get worst performance impact never
85switching up (compare with below possible ondemand sample kick ins (2))::
86
87 50 50 50 50ms ->time
88load -----| |-----| |-----| |-----|
89 | | | | | | |
90sleep |-----| |-----| |-----| |----
91 |-----|-----|-----|-----|-----|-----|-----|---- ondemand sampling (1)
92 100 0 100 0 100 0 100 load seen by ondemand(%)
93 |-----|-----|-----|-----|-----|-----|-----|-- ondemand sampling (2)
94 50 50 50 50 50 50 50 load seen by ondemand(%)
95
96You can easily test all kind of load/sleep times and check whether your
97governor in average behaves as expected.
98
99
100ToDo
101====
102
103Provide a gnuplot utility script for easy generation of plots to present
104the outcome nicely.
105
106
107cpufreq-bench Command Usage
108===========================
109-l, --load=<long int> initial load time in us
110-s, --sleep=<long int> initial sleep time in us
111-x, --load-step=<long int> time to be added to load time, in us
112-y, --sleep-step=<long int> time to be added to sleep time, in us
113-c, --cpu=<unsigned int> CPU Number to use, starting at 0
114-p, --prio=<priority> scheduler priority, HIGH, LOW or DEFAULT
115-g, --governor=<governor> cpufreq governor to test
116-n, --cycles=<int> load/sleep cycles to get an avarage value to compare
117-r, --rounds<int> load/sleep rounds
118-f, --file=<configfile> config file to use
119-o, --output=<dir> output dir, must exist
120-v, --verbose verbose output on/off
121
122Due to the high priority, the application may not be responsible for some time.
123After the benchmark, the logfile is saved in OUTPUTDIR/benchmark_TIMESTAMP.log
124
diff --git a/tools/power/cpupower/bench/benchmark.c b/tools/power/cpupower/bench/benchmark.c
new file mode 100644
index 000000000000..81b1c48607d9
--- /dev/null
+++ b/tools/power/cpupower/bench/benchmark.c
@@ -0,0 +1,194 @@
1/* cpufreq-bench CPUFreq microbenchmark
2 *
3 * Copyright (C) 2008 Christian Kornacker <ckornacker@suse.de>
4 *
5 * This program is free software; you can redistribute it and/or modify
6 * it under the terms of the GNU General Public License as published by
7 * the Free Software Foundation; either version 2 of the License, or
8 * (at your option) any later version.
9 *
10 * This program is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 * GNU General Public License for more details.
14 *
15 * You should have received a copy of the GNU General Public License
16 * along with this program; if not, write to the Free Software
17 * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
18 */
19
20#include <stdio.h>
21#include <unistd.h>
22#include <math.h>
23
24#include "config.h"
25#include "system.h"
26#include "benchmark.h"
27
28/* Print out progress if we log into a file */
29#define show_progress(total_time, progress_time) \
30if (config->output != stdout) { \
31 fprintf(stdout, "Progress: %02lu %%\r", \
32 (progress_time * 100) / total_time); \
33 fflush(stdout); \
34}
35
36/**
37 * compute how many rounds of calculation we should do
38 * to get the given load time
39 *
40 * @param load aimed load time in µs
41 *
42 * @retval rounds of calculation
43 **/
44
45unsigned int calculate_timespace(long load, struct config *config)
46{
47 int i;
48 long long now, then;
49 unsigned int estimated = GAUGECOUNT;
50 unsigned int rounds = 0;
51 unsigned int timed = 0;
52
53 if (config->verbose)
54 printf("calibrating load of %lius, please wait...\n", load);
55
56 /* get the initial calculation time for a specific number of rounds */
57 now = get_time();
58 ROUNDS(estimated);
59 then = get_time();
60
61 timed = (unsigned int)(then - now);
62
63 /* approximation of the wanted load time by comparing with the
64 * initial calculation time */
65 for (i = 0; i < 4; i++) {
66 rounds = (unsigned int)(load * estimated / timed);
67 dprintf("calibrating with %u rounds\n", rounds);
68 now = get_time();
69 ROUNDS(rounds);
70 then = get_time();
71
72 timed = (unsigned int)(then - now);
73 estimated = rounds;
74 }
75 if (config->verbose)
76 printf("calibration done\n");
77
78 return estimated;
79}
80
81/**
82 * benchmark
83 * generates a specific sleep an load time with the performance
84 * governor and compares the used time for same calculations done
85 * with the configured powersave governor
86 *
87 * @param config config values for the benchmark
88 *
89 **/
90
91void start_benchmark(struct config *config)
92{
93 unsigned int _round, cycle;
94 long long now, then;
95 long sleep_time = 0, load_time = 0;
96 long performance_time = 0, powersave_time = 0;
97 unsigned int calculations;
98 unsigned long total_time = 0, progress_time = 0;
99
100 sleep_time = config->sleep;
101 load_time = config->load;
102
103 /* For the progress bar */
104 for (_round = 1; _round <= config->rounds; _round++)
105 total_time += _round * (config->sleep + config->load);
106 total_time *= 2; /* powersave and performance cycles */
107
108 for (_round = 0; _round < config->rounds; _round++) {
109 performance_time = 0LL;
110 powersave_time = 0LL;
111
112 show_progress(total_time, progress_time);
113
114 /* set the cpufreq governor to "performance" which disables
115 * P-State switching. */
116 if (set_cpufreq_governor("performance", config->cpu) != 0)
117 return;
118
119 /* calibrate the calculation time. the resulting calculation
120 * _rounds should produce a load which matches the configured
121 * load time */
122 calculations = calculate_timespace(load_time, config);
123
124 if (config->verbose)
125 printf("_round %i: doing %u cycles with %u calculations"
126 " for %lius\n", _round + 1, config->cycles,
127 calculations, load_time);
128
129 fprintf(config->output, "%u %li %li ",
130 _round, load_time, sleep_time);
131
132 if (config->verbose)
133 printf("avarage: %lius, rps:%li\n",
134 load_time / calculations,
135 1000000 * calculations / load_time);
136
137 /* do some sleep/load cycles with the performance governor */
138 for (cycle = 0; cycle < config->cycles; cycle++) {
139 now = get_time();
140 usleep(sleep_time);
141 ROUNDS(calculations);
142 then = get_time();
143 performance_time += then - now - sleep_time;
144 if (config->verbose)
145 printf("performance cycle took %lius, "
146 "sleep: %lius, "
147 "load: %lius, rounds: %u\n",
148 (long)(then - now), sleep_time,
149 load_time, calculations);
150 }
151 fprintf(config->output, "%li ",
152 performance_time / config->cycles);
153
154 progress_time += sleep_time + load_time;
155 show_progress(total_time, progress_time);
156
157 /* set the powersave governor which activates P-State switching
158 * again */
159 if (set_cpufreq_governor(config->governor, config->cpu) != 0)
160 return;
161
162 /* again, do some sleep/load cycles with the
163 * powersave governor */
164 for (cycle = 0; cycle < config->cycles; cycle++) {
165 now = get_time();
166 usleep(sleep_time);
167 ROUNDS(calculations);
168 then = get_time();
169 powersave_time += then - now - sleep_time;
170 if (config->verbose)
171 printf("powersave cycle took %lius, "
172 "sleep: %lius, "
173 "load: %lius, rounds: %u\n",
174 (long)(then - now), sleep_time,
175 load_time, calculations);
176 }
177
178 progress_time += sleep_time + load_time;
179
180 /* compare the avarage sleep/load cycles */
181 fprintf(config->output, "%li ",
182 powersave_time / config->cycles);
183 fprintf(config->output, "%.3f\n",
184 performance_time * 100.0 / powersave_time);
185 fflush(config->output);
186
187 if (config->verbose)
188 printf("performance is at %.2f%%\n",
189 performance_time * 100.0 / powersave_time);
190
191 sleep_time += config->sleep_step;
192 load_time += config->load_step;
193 }
194}
diff --git a/tools/power/cpupower/bench/benchmark.h b/tools/power/cpupower/bench/benchmark.h
new file mode 100644
index 000000000000..51d7f50ac2bb
--- /dev/null
+++ b/tools/power/cpupower/bench/benchmark.h
@@ -0,0 +1,29 @@
1/* cpufreq-bench CPUFreq microbenchmark
2 *
3 * Copyright (C) 2008 Christian Kornacker <ckornacker@suse.de>
4 *
5 * This program is free software; you can redistribute it and/or modify
6 * it under the terms of the GNU General Public License as published by
7 * the Free Software Foundation; either version 2 of the License, or
8 * (at your option) any later version.
9 *
10 * This program is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 * GNU General Public License for more details.
14 *
15 * You should have received a copy of the GNU General Public License
16 * along with this program; if not, write to the Free Software
17 * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
18 */
19
20/* load loop, this schould take about 1 to 2ms to complete */
21#define ROUNDS(x) {unsigned int rcnt; \
22 for (rcnt = 0; rcnt < x*1000; rcnt++) { \
23 (void)(((int)(pow(rcnt, rcnt) * \
24 sqrt(rcnt*7230970)) ^ 7230716) ^ \
25 (int)atan2(rcnt, rcnt)); \
26 } } \
27
28
29void start_benchmark(struct config *config);
diff --git a/tools/power/cpupower/bench/config.h b/tools/power/cpupower/bench/config.h
new file mode 100644
index 000000000000..ee6f258e5336
--- /dev/null
+++ b/tools/power/cpupower/bench/config.h
@@ -0,0 +1,36 @@
1/* cpufreq-bench CPUFreq microbenchmark
2 *
3 * Copyright (C) 2008 Christian Kornacker <ckornacker@suse.de>
4 *
5 * This program is free software; you can redistribute it and/or modify
6 * it under the terms of the GNU General Public License as published by
7 * the Free Software Foundation; either version 2 of the License, or
8 * (at your option) any later version.
9 *
10 * This program is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 * GNU General Public License for more details.
14 *
15 * You should have received a copy of the GNU General Public License
16 * along with this program; if not, write to the Free Software
17 * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
18 */
19
20/* initial loop count for the load calibration */
21#define GAUGECOUNT 1500
22
23/* default scheduling policy SCHED_OTHER */
24#define SCHEDULER SCHED_OTHER
25
26#define PRIORITY_DEFAULT 0
27#define PRIORITY_HIGH sched_get_priority_max(SCHEDULER)
28#define PRIORITY_LOW sched_get_priority_min(SCHEDULER)
29
30/* enable further debug messages */
31#ifdef DEBUG
32#define dprintf printf
33#else
34#define dprintf(...) do { } while (0)
35#endif
36
diff --git a/tools/power/cpupower/bench/cpufreq-bench_plot.sh b/tools/power/cpupower/bench/cpufreq-bench_plot.sh
new file mode 100644
index 000000000000..410021a12f40
--- /dev/null
+++ b/tools/power/cpupower/bench/cpufreq-bench_plot.sh
@@ -0,0 +1,104 @@
1#!/bin/bash
2
3# This program is free software: you can redistribute it and/or modify
4# it under the terms of the GNU General Public License as published by
5# the Free Software Foundation; either version 2, or (at your option)
6# any later version.
7
8# This program is distributed in the hope that it will be useful,
9# but WITHOUT ANY WARRANTY; without even the implied warranty of
10# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11# GNU General Public License for more details.
12
13# You should have received a copy of the GNU General Public License
14# along with this program; if not, write to the Free Software
15# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
16# 02110-1301, USA.
17
18# Author/Copyright(c): 2009, Thomas Renninger <trenn@suse.de>, Novell Inc.
19
20# Helper script to easily create nice plots of your cpufreq-bench results
21
22dir=`mktemp -d`
23output_file="cpufreq-bench.png"
24global_title="cpufreq-bench plot"
25picture_type="jpeg"
26file[0]=""
27
28function usage()
29{
30 echo "cpufreq-bench_plot.sh [OPTIONS] logfile [measure_title] [logfile [measure_title]] ...]"
31 echo
32 echo "Options"
33 echo " -o output_file"
34 echo " -t global_title"
35 echo " -p picture_type [jpeg|gif|png|postscript|...]"
36 exit 1
37}
38
39if [ $# -eq 0 ];then
40 echo "No benchmark results file provided"
41 echo
42 usage
43fi
44
45while getopts o:t:p: name ; do
46 case $name in
47 o)
48 output_file="$OPTARG".$picture_type
49 ;;
50 t)
51 global_title="$OPTARG"
52 ;;
53 p)
54 picture_type="$OPTARG"
55 ;;
56 ?)
57 usage
58 ;;
59 esac
60done
61shift $(($OPTIND -1))
62
63plots=0
64while [ "$1" ];do
65 if [ ! -f "$1" ];then
66 echo "File $1 does not exist"
67 usage
68 fi
69 file[$plots]="$1"
70 title[$plots]="$2"
71 # echo "File: ${file[$plots]} - ${title[plots]}"
72 shift;shift
73 plots=$((plots + 1))
74done
75
76echo "set terminal $picture_type" >> $dir/plot_script.gpl
77echo "set output \"$output_file\"" >> $dir/plot_script.gpl
78echo "set title \"$global_title\"" >> $dir/plot_script.gpl
79echo "set xlabel \"sleep/load time\"" >> $dir/plot_script.gpl
80echo "set ylabel \"Performance (%)\"" >> $dir/plot_script.gpl
81
82for((plot=0;plot<$plots;plot++));do
83
84 # Sanity check
85 ###### I am to dump to get this redirected to stderr/stdout in one awk call... #####
86 cat ${file[$plot]} |grep -v "^#" |awk '{if ($2 != $3) printf("Error in measure %d:Load time %s does not equal sleep time %s, plot will not be correct\n", $1, $2, $3); ERR=1}'
87 ###### I am to dump to get this redirected in one awk call... #####
88
89 # Parse out load time (which must be equal to sleep time for a plot), divide it by 1000
90 # to get ms and parse out the performance in percentage and write it to a temp file for plotting
91 cat ${file[$plot]} |grep -v "^#" |awk '{printf "%lu %.1f\n",$2/1000, $6}' >$dir/data_$plot
92
93 if [ $plot -eq 0 ];then
94 echo -n "plot " >> $dir/plot_script.gpl
95 fi
96 echo -n "\"$dir/data_$plot\" title \"${title[$plot]}\" with lines" >> $dir/plot_script.gpl
97 if [ $(($plot + 1)) -ne $plots ];then
98 echo -n ", " >> $dir/plot_script.gpl
99 fi
100done
101echo >> $dir/plot_script.gpl
102
103gnuplot $dir/plot_script.gpl
104rm -r $dir \ No newline at end of file
diff --git a/tools/power/cpupower/bench/cpufreq-bench_script.sh b/tools/power/cpupower/bench/cpufreq-bench_script.sh
new file mode 100644
index 000000000000..de20d2a06879
--- /dev/null
+++ b/tools/power/cpupower/bench/cpufreq-bench_script.sh
@@ -0,0 +1,101 @@
1#!/bin/bash
2
3# This program is free software: you can redistribute it and/or modify
4# it under the terms of the GNU General Public License as published by
5# the Free Software Foundation; either version 2, or (at your option)
6# any later version.
7
8# This program is distributed in the hope that it will be useful,
9# but WITHOUT ANY WARRANTY; without even the implied warranty of
10# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11# GNU General Public License for more details.
12
13# You should have received a copy of the GNU General Public License
14# along with this program; if not, write to the Free Software
15# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
16# 02110-1301, USA.
17
18# Author/Copyright(c): 2009, Thomas Renninger <trenn@suse.de>, Novell Inc.
19
20# Ondemand up_threshold and sampling rate test script for cpufreq-bench
21# mircobenchmark.
22# Modify the general variables at the top or extend or copy out parts
23# if you want to test other things
24#
25
26# Default with latest kernels is 95, before micro account patches
27# it was 80, cmp. with git commit 808009131046b62ac434dbc796
28UP_THRESHOLD="60 80 95"
29# Depending on the kernel and the HW sampling rate could be restricted
30# and cannot be set that low...
31# E.g. before git commit cef9615a853ebc4972084f7 one could only set
32# min sampling rate of 80000 if CONFIG_HZ=250
33SAMPLING_RATE="20000 80000"
34
35function measure()
36{
37 local -i up_threshold_set
38 local -i sampling_rate_set
39
40 for up_threshold in $UP_THRESHOLD;do
41 for sampling_rate in $SAMPLING_RATE;do
42 # Set values in sysfs
43 echo $up_threshold >/sys/devices/system/cpu/cpu0/cpufreq/ondemand/up_threshold
44 echo $sampling_rate >/sys/devices/system/cpu/cpu0/cpufreq/ondemand/sampling_rate
45 up_threshold_set=$(cat /sys/devices/system/cpu/cpu0/cpufreq/ondemand/up_threshold)
46 sampling_rate_set=$(cat /sys/devices/system/cpu/cpu0/cpufreq/ondemand/sampling_rate)
47
48 # Verify set values in sysfs
49 if [ ${up_threshold_set} -eq ${up_threshold} ];then
50 echo "up_threshold: $up_threshold, set in sysfs: ${up_threshold_set}"
51 else
52 echo "WARNING: Tried to set up_threshold: $up_threshold, set in sysfs: ${up_threshold_set}"
53 fi
54 if [ ${sampling_rate_set} -eq ${sampling_rate} ];then
55 echo "sampling_rate: $sampling_rate, set in sysfs: ${sampling_rate_set}"
56 else
57 echo "WARNING: Tried to set sampling_rate: $sampling_rate, set in sysfs: ${sampling_rate_set}"
58 fi
59
60 # Benchmark
61 cpufreq-bench -o /var/log/cpufreq-bench/up_threshold_${up_threshold}_sampling_rate_${sampling_rate}
62 done
63 done
64}
65
66function create_plots()
67{
68 local command
69
70 for up_threshold in $UP_THRESHOLD;do
71 command="cpufreq-bench_plot.sh -o \"sampling_rate_${SAMPLING_RATE}_up_threshold_${up_threshold}\" -t \"Ondemand sampling_rate: ${SAMPLING_RATE} comparison - Up_threshold: $up_threshold %\""
72 for sampling_rate in $SAMPLING_RATE;do
73 command="${command} /var/log/cpufreq-bench/up_threshold_${up_threshold}_sampling_rate_${sampling_rate}/* \"sampling_rate = $sampling_rate\""
74 done
75 echo $command
76 eval "$command"
77 echo
78 done
79
80 for sampling_rate in $SAMPLING_RATE;do
81 command="cpufreq-bench_plot.sh -o \"up_threshold_${UP_THRESHOLD}_sampling_rate_${sampling_rate}\" -t \"Ondemand up_threshold: ${UP_THRESHOLD} % comparison - sampling_rate: $sampling_rate\""
82 for up_threshold in $UP_THRESHOLD;do
83 command="${command} /var/log/cpufreq-bench/up_threshold_${up_threshold}_sampling_rate_${sampling_rate}/* \"up_threshold = $up_threshold\""
84 done
85 echo $command
86 eval "$command"
87 echo
88 done
89
90 command="cpufreq-bench_plot.sh -o \"up_threshold_${UP_THRESHOLD}_sampling_rate_${SAMPLING_RATE}\" -t \"Ondemand up_threshold: ${UP_THRESHOLD} and sampling_rate ${SAMPLING_RATE} comparison\""
91 for sampling_rate in $SAMPLING_RATE;do
92 for up_threshold in $UP_THRESHOLD;do
93 command="${command} /var/log/cpufreq-bench/up_threshold_${up_threshold}_sampling_rate_${sampling_rate}/* \"up_threshold = $up_threshold - sampling_rate = $sampling_rate\""
94 done
95 done
96 echo "$command"
97 eval "$command"
98}
99
100measure
101create_plots \ No newline at end of file
diff --git a/tools/power/cpupower/bench/example.cfg b/tools/power/cpupower/bench/example.cfg
new file mode 100644
index 000000000000..f91f64360688
--- /dev/null
+++ b/tools/power/cpupower/bench/example.cfg
@@ -0,0 +1,11 @@
1sleep = 50000
2load = 50000
3cpu = 0
4priority = LOW
5output = /var/log/cpufreq-bench
6sleep_step = 50000
7load_step = 50000
8cycles = 20
9rounds = 40
10verbose = 0
11governor = ondemand
diff --git a/tools/power/cpupower/bench/main.c b/tools/power/cpupower/bench/main.c
new file mode 100644
index 000000000000..24910313a521
--- /dev/null
+++ b/tools/power/cpupower/bench/main.c
@@ -0,0 +1,202 @@
1/* cpufreq-bench CPUFreq microbenchmark
2 *
3 * Copyright (C) 2008 Christian Kornacker <ckornacker@suse.de>
4 *
5 * This program is free software; you can redistribute it and/or modify
6 * it under the terms of the GNU General Public License as published by
7 * the Free Software Foundation; either version 2 of the License, or
8 * (at your option) any later version.
9 *
10 * This program is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 * GNU General Public License for more details.
14 *
15 * You should have received a copy of the GNU General Public License
16 * along with this program; if not, write to the Free Software
17 * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
18 */
19
20#include <stdio.h>
21#include <stdlib.h>
22#include <string.h>
23#include <unistd.h>
24#include <getopt.h>
25#include <errno.h>
26
27#include "config.h"
28#include "system.h"
29#include "benchmark.h"
30
31static struct option long_options[] = {
32 {"output", 1, 0, 'o'},
33 {"sleep", 1, 0, 's'},
34 {"load", 1, 0, 'l'},
35 {"verbose", 0, 0, 'v'},
36 {"cpu", 1, 0, 'c'},
37 {"governor", 1, 0, 'g'},
38 {"prio", 1, 0, 'p'},
39 {"file", 1, 0, 'f'},
40 {"cycles", 1, 0, 'n'},
41 {"rounds", 1, 0, 'r'},
42 {"load-step", 1, 0, 'x'},
43 {"sleep-step", 1, 0, 'y'},
44 {"help", 0, 0, 'h'},
45 {0, 0, 0, 0}
46};
47
48/*******************************************************************
49 usage
50*******************************************************************/
51
52void usage()
53{
54 printf("usage: ./bench\n");
55 printf("Options:\n");
56 printf(" -l, --load=<long int>\t\tinitial load time in us\n");
57 printf(" -s, --sleep=<long int>\t\tinitial sleep time in us\n");
58 printf(" -x, --load-step=<long int>\ttime to be added to load time, in us\n");
59 printf(" -y, --sleep-step=<long int>\ttime to be added to sleep time, in us\n");
60 printf(" -c, --cpu=<cpu #>\t\t\tCPU Nr. to use, starting at 0\n");
61 printf(" -p, --prio=<priority>\t\t\tscheduler priority, HIGH, LOW or DEFAULT\n");
62 printf(" -g, --governor=<governor>\t\tcpufreq governor to test\n");
63 printf(" -n, --cycles=<int>\t\t\tload/sleep cycles\n");
64 printf(" -r, --rounds<int>\t\t\tload/sleep rounds\n");
65 printf(" -f, --file=<configfile>\t\tconfig file to use\n");
66 printf(" -o, --output=<dir>\t\t\toutput path. Filename will be OUTPUTPATH/benchmark_TIMESTAMP.log\n");
67 printf(" -v, --verbose\t\t\t\tverbose output on/off\n");
68 printf(" -h, --help\t\t\t\tPrint this help screen\n");
69 exit(1);
70}
71
72/*******************************************************************
73 main
74*******************************************************************/
75
76int main(int argc, char **argv)
77{
78 int c;
79 int option_index = 0;
80 struct config *config = NULL;
81
82 config = prepare_default_config();
83
84 if (config == NULL)
85 return EXIT_FAILURE;
86
87 while (1) {
88 c = getopt_long (argc, argv, "hg:o:s:l:vc:p:f:n:r:x:y:",
89 long_options, &option_index);
90 if (c == -1)
91 break;
92
93 switch (c) {
94 case 'o':
95 if (config->output != NULL)
96 fclose(config->output);
97
98 config->output = prepare_output(optarg);
99
100 if (config->output == NULL)
101 return EXIT_FAILURE;
102
103 dprintf("user output path -> %s\n", optarg);
104 break;
105 case 's':
106 sscanf(optarg, "%li", &config->sleep);
107 dprintf("user sleep time -> %s\n", optarg);
108 break;
109 case 'l':
110 sscanf(optarg, "%li", &config->load);
111 dprintf("user load time -> %s\n", optarg);
112 break;
113 case 'c':
114 sscanf(optarg, "%u", &config->cpu);
115 dprintf("user cpu -> %s\n", optarg);
116 break;
117 case 'g':
118 strncpy(config->governor, optarg, 14);
119 dprintf("user governor -> %s\n", optarg);
120 break;
121 case 'p':
122 if (string_to_prio(optarg) != SCHED_ERR) {
123 config->prio = string_to_prio(optarg);
124 dprintf("user prio -> %s\n", optarg);
125 } else {
126 if (config != NULL) {
127 if (config->output != NULL)
128 fclose(config->output);
129 free(config);
130 }
131 usage();
132 }
133 break;
134 case 'n':
135 sscanf(optarg, "%u", &config->cycles);
136 dprintf("user cycles -> %s\n", optarg);
137 break;
138 case 'r':
139 sscanf(optarg, "%u", &config->rounds);
140 dprintf("user rounds -> %s\n", optarg);
141 break;
142 case 'x':
143 sscanf(optarg, "%li", &config->load_step);
144 dprintf("user load_step -> %s\n", optarg);
145 break;
146 case 'y':
147 sscanf(optarg, "%li", &config->sleep_step);
148 dprintf("user sleep_step -> %s\n", optarg);
149 break;
150 case 'f':
151 if (prepare_config(optarg, config))
152 return EXIT_FAILURE;
153 break;
154 case 'v':
155 config->verbose = 1;
156 dprintf("verbose output enabled\n");
157 break;
158 case 'h':
159 case '?':
160 default:
161 if (config != NULL) {
162 if (config->output != NULL)
163 fclose(config->output);
164 free(config);
165 }
166 usage();
167 }
168 }
169
170 if (config->verbose) {
171 printf("starting benchmark with parameters:\n");
172 printf("config:\n\t"
173 "sleep=%li\n\t"
174 "load=%li\n\t"
175 "sleep_step=%li\n\t"
176 "load_step=%li\n\t"
177 "cpu=%u\n\t"
178 "cycles=%u\n\t"
179 "rounds=%u\n\t"
180 "governor=%s\n\n",
181 config->sleep,
182 config->load,
183 config->sleep_step,
184 config->load_step,
185 config->cpu,
186 config->cycles,
187 config->rounds,
188 config->governor);
189 }
190
191 prepare_user(config);
192 prepare_system(config);
193 start_benchmark(config);
194
195 if (config->output != stdout)
196 fclose(config->output);
197
198 free(config);
199
200 return EXIT_SUCCESS;
201}
202
diff --git a/tools/power/cpupower/bench/parse.c b/tools/power/cpupower/bench/parse.c
new file mode 100644
index 000000000000..543bba14ae2c
--- /dev/null
+++ b/tools/power/cpupower/bench/parse.c
@@ -0,0 +1,225 @@
1/* cpufreq-bench CPUFreq microbenchmark
2 *
3 * Copyright (C) 2008 Christian Kornacker <ckornacker@suse.de>
4 *
5 * This program is free software; you can redistribute it and/or modify
6 * it under the terms of the GNU General Public License as published by
7 * the Free Software Foundation; either version 2 of the License, or
8 * (at your option) any later version.
9 *
10 * This program is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 * GNU General Public License for more details.
14 *
15 * You should have received a copy of the GNU General Public License
16 * along with this program; if not, write to the Free Software
17 * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
18 */
19
20#include <stdio.h>
21#include <stdlib.h>
22#include <stdarg.h>
23#include <string.h>
24#include <time.h>
25#include <dirent.h>
26
27#include <sys/utsname.h>
28#include <sys/types.h>
29#include <sys/stat.h>
30
31#include "parse.h"
32#include "config.h"
33
34/**
35 * converts priority string to priority
36 *
37 * @param str string that represents a scheduler priority
38 *
39 * @retval priority
40 * @retval SCHED_ERR when the priority doesn't exit
41 **/
42
43enum sched_prio string_to_prio(const char *str)
44{
45 if (strncasecmp("high", str, strlen(str)) == 0)
46 return SCHED_HIGH;
47 else if (strncasecmp("default", str, strlen(str)) == 0)
48 return SCHED_DEFAULT;
49 else if (strncasecmp("low", str, strlen(str)) == 0)
50 return SCHED_LOW;
51 else
52 return SCHED_ERR;
53}
54
55/**
56 * create and open logfile
57 *
58 * @param dir directory in which the logfile should be created
59 *
60 * @retval logfile on success
61 * @retval NULL when the file can't be created
62 **/
63
64FILE *prepare_output(const char *dirname)
65{
66 FILE *output = NULL;
67 int len;
68 char *filename;
69 struct utsname sysdata;
70 DIR *dir;
71
72 dir = opendir(dirname);
73 if (dir == NULL) {
74 if (mkdir(dirname, 0755)) {
75 perror("mkdir");
76 fprintf(stderr, "error: Cannot create dir %s\n",
77 dirname);
78 return NULL;
79 }
80 }
81
82 len = strlen(dirname) + 30;
83 filename = malloc(sizeof(char) * len);
84
85 if (uname(&sysdata) == 0) {
86 len += strlen(sysdata.nodename) + strlen(sysdata.release);
87 filename = realloc(filename, sizeof(char) * len);
88
89 if (filename == NULL) {
90 perror("realloc");
91 return NULL;
92 }
93
94 snprintf(filename, len - 1, "%s/benchmark_%s_%s_%li.log",
95 dirname, sysdata.nodename, sysdata.release, time(NULL));
96 } else {
97 snprintf(filename, len - 1, "%s/benchmark_%li.log",
98 dirname, time(NULL));
99 }
100
101 dprintf("logilename: %s\n", filename);
102
103 output = fopen(filename, "w+");
104 if (output == NULL) {
105 perror("fopen");
106 fprintf(stderr, "error: unable to open logfile\n");
107 }
108
109 fprintf(stdout, "Logfile: %s\n", filename);
110
111 free(filename);
112 fprintf(output, "#round load sleep performance powersave percentage\n");
113 return output;
114}
115
116/**
117 * returns the default config
118 *
119 * @retval default config on success
120 * @retval NULL when the output file can't be created
121 **/
122
123struct config *prepare_default_config()
124{
125 struct config *config = malloc(sizeof(struct config));
126
127 dprintf("loading defaults\n");
128
129 config->sleep = 500000;
130 config->load = 500000;
131 config->sleep_step = 500000;
132 config->load_step = 500000;
133 config->cycles = 5;
134 config->rounds = 50;
135 config->cpu = 0;
136 config->prio = SCHED_HIGH;
137 config->verbose = 0;
138 strncpy(config->governor, "ondemand", 8);
139
140 config->output = stdout;
141
142#ifdef DEFAULT_CONFIG_FILE
143 if (prepare_config(DEFAULT_CONFIG_FILE, config))
144 return NULL;
145#endif
146 return config;
147}
148
149/**
150 * parses config file and returns the config to the caller
151 *
152 * @param path config file name
153 *
154 * @retval 1 on error
155 * @retval 0 on success
156 **/
157
158int prepare_config(const char *path, struct config *config)
159{
160 size_t len = 0;
161 char *opt, *val, *line = NULL;
162 FILE *configfile = fopen(path, "r");
163
164 if (config == NULL) {
165 fprintf(stderr, "error: config is NULL\n");
166 return 1;
167 }
168
169 if (configfile == NULL) {
170 perror("fopen");
171 fprintf(stderr, "error: unable to read configfile\n");
172 free(config);
173 return 1;
174 }
175
176 while (getline(&line, &len, configfile) != -1) {
177 if (line[0] == '#' || line[0] == ' ')
178 continue;
179
180 sscanf(line, "%as = %as", &opt, &val);
181
182 dprintf("parsing: %s -> %s\n", opt, val);
183
184 if (strncmp("sleep", opt, strlen(opt)) == 0)
185 sscanf(val, "%li", &config->sleep);
186
187 else if (strncmp("load", opt, strlen(opt)) == 0)
188 sscanf(val, "%li", &config->load);
189
190 else if (strncmp("load_step", opt, strlen(opt)) == 0)
191 sscanf(val, "%li", &config->load_step);
192
193 else if (strncmp("sleep_step", opt, strlen(opt)) == 0)
194 sscanf(val, "%li", &config->sleep_step);
195
196 else if (strncmp("cycles", opt, strlen(opt)) == 0)
197 sscanf(val, "%u", &config->cycles);
198
199 else if (strncmp("rounds", opt, strlen(opt)) == 0)
200 sscanf(val, "%u", &config->rounds);
201
202 else if (strncmp("verbose", opt, strlen(opt)) == 0)
203 sscanf(val, "%u", &config->verbose);
204
205 else if (strncmp("output", opt, strlen(opt)) == 0)
206 config->output = prepare_output(val);
207
208 else if (strncmp("cpu", opt, strlen(opt)) == 0)
209 sscanf(val, "%u", &config->cpu);
210
211 else if (strncmp("governor", opt, 14) == 0)
212 strncpy(config->governor, val, 14);
213
214 else if (strncmp("priority", opt, strlen(opt)) == 0) {
215 if (string_to_prio(val) != SCHED_ERR)
216 config->prio = string_to_prio(val);
217 }
218 }
219
220 free(line);
221 free(opt);
222 free(val);
223
224 return 0;
225}
diff --git a/tools/power/cpupower/bench/parse.h b/tools/power/cpupower/bench/parse.h
new file mode 100644
index 000000000000..a8dc632d9eee
--- /dev/null
+++ b/tools/power/cpupower/bench/parse.h
@@ -0,0 +1,53 @@
1/* cpufreq-bench CPUFreq microbenchmark
2 *
3 * Copyright (C) 2008 Christian Kornacker <ckornacker@suse.de>
4 *
5 * This program is free software; you can redistribute it and/or modify
6 * it under the terms of the GNU General Public License as published by
7 * the Free Software Foundation; either version 2 of the License, or
8 * (at your option) any later version.
9 *
10 * This program is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 * GNU General Public License for more details.
14 *
15 * You should have received a copy of the GNU General Public License
16 * along with this program; if not, write to the Free Software
17 * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
18 */
19
20/* struct that holds the required config parameters */
21struct config
22{
23 long sleep; /* sleep time in µs */
24 long load; /* load time in µs */
25 long sleep_step; /* time value which changes the
26 * sleep time after every round in µs */
27 long load_step; /* time value which changes the
28 * load time after every round in µs */
29 unsigned int cycles; /* calculation cycles with the same sleep/load time */
30 unsigned int rounds; /* calculation rounds with iterated sleep/load time */
31 unsigned int cpu; /* cpu for which the affinity is set */
32 char governor[15]; /* cpufreq governor */
33 enum sched_prio /* possible scheduler priorities */
34 {
35 SCHED_ERR = -1,
36 SCHED_HIGH,
37 SCHED_DEFAULT,
38 SCHED_LOW
39 } prio;
40
41 unsigned int verbose; /* verbose output */
42 FILE *output; /* logfile */
43 char *output_filename; /* logfile name, must be freed at the end
44 if output != NULL and output != stdout*/
45};
46
47enum sched_prio string_to_prio(const char *str);
48
49FILE *prepare_output(const char *dir);
50
51int prepare_config(const char *path, struct config *config);
52struct config *prepare_default_config();
53
diff --git a/tools/power/cpupower/bench/system.c b/tools/power/cpupower/bench/system.c
new file mode 100644
index 000000000000..f01e3f4be84c
--- /dev/null
+++ b/tools/power/cpupower/bench/system.c
@@ -0,0 +1,191 @@
1/* cpufreq-bench CPUFreq microbenchmark
2 *
3 * Copyright (C) 2008 Christian Kornacker <ckornacker@suse.de>
4 *
5 * This program is free software; you can redistribute it and/or modify
6 * it under the terms of the GNU General Public License as published by
7 * the Free Software Foundation; either version 2 of the License, or
8 * (at your option) any later version.
9 *
10 * This program is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 * GNU General Public License for more details.
14 *
15 * You should have received a copy of the GNU General Public License
16 * along with this program; if not, write to the Free Software
17 * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
18 */
19
20#include <stdio.h>
21#include <time.h>
22#include <sys/time.h>
23#include <sys/types.h>
24#include <unistd.h>
25
26#include <sched.h>
27
28#include <cpufreq.h>
29
30#include "config.h"
31#include "system.h"
32
33/**
34 * returns time since epoch in µs
35 *
36 * @retval time
37 **/
38
39long long int get_time()
40{
41 struct timeval now;
42
43 gettimeofday(&now, NULL);
44
45 return (long long int)(now.tv_sec * 1000000LL + now.tv_usec);
46}
47
48/**
49 * sets the cpufreq governor
50 *
51 * @param governor cpufreq governor name
52 * @param cpu cpu for which the governor should be set
53 *
54 * @retval 0 on success
55 * @retval -1 when failed
56 **/
57
58int set_cpufreq_governor(char *governor, unsigned int cpu)
59{
60
61 dprintf("set %s as cpufreq governor\n", governor);
62
63 if (cpufreq_cpu_exists(cpu) != 0) {
64 perror("cpufreq_cpu_exists");
65 fprintf(stderr, "error: cpu %u does not exist\n", cpu);
66 return -1;
67 }
68
69 if (cpufreq_modify_policy_governor(cpu, governor) != 0) {
70 perror("cpufreq_modify_policy_governor");
71 fprintf(stderr, "error: unable to set %s governor\n", governor);
72 return -1;
73 }
74
75 return 0;
76}
77
78/**
79 * sets cpu affinity for the process
80 *
81 * @param cpu cpu# to which the affinity should be set
82 *
83 * @retval 0 on success
84 * @retval -1 when setting the affinity failed
85 **/
86
87int set_cpu_affinity(unsigned int cpu)
88{
89 cpu_set_t cpuset;
90
91 CPU_ZERO(&cpuset);
92 CPU_SET(cpu, &cpuset);
93
94 dprintf("set affinity to cpu #%u\n", cpu);
95
96 if (sched_setaffinity(getpid(), sizeof(cpu_set_t), &cpuset) < 0) {
97 perror("sched_setaffinity");
98 fprintf(stderr, "warning: unable to set cpu affinity\n");
99 return -1;
100 }
101
102 return 0;
103}
104
105/**
106 * sets the process priority parameter
107 *
108 * @param priority priority value
109 *
110 * @retval 0 on success
111 * @retval -1 when setting the priority failed
112 **/
113
114int set_process_priority(int priority)
115{
116 struct sched_param param;
117
118 dprintf("set scheduler priority to %i\n", priority);
119
120 param.sched_priority = priority;
121
122 if (sched_setscheduler(0, SCHEDULER, &param) < 0) {
123 perror("sched_setscheduler");
124 fprintf(stderr, "warning: unable to set scheduler priority\n");
125 return -1;
126 }
127
128 return 0;
129}
130
131/**
132 * notifies the user that the benchmark may run some time
133 *
134 * @param config benchmark config values
135 *
136 **/
137
138void prepare_user(const struct config *config)
139{
140 unsigned long sleep_time = 0;
141 unsigned long load_time = 0;
142 unsigned int round;
143
144 for (round = 0; round < config->rounds; round++) {
145 sleep_time += 2 * config->cycles *
146 (config->sleep + config->sleep_step * round);
147 load_time += 2 * config->cycles *
148 (config->load + config->load_step * round) +
149 (config->load + config->load_step * round * 4);
150 }
151
152 if (config->verbose || config->output != stdout)
153 printf("approx. test duration: %im\n",
154 (int)((sleep_time + load_time) / 60000000));
155}
156
157/**
158 * sets up the cpu affinity and scheduler priority
159 *
160 * @param config benchmark config values
161 *
162 **/
163
164void prepare_system(const struct config *config)
165{
166 if (config->verbose)
167 printf("set cpu affinity to cpu #%u\n", config->cpu);
168
169 set_cpu_affinity(config->cpu);
170
171 switch (config->prio) {
172 case SCHED_HIGH:
173 if (config->verbose)
174 printf("high priority condition requested\n");
175
176 set_process_priority(PRIORITY_HIGH);
177 break;
178 case SCHED_LOW:
179 if (config->verbose)
180 printf("low priority condition requested\n");
181
182 set_process_priority(PRIORITY_LOW);
183 break;
184 default:
185 if (config->verbose)
186 printf("default priority condition requested\n");
187
188 set_process_priority(PRIORITY_DEFAULT);
189 }
190}
191
diff --git a/tools/power/cpupower/bench/system.h b/tools/power/cpupower/bench/system.h
new file mode 100644
index 000000000000..3a8c858b78f0
--- /dev/null
+++ b/tools/power/cpupower/bench/system.h
@@ -0,0 +1,29 @@
1/* cpufreq-bench CPUFreq microbenchmark
2 *
3 * Copyright (C) 2008 Christian Kornacker <ckornacker@suse.de>
4 *
5 * This program is free software; you can redistribute it and/or modify
6 * it under the terms of the GNU General Public License as published by
7 * the Free Software Foundation; either version 2 of the License, or
8 * (at your option) any later version.
9 *
10 * This program is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 * GNU General Public License for more details.
14 *
15 * You should have received a copy of the GNU General Public License
16 * along with this program; if not, write to the Free Software
17 * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
18 */
19
20#include "parse.h"
21
22long long get_time();
23
24int set_cpufreq_governor(char *governor, unsigned int cpu);
25int set_cpu_affinity(unsigned int cpu);
26int set_process_priority(int priority);
27
28void prepare_user(const struct config *config);
29void prepare_system(const struct config *config);