aboutsummaryrefslogtreecommitdiffstats
path: root/tools/power/cpupower
diff options
context:
space:
mode:
Diffstat (limited to 'tools/power/cpupower')
-rw-r--r--tools/power/cpupower/.gitignore29
-rw-r--r--tools/power/cpupower/Makefile280
-rw-r--r--tools/power/cpupower/README49
-rw-r--r--tools/power/cpupower/ToDo11
-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
-rw-r--r--tools/power/cpupower/debug/i386/Makefile20
-rw-r--r--tools/power/cpupower/debug/i386/centrino-decode.c113
-rw-r--r--tools/power/cpupower/debug/i386/dump_psb.c196
-rw-r--r--tools/power/cpupower/debug/i386/intel_gsic.c78
-rw-r--r--tools/power/cpupower/debug/i386/powernow-k8-decode.c96
-rw-r--r--tools/power/cpupower/debug/kernel/Makefile23
-rw-r--r--tools/power/cpupower/debug/kernel/cpufreq-test_tsc.c113
-rw-r--r--tools/power/cpupower/debug/x86_64/Makefile14
-rw-r--r--tools/power/cpupower/lib/cpufreq.c208
-rw-r--r--tools/power/cpupower/lib/cpufreq.h223
-rw-r--r--tools/power/cpupower/lib/sysfs.c672
-rw-r--r--tools/power/cpupower/lib/sysfs.h31
-rw-r--r--tools/power/cpupower/man/cpupower-frequency-info.176
-rw-r--r--tools/power/cpupower/man/cpupower-frequency-set.154
-rw-r--r--tools/power/cpupower/man/cpupower-info.119
-rw-r--r--tools/power/cpupower/man/cpupower-monitor.1179
-rw-r--r--tools/power/cpupower/man/cpupower-set.1103
-rw-r--r--tools/power/cpupower/man/cpupower.172
-rw-r--r--tools/power/cpupower/po/cs.po944
-rw-r--r--tools/power/cpupower/po/de.po961
-rw-r--r--tools/power/cpupower/po/fr.po947
-rw-r--r--tools/power/cpupower/po/it.po961
-rw-r--r--tools/power/cpupower/po/pt.po957
-rw-r--r--tools/power/cpupower/utils/builtin.h11
-rw-r--r--tools/power/cpupower/utils/cpufreq-info.c668
-rw-r--r--tools/power/cpupower/utils/cpufreq-set.c331
-rw-r--r--tools/power/cpupower/utils/cpuidle-info.c222
-rw-r--r--tools/power/cpupower/utils/cpupower-info.c135
-rw-r--r--tools/power/cpupower/utils/cpupower-set.c134
-rw-r--r--tools/power/cpupower/utils/cpupower.c214
-rw-r--r--tools/power/cpupower/utils/helpers/amd.c137
-rw-r--r--tools/power/cpupower/utils/helpers/bitmask.c292
-rw-r--r--tools/power/cpupower/utils/helpers/bitmask.h33
-rw-r--r--tools/power/cpupower/utils/helpers/cpuid.c176
-rw-r--r--tools/power/cpupower/utils/helpers/helpers.h190
-rw-r--r--tools/power/cpupower/utils/helpers/misc.c27
-rw-r--r--tools/power/cpupower/utils/helpers/msr.c115
-rw-r--r--tools/power/cpupower/utils/helpers/pci.c44
-rw-r--r--tools/power/cpupower/utils/helpers/sysfs.c408
-rw-r--r--tools/power/cpupower/utils/helpers/sysfs.h30
-rw-r--r--tools/power/cpupower/utils/helpers/topology.c111
-rw-r--r--tools/power/cpupower/utils/idle_monitor/amd_fam14h_idle.c338
-rw-r--r--tools/power/cpupower/utils/idle_monitor/cpuidle_sysfs.c196
-rw-r--r--tools/power/cpupower/utils/idle_monitor/cpupower-monitor.c440
-rw-r--r--tools/power/cpupower/utils/idle_monitor/cpupower-monitor.h68
-rw-r--r--tools/power/cpupower/utils/idle_monitor/idle_monitors.def7
-rw-r--r--tools/power/cpupower/utils/idle_monitor/idle_monitors.h18
-rw-r--r--tools/power/cpupower/utils/idle_monitor/mperf_monitor.c338
-rw-r--r--tools/power/cpupower/utils/idle_monitor/nhm_idle.c216
-rw-r--r--tools/power/cpupower/utils/idle_monitor/snb_idle.c190
-rwxr-xr-xtools/power/cpupower/utils/version-gen.sh35
68 files changed, 13881 insertions, 0 deletions
diff --git a/tools/power/cpupower/.gitignore b/tools/power/cpupower/.gitignore
new file mode 100644
index 00000000000..d42073f1260
--- /dev/null
+++ b/tools/power/cpupower/.gitignore
@@ -0,0 +1,29 @@
1.libs
2libcpupower.so
3libcpupower.so.0
4libcpupower.so.0.0.0
5build/ccdv
6cpufreq-info
7cpufreq-set
8cpufreq-aperf
9lib/.libs
10lib/cpufreq.lo
11lib/cpufreq.o
12lib/proc.lo
13lib/proc.o
14lib/sysfs.lo
15lib/sysfs.o
16po/cpupowerutils.pot
17po/*.gmo
18utils/cpufreq-info.o
19utils/cpufreq-set.o
20utils/cpufreq-aperf.o
21cpupower
22bench/cpufreq-bench
23debug/kernel/Module.symvers
24debug/i386/centrino-decode
25debug/i386/dump_psb
26debug/i386/intel_gsic
27debug/i386/powernow-k8-decode
28debug/x86_64/centrino-decode
29debug/x86_64/powernow-k8-decode
diff --git a/tools/power/cpupower/Makefile b/tools/power/cpupower/Makefile
new file mode 100644
index 00000000000..e8a03aceceb
--- /dev/null
+++ b/tools/power/cpupower/Makefile
@@ -0,0 +1,280 @@
1# Makefile for cpupower
2#
3# Copyright (C) 2005,2006 Dominik Brodowski <linux@dominikbrodowski.net>
4#
5# Based largely on the Makefile for udev by:
6#
7# Copyright (C) 2003,2004 Greg Kroah-Hartman <greg@kroah.com>
8#
9# This program is free software; you can redistribute it and/or modify
10# it under the terms of the GNU General Public License as published by
11# the Free Software Foundation; version 2 of the License.
12#
13# This program is distributed in the hope that it will be useful,
14# but WITHOUT ANY WARRANTY; without even the implied warranty of
15# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
16# General Public License for more details.
17#
18# You should have received a copy of the GNU General Public License
19# along with this program; if not, write to the Free Software
20# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
21#
22
23# --- CONFIGURATION BEGIN ---
24
25# Set the following to `true' to make a unstripped, unoptimized
26# binary. Leave this set to `false' for production use.
27DEBUG ?= true
28
29# make the build silent. Set this to something else to make it noisy again.
30V ?= false
31
32# Internationalization support (output in different languages).
33# Requires gettext.
34NLS ?= true
35
36# Set the following to 'true' to build/install the
37# cpufreq-bench benchmarking tool
38CPUFREQ_BENCH ?= true
39
40# Prefix to the directories we're installing to
41DESTDIR ?=
42
43# --- CONFIGURATION END ---
44
45
46
47# Package-related definitions. Distributions can modify the version
48# and _should_ modify the PACKAGE_BUGREPORT definition
49
50VERSION= $(shell ./utils/version-gen.sh)
51LIB_MAJ= 0.0.0
52LIB_MIN= 0
53
54PACKAGE = cpupower
55PACKAGE_BUGREPORT = cpufreq@vger.kernel.org
56LANGUAGES = de fr it cs pt
57
58
59# Directory definitions. These are default and most probably
60# do not need to be changed. Please note that DESTDIR is
61# added in front of any of them
62
63bindir ?= /usr/bin
64sbindir ?= /usr/sbin
65mandir ?= /usr/man
66includedir ?= /usr/include
67libdir ?= /usr/lib
68localedir ?= /usr/share/locale
69docdir ?= /usr/share/doc/packages/cpupower
70confdir ?= /etc/
71
72# Toolchain: what tools do we use, and what options do they need:
73
74CP = cp -fpR
75INSTALL = /usr/bin/install -c
76INSTALL_PROGRAM = ${INSTALL}
77INSTALL_DATA = ${INSTALL} -m 644
78INSTALL_SCRIPT = ${INSTALL_PROGRAM}
79
80# If you are running a cross compiler, you may want to set this
81# to something more interesting, like "arm-linux-". If you want
82# to compile vs uClibc, that can be done here as well.
83CROSS = #/usr/i386-linux-uclibc/usr/bin/i386-uclibc-
84CC = $(CROSS)gcc
85LD = $(CROSS)gcc
86AR = $(CROSS)ar
87STRIP = $(CROSS)strip
88RANLIB = $(CROSS)ranlib
89HOSTCC = gcc
90
91
92# Now we set up the build system
93#
94
95# set up PWD so that older versions of make will work with our build.
96PWD = $(shell pwd)
97
98GMO_FILES = ${shell for HLANG in ${LANGUAGES}; do echo po/$$HLANG.gmo; done;}
99
100export CROSS CC AR STRIP RANLIB CFLAGS LDFLAGS LIB_OBJS
101
102# check if compiler option is supported
103cc-supports = ${shell if $(CC) ${1} -S -o /dev/null -xc /dev/null > /dev/null 2>&1; then echo "$(1)"; fi;}
104
105# use '-Os' optimization if available, else use -O2
106OPTIMIZATION := $(call cc-supports,-Os,-O2)
107
108WARNINGS := -Wall -Wchar-subscripts -Wpointer-arith -Wsign-compare
109WARNINGS += $(call cc-supports,-Wno-pointer-sign)
110WARNINGS += $(call cc-supports,-Wdeclaration-after-statement)
111WARNINGS += -Wshadow
112
113CFLAGS += -DVERSION=\"$(VERSION)\" -DPACKAGE=\"$(PACKAGE)\" \
114 -DPACKAGE_BUGREPORT=\"$(PACKAGE_BUGREPORT)\" -D_GNU_SOURCE
115
116UTIL_OBJS = utils/helpers/amd.o utils/helpers/topology.o utils/helpers/msr.o \
117 utils/helpers/sysfs.o utils/helpers/misc.o utils/helpers/cpuid.o \
118 utils/helpers/pci.o utils/helpers/bitmask.o \
119 utils/idle_monitor/nhm_idle.o utils/idle_monitor/snb_idle.o \
120 utils/idle_monitor/amd_fam14h_idle.o utils/idle_monitor/cpuidle_sysfs.o \
121 utils/idle_monitor/mperf_monitor.o utils/idle_monitor/cpupower-monitor.o \
122 utils/cpupower.o utils/cpufreq-info.o utils/cpufreq-set.o \
123 utils/cpupower-set.o utils/cpupower-info.o utils/cpuidle-info.o
124
125UTIL_HEADERS = utils/helpers/helpers.h utils/idle_monitor/cpupower-monitor.h \
126 utils/helpers/bitmask.h \
127 utils/idle_monitor/idle_monitors.h utils/idle_monitor/idle_monitors.def
128
129UTIL_SRC := $(UTIL_OBJS:.o=.c)
130
131LIB_HEADERS = lib/cpufreq.h lib/sysfs.h
132LIB_SRC = lib/cpufreq.c lib/sysfs.c
133LIB_OBJS = lib/cpufreq.o lib/sysfs.o
134
135CFLAGS += -pipe
136
137ifeq ($(strip $(NLS)),true)
138 INSTALL_NLS += install-gmo
139 COMPILE_NLS += create-gmo
140 CFLAGS += -DNLS
141endif
142
143ifeq ($(strip $(CPUFREQ_BENCH)),true)
144 INSTALL_BENCH += install-bench
145 COMPILE_BENCH += compile-bench
146endif
147
148CFLAGS += $(WARNINGS)
149
150ifeq ($(strip $(V)),false)
151 QUIET=@
152 ECHO=@echo
153else
154 QUIET=
155 ECHO=@\#
156endif
157export QUIET ECHO
158
159# if DEBUG is enabled, then we do not strip or optimize
160ifeq ($(strip $(DEBUG)),true)
161 CFLAGS += -O1 -g -DDEBUG
162 STRIPCMD = /bin/true -Since_we_are_debugging
163else
164 CFLAGS += $(OPTIMIZATION) -fomit-frame-pointer
165 STRIPCMD = $(STRIP) -s --remove-section=.note --remove-section=.comment
166endif
167
168
169# the actual make rules
170
171all: libcpupower cpupower $(COMPILE_NLS) $(COMPILE_BENCH)
172
173lib/%.o: $(LIB_SRC) $(LIB_HEADERS)
174 $(ECHO) " CC " $@
175 $(QUIET) $(CC) $(CFLAGS) -fPIC -o $@ -c lib/$*.c
176
177libcpupower.so.$(LIB_MAJ): $(LIB_OBJS)
178 $(ECHO) " LD " $@
179 $(QUIET) $(CC) -shared $(CFLAGS) $(LDFLAGS) -o $@ \
180 -Wl,-soname,libcpupower.so.$(LIB_MIN) $(LIB_OBJS)
181 @ln -sf $@ libcpupower.so
182 @ln -sf $@ libcpupower.so.$(LIB_MIN)
183
184libcpupower: libcpupower.so.$(LIB_MAJ)
185
186# Let all .o files depend on its .c file and all headers
187# Might be worth to put this into utils/Makefile at some point of time
188$(UTIL_OBJS): $(UTIL_HEADERS)
189
190.c.o:
191 $(ECHO) " CC " $@
192 $(QUIET) $(CC) $(CFLAGS) -I./lib -I ./utils -o $@ -c $*.c
193
194cpupower: $(UTIL_OBJS) libcpupower.so.$(LIB_MAJ)
195 $(ECHO) " CC " $@
196 $(QUIET) $(CC) $(CFLAGS) $(LDFLAGS) -lcpupower -lrt -lpci -L. -o $@ $(UTIL_OBJS)
197 $(QUIET) $(STRIPCMD) $@
198
199po/$(PACKAGE).pot: $(UTIL_SRC)
200 $(ECHO) " GETTEXT " $@
201 $(QUIET) xgettext --default-domain=$(PACKAGE) --add-comments \
202 --keyword=_ --keyword=N_ $(UTIL_SRC) && \
203 test -f $(PACKAGE).po && \
204 mv -f $(PACKAGE).po po/$(PACKAGE).pot
205
206po/%.gmo: po/%.po
207 $(ECHO) " MSGFMT " $@
208 $(QUIET) msgfmt -o $@ po/$*.po
209
210create-gmo: ${GMO_FILES}
211
212update-po: po/$(PACKAGE).pot
213 $(ECHO) " MSGMRG " $@
214 $(QUIET) @for HLANG in $(LANGUAGES); do \
215 echo -n "Updating $$HLANG "; \
216 if msgmerge po/$$HLANG.po po/$(PACKAGE).pot -o \
217 po/$$HLANG.new.po; then \
218 mv -f po/$$HLANG.new.po po/$$HLANG.po; \
219 else \
220 echo "msgmerge for $$HLANG failed!"; \
221 rm -f po/$$HLANG.new.po; \
222 fi; \
223 done;
224
225compile-bench: libcpupower.so.$(LIB_MAJ)
226 @V=$(V) confdir=$(confdir) $(MAKE) -C bench
227
228clean:
229 -find . \( -not -type d \) -and \( -name '*~' -o -name '*.[oas]' \) -type f -print \
230 | xargs rm -f
231 -rm -f $(UTIL_BINS)
232 -rm -f $(IDLE_OBJS)
233 -rm -f cpupower
234 -rm -f libcpupower.so*
235 -rm -rf po/*.gmo po/*.pot
236 $(MAKE) -C bench clean
237
238
239install-lib:
240 $(INSTALL) -d $(DESTDIR)${libdir}
241 $(CP) libcpupower.so* $(DESTDIR)${libdir}/
242 $(INSTALL) -d $(DESTDIR)${includedir}
243 $(INSTALL_DATA) lib/cpufreq.h $(DESTDIR)${includedir}/cpufreq.h
244
245install-tools:
246 $(INSTALL) -d $(DESTDIR)${bindir}
247 $(INSTALL_PROGRAM) cpupower $(DESTDIR)${bindir}
248
249install-man:
250 $(INSTALL_DATA) -D man/cpupower.1 $(DESTDIR)${mandir}/man1/cpupower.1
251 $(INSTALL_DATA) -D man/cpupower-frequency-set.1 $(DESTDIR)${mandir}/man1/cpupower-frequency-set.1
252 $(INSTALL_DATA) -D man/cpupower-frequency-info.1 $(DESTDIR)${mandir}/man1/cpupower-frequency-info.1
253 $(INSTALL_DATA) -D man/cpupower-set.1 $(DESTDIR)${mandir}/man1/cpupower-set.1
254 $(INSTALL_DATA) -D man/cpupower-info.1 $(DESTDIR)${mandir}/man1/cpupower-info.1
255 $(INSTALL_DATA) -D man/cpupower-monitor.1 $(DESTDIR)${mandir}/man1/cpupower-monitor.1
256
257install-gmo:
258 $(INSTALL) -d $(DESTDIR)${localedir}
259 for HLANG in $(LANGUAGES); do \
260 echo '$(INSTALL_DATA) -D po/$$HLANG.gmo $(DESTDIR)${localedir}/$$HLANG/LC_MESSAGES/cpupower.mo'; \
261 $(INSTALL_DATA) -D po/$$HLANG.gmo $(DESTDIR)${localedir}/$$HLANG/LC_MESSAGES/cpupower.mo; \
262 done;
263
264install-bench:
265 @#DESTDIR must be set from outside to survive
266 @sbindir=$(sbindir) bindir=$(bindir) docdir=$(docdir) confdir=$(confdir) $(MAKE) -C bench install
267
268install: all install-lib install-tools install-man $(INSTALL_NLS) $(INSTALL_BENCH)
269
270uninstall:
271 - rm -f $(DESTDIR)${libdir}/libcpupower.*
272 - rm -f $(DESTDIR)${includedir}/cpufreq.h
273 - rm -f $(DESTDIR)${bindir}/utils/cpupower
274 - rm -f $(DESTDIR)${mandir}/man1/cpufreq-set.1
275 - rm -f $(DESTDIR)${mandir}/man1/cpufreq-info.1
276 - for HLANG in $(LANGUAGES); do \
277 rm -f $(DESTDIR)${localedir}/$$HLANG/LC_MESSAGES/cpupower.mo; \
278 done;
279
280.PHONY: all utils libcpupower update-po create-gmo install-lib install-tools install-man install-gmo install uninstall clean
diff --git a/tools/power/cpupower/README b/tools/power/cpupower/README
new file mode 100644
index 00000000000..fd9d4c0d668
--- /dev/null
+++ b/tools/power/cpupower/README
@@ -0,0 +1,49 @@
1The cpufrequtils package (homepage:
2http://www.kernel.org/pub/linux/utils/kernel/cpufreq/cpufrequtils.html )
3consists of the following elements:
4
5requirements
6------------
7
8On x86 pciutils is needed at runtime (-lpci).
9For compilation pciutils-devel (pci/pci.h) and a gcc version
10providing cpuid.h is needed.
11For both it's not explicitly checked for (yet).
12
13
14libcpufreq
15----------
16
17"libcpufreq" is a library which offers a unified access method for userspace
18tools and programs to the cpufreq core and drivers in the Linux kernel. This
19allows for code reduction in userspace tools, a clean implementation of
20the interaction to the cpufreq core, and support for both the sysfs and proc
21interfaces [depending on configuration, see below].
22
23
24compilation and installation
25----------------------------
26
27make
28su
29make install
30
31should suffice on most systems. It builds default libcpufreq,
32cpufreq-set and cpufreq-info files and installs them in /usr/lib and
33/usr/bin, respectively. If you want to set up the paths differently and/or
34want to configure the package to your specific needs, you need to open
35"Makefile" with an editor of your choice and edit the block marked
36CONFIGURATION.
37
38
39THANKS
40------
41Many thanks to Mattia Dongili who wrote the autotoolization and
42libtoolization, the manpages and the italian language file for cpufrequtils;
43to Dave Jones for his feedback and his dump_psb tool; to Bruno Ducrot for his
44powernow-k8-decode and intel_gsic tools as well as the french language file;
45and to various others commenting on the previous (pre-)releases of
46cpufrequtils.
47
48
49 Dominik Brodowski
diff --git a/tools/power/cpupower/ToDo b/tools/power/cpupower/ToDo
new file mode 100644
index 00000000000..874b78b586e
--- /dev/null
+++ b/tools/power/cpupower/ToDo
@@ -0,0 +1,11 @@
1ToDos sorted by priority:
2
3- Use bitmask functions to parse CPU topology more robust
4 (current implementation has issues on AMD)
5- Try to read out boost states and frequencies on Intel
6- Adjust README
7- Somewhere saw the ability to read power consumption of
8 RAM from HW on Intel SandyBridge -> another monitor?
9- Add another c1e debug idle monitor
10 -> Is by design racy with BIOS, but could be added
11 with a --force option and some "be careful" messages
diff --git a/tools/power/cpupower/bench/Makefile b/tools/power/cpupower/bench/Makefile
new file mode 100644
index 00000000000..2b67606fc3e
--- /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 00000000000..8093ec73817
--- /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 00000000000..81b1c48607d
--- /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 00000000000..51d7f50ac2b
--- /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 00000000000..ee6f258e533
--- /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 00000000000..410021a12f4
--- /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 00000000000..de20d2a0687
--- /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 00000000000..f91f6436068
--- /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 00000000000..24910313a52
--- /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 00000000000..543bba14ae2
--- /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 00000000000..a8dc632d9ee
--- /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 00000000000..f01e3f4be84
--- /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 00000000000..3a8c858b78f
--- /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);
diff --git a/tools/power/cpupower/debug/i386/Makefile b/tools/power/cpupower/debug/i386/Makefile
new file mode 100644
index 00000000000..d08cc1ead9b
--- /dev/null
+++ b/tools/power/cpupower/debug/i386/Makefile
@@ -0,0 +1,20 @@
1default: all
2
3centrino-decode: centrino-decode.c
4 $(CC) $(CFLAGS) -o centrino-decode centrino-decode.c
5
6dump_psb: dump_psb.c
7 $(CC) $(CFLAGS) -o dump_psb dump_psb.c
8
9intel_gsic: intel_gsic.c
10 $(CC) $(CFLAGS) -o intel_gsic -llrmi intel_gsic.c
11
12powernow-k8-decode: powernow-k8-decode.c
13 $(CC) $(CFLAGS) -o powernow-k8-decode powernow-k8-decode.c
14
15all: centrino-decode dump_psb intel_gsic powernow-k8-decode
16
17clean:
18 rm -rf centrino-decode dump_psb intel_gsic powernow-k8-decode
19
20.PHONY: all default clean
diff --git a/tools/power/cpupower/debug/i386/centrino-decode.c b/tools/power/cpupower/debug/i386/centrino-decode.c
new file mode 100644
index 00000000000..7ef24cce492
--- /dev/null
+++ b/tools/power/cpupower/debug/i386/centrino-decode.c
@@ -0,0 +1,113 @@
1/*
2 * (C) 2003 - 2004 Dominik Brodowski <linux@dominikbrodowski.de>
3 *
4 * Licensed under the terms of the GNU GPL License version 2.
5 *
6 * Based on code found in
7 * linux/arch/i386/kernel/cpu/cpufreq/speedstep-centrino.c
8 * and originally developed by Jeremy Fitzhardinge.
9 *
10 * USAGE: simply run it to decode the current settings on CPU 0,
11 * or pass the CPU number as argument, or pass the MSR content
12 * as argument.
13 */
14
15#include <stdio.h>
16#include <stdlib.h>
17#include <stdint.h>
18#include <unistd.h>
19#include <errno.h>
20#include <fcntl.h>
21
22#include <sys/types.h>
23#include <sys/stat.h>
24
25#define MCPU 32
26
27#define MSR_IA32_PERF_STATUS 0x198
28
29static int rdmsr(unsigned int cpu, unsigned int msr,
30 unsigned int *lo, unsigned int *hi)
31{
32 int fd;
33 char file[20];
34 unsigned long long val;
35 int retval = -1;
36
37 *lo = *hi = 0;
38
39 if (cpu > MCPU)
40 goto err1;
41
42 sprintf(file, "/dev/cpu/%d/msr", cpu);
43 fd = open(file, O_RDONLY);
44
45 if (fd < 0)
46 goto err1;
47
48 if (lseek(fd, msr, SEEK_CUR) == -1)
49 goto err2;
50
51 if (read(fd, &val, 8) != 8)
52 goto err2;
53
54 *lo = (uint32_t )(val & 0xffffffffull);
55 *hi = (uint32_t )(val>>32 & 0xffffffffull);
56
57 retval = 0;
58err2:
59 close(fd);
60err1:
61 return retval;
62}
63
64static void decode (unsigned int msr)
65{
66 unsigned int multiplier;
67 unsigned int mv;
68
69 multiplier = ((msr >> 8) & 0xFF);
70
71 mv = (((msr & 0xFF) * 16) + 700);
72
73 printf("0x%x means multiplier %d @ %d mV\n", msr, multiplier, mv);
74}
75
76static int decode_live(unsigned int cpu)
77{
78 unsigned int lo, hi;
79 int err;
80
81 err = rdmsr(cpu, MSR_IA32_PERF_STATUS, &lo, &hi);
82
83 if (err) {
84 printf("can't get MSR_IA32_PERF_STATUS for cpu %d\n", cpu);
85 printf("Possible trouble: you don't run an Enhanced SpeedStep capable cpu\n");
86 printf("or you are not root, or the msr driver is not present\n");
87 return 1;
88 }
89
90 decode(lo);
91
92 return 0;
93}
94
95int main (int argc, char **argv)
96{
97 unsigned int cpu, mode = 0;
98
99 if (argc < 2)
100 cpu = 0;
101 else {
102 cpu = strtoul(argv[1], NULL, 0);
103 if (cpu >= MCPU)
104 mode = 1;
105 }
106
107 if (mode)
108 decode(cpu);
109 else
110 decode_live(cpu);
111
112 return 0;
113}
diff --git a/tools/power/cpupower/debug/i386/dump_psb.c b/tools/power/cpupower/debug/i386/dump_psb.c
new file mode 100644
index 00000000000..8d6a4751425
--- /dev/null
+++ b/tools/power/cpupower/debug/i386/dump_psb.c
@@ -0,0 +1,196 @@
1/*
2 * dump_psb. (c) 2004, Dave Jones, Red Hat Inc.
3 * Licensed under the GPL v2.
4 */
5
6#include <fcntl.h>
7#include <stdio.h>
8#include <stdlib.h>
9#include <string.h>
10#include <unistd.h>
11
12#define _GNU_SOURCE
13#include <getopt.h>
14
15#include <sys/mman.h>
16
17#define LEN (0x100000 - 0xc0000)
18#define OFFSET (0xc0000)
19
20#ifndef __packed
21#define __packed __attribute((packed))
22#endif
23
24static long relevant;
25
26static const int fid_to_mult[32] = {
27 110, 115, 120, 125, 50, 55, 60, 65,
28 70, 75, 80, 85, 90, 95, 100, 105,
29 30, 190, 40, 200, 130, 135, 140, 210,
30 150, 225, 160, 165, 170, 180, -1, -1,
31};
32
33static const int vid_to_voltage[32] = {
34 2000, 1950, 1900, 1850, 1800, 1750, 1700, 1650,
35 1600, 1550, 1500, 1450, 1400, 1350, 1300, 0,
36 1275, 1250, 1225, 1200, 1175, 1150, 1125, 1100,
37 1075, 1050, 1024, 1000, 975, 950, 925, 0,
38};
39
40struct psb_header {
41 char signature[10];
42 u_char version;
43 u_char flags;
44 u_short settlingtime;
45 u_char res1;
46 u_char numpst;
47} __packed;
48
49struct pst_header {
50 u_int32_t cpuid;
51 u_char fsb;
52 u_char maxfid;
53 u_char startvid;
54 u_char numpstates;
55} __packed;
56
57static u_int fsb;
58static u_int sgtc;
59
60static int
61decode_pst(char *p, int npstates)
62{
63 int i;
64 int freq, fid, vid;
65
66 for (i = 0; i < npstates; ++i) {
67 fid = *p++;
68 vid = *p++;
69 freq = 100 * fid_to_mult[fid] * fsb;
70
71 printf(" %2d %8dkHz FID %02x (%2d.%01d) VID %02x (%4dmV)\n",
72 i,
73 freq,
74 fid, fid_to_mult[fid]/10, fid_to_mult[fid]%10,
75 vid, vid_to_voltage[vid]);
76 }
77
78 return 0;
79}
80
81static
82void decode_psb(char *p, int numpst)
83{
84 int i;
85 struct psb_header *psb;
86 struct pst_header *pst;
87
88 psb = (struct psb_header*) p;
89
90 if (psb->version != 0x12)
91 return;
92
93 printf("PSB version: %hhx flags: %hhx settling time %hhuus res1 %hhx num pst %hhu\n",
94 psb->version,
95 psb->flags,
96 psb->settlingtime,
97 psb->res1,
98 psb->numpst);
99 sgtc = psb->settlingtime * 100;
100
101 if (sgtc < 10000)
102 sgtc = 10000;
103
104 p = ((char *) psb) + sizeof(struct psb_header);
105
106 if (numpst < 0)
107 numpst = psb->numpst;
108 else
109 printf("Overriding number of pst :%d\n", numpst);
110
111 for (i = 0; i < numpst; i++) {
112 pst = (struct pst_header*) p;
113
114 if (relevant != 0) {
115 if (relevant!= pst->cpuid)
116 goto next_one;
117 }
118
119 printf(" PST %d cpuid %.3x fsb %hhu mfid %hhx svid %hhx numberstates %hhu\n",
120 i+1,
121 pst->cpuid,
122 pst->fsb,
123 pst->maxfid,
124 pst->startvid,
125 pst->numpstates);
126
127 fsb = pst->fsb;
128 decode_pst(p + sizeof(struct pst_header), pst->numpstates);
129
130next_one:
131 p += sizeof(struct pst_header) + 2*pst->numpstates;
132 }
133
134}
135
136static struct option info_opts[] = {
137 {.name = "numpst", .has_arg=no_argument, .flag=NULL, .val='n'},
138};
139
140void print_help(void)
141{
142 printf ("Usage: dump_psb [options]\n");
143 printf ("Options:\n");
144 printf (" -n, --numpst Set number of PST tables to scan\n");
145 printf (" -r, --relevant Only display PSTs relevant to cpuid N\n");
146}
147
148int
149main(int argc, char *argv[])
150{
151 int fd;
152 int numpst=-1;
153 int ret=0, cont=1;
154 char *mem = NULL;
155 char *p;
156
157 do {
158 ret = getopt_long(argc, argv, "hr:n:", info_opts, NULL);
159 switch (ret){
160 case '?':
161 case 'h':
162 print_help();
163 cont = 0;
164 break;
165 case 'r':
166 relevant = strtol(optarg, NULL, 16);
167 break;
168 case 'n':
169 numpst = strtol(optarg, NULL, 10);
170 break;
171 case -1:
172 cont = 0;
173 break;
174 }
175
176 } while(cont);
177
178 fd = open("/dev/mem", O_RDONLY);
179 if (fd < 0) {
180 printf ("Couldn't open /dev/mem. Are you root?\n");
181 exit(1);
182 }
183
184 mem = mmap(mem, 0x100000 - 0xc0000, PROT_READ, MAP_SHARED, fd, 0xc0000);
185 close(fd);
186
187 for (p = mem; p - mem < LEN; p+=16) {
188 if (memcmp(p, "AMDK7PNOW!", 10) == 0) {
189 decode_psb(p, numpst);
190 break;
191 }
192 }
193
194 munmap(mem, LEN);
195 return 0;
196}
diff --git a/tools/power/cpupower/debug/i386/intel_gsic.c b/tools/power/cpupower/debug/i386/intel_gsic.c
new file mode 100644
index 00000000000..53f5293c9c9
--- /dev/null
+++ b/tools/power/cpupower/debug/i386/intel_gsic.c
@@ -0,0 +1,78 @@
1/*
2 * (C) 2003 Bruno Ducrot
3 * (C) 2004 Dominik Brodowski <linux@dominikbrodowski.de>
4 *
5 * Licensed under the terms of the GNU GPL License version 2.
6 *
7 * Based on code found in
8 * linux/include/asm-i386/ist.h and linux/arch/i386/kernel/setup.c
9 * and originally developed by Andy Grover <andrew.grover@intel.com>
10 */
11
12#include <stdio.h>
13#include <string.h>
14#include <lrmi.h>
15
16int main (void)
17{
18 struct LRMI_regs r;
19 int retval;
20
21 if (!LRMI_init())
22 return 0;
23
24 memset(&r, 0, sizeof(r));
25
26 r.eax = 0x0000E980;
27 r.edx = 0x47534943;
28
29 retval = LRMI_int(0x15, &r);
30
31 if (!retval) {
32 printf("Failed!\n");
33 return 0;
34 }
35 if (r.eax == 0x47534943) {
36 printf("BIOS supports GSIC call:\n");
37 printf("\tsignature: %c%c%c%c\n",
38 (r.eax >> 24) & 0xff,
39 (r.eax >> 16) & 0xff,
40 (r.eax >> 8) & 0xff,
41 (r.eax) & 0xff);
42 printf("\tcommand port = 0x%.4x\n",
43 r.ebx & 0xffff);
44 printf("\tcommand = 0x%.4x\n",
45 (r.ebx >> 16) & 0xffff);
46 printf("\tevent port = 0x%.8x\n", r.ecx);
47 printf("\tflags = 0x%.8x\n", r.edx);
48 if (((r.ebx >> 16) & 0xffff) != 0x82) {
49 printf("non-default command value. If speedstep-smi "
50 "doesn't work out of the box,\nyou may want to "
51 "try out the default value by passing "
52 "smi_cmd=0x82 to the module\n ON YOUR OWN "
53 "RISK.\n");
54 }
55 if ((r.ebx & 0xffff) != 0xb2) {
56 printf("non-default command port. If speedstep-smi "
57 "doesn't work out of the box,\nyou may want to "
58 "try out the default value by passing "
59 "smi_port=0x82 to the module\n ON YOUR OWN "
60 "RISK.\n");
61 }
62 } else {
63 printf("BIOS DOES NOT support GSIC call. Dumping registers anyway:\n");
64 printf("eax = 0x%.8x\n", r.eax);
65 printf("ebx = 0x%.8x\n", r.ebx);
66 printf("ecx = 0x%.8x\n", r.ecx);
67 printf("edx = 0x%.8x\n", r.edx);
68 printf("Note also that some BIOS do not support the initial "
69 "GSIC call, but the newer\nspeeedstep-smi driver may "
70 "work.\nFor this, you need to pass some arguments to "
71 "the speedstep-smi driver:\n");
72 printf("\tsmi_cmd=0x?? smi_port=0x?? smi_sig=1\n");
73 printf("\nUnfortunately, you have to know what exactly are "
74 "smi_cmd and smi_port, and this\nis system "
75 "dependant.\n");
76 }
77 return 1;
78}
diff --git a/tools/power/cpupower/debug/i386/powernow-k8-decode.c b/tools/power/cpupower/debug/i386/powernow-k8-decode.c
new file mode 100644
index 00000000000..638a6b3bfd9
--- /dev/null
+++ b/tools/power/cpupower/debug/i386/powernow-k8-decode.c
@@ -0,0 +1,96 @@
1/*
2 * (C) 2004 Bruno Ducrot <ducrot@poupinou.org>
3 *
4 * Licensed under the terms of the GNU GPL License version 2.
5 *
6 * Based on code found in
7 * linux/arch/i386/kernel/cpu/cpufreq/powernow-k8.c
8 * and originally developed by Paul Devriendt
9 */
10
11#include <stdio.h>
12#include <stdlib.h>
13#include <stdint.h>
14#include <unistd.h>
15#include <errno.h>
16#include <fcntl.h>
17
18#include <sys/types.h>
19#include <sys/stat.h>
20
21#define MCPU 32
22
23#define MSR_FIDVID_STATUS 0xc0010042
24
25#define MSR_S_HI_CURRENT_VID 0x0000001f
26#define MSR_S_LO_CURRENT_FID 0x0000003f
27
28static int get_fidvid(uint32_t cpu, uint32_t *fid, uint32_t *vid)
29{
30 int err = 1;
31 uint64_t msr = 0;
32 int fd;
33 char file[20];
34
35 if (cpu > MCPU)
36 goto out;
37
38 sprintf(file, "/dev/cpu/%d/msr", cpu);
39
40 fd = open(file, O_RDONLY);
41 if (fd < 0)
42 goto out;
43 lseek(fd, MSR_FIDVID_STATUS, SEEK_CUR);
44 if (read(fd, &msr, 8) != 8)
45 goto err1;
46
47 *fid = ((uint32_t )(msr & 0xffffffffull)) & MSR_S_LO_CURRENT_FID;
48 *vid = ((uint32_t )(msr>>32 & 0xffffffffull)) & MSR_S_HI_CURRENT_VID;
49 err = 0;
50err1:
51 close(fd);
52out:
53 return err;
54}
55
56
57/* Return a frequency in MHz, given an input fid */
58static uint32_t find_freq_from_fid(uint32_t fid)
59{
60 return 800 + (fid * 100);
61}
62
63/* Return a voltage in miliVolts, given an input vid */
64static uint32_t find_millivolts_from_vid(uint32_t vid)
65{
66 return 1550-vid*25;
67}
68
69int main (int argc, char *argv[])
70{
71 int err;
72 int cpu;
73 uint32_t fid, vid;
74
75 if (argc < 2)
76 cpu = 0;
77 else
78 cpu = strtoul(argv[1], NULL, 0);
79
80 err = get_fidvid(cpu, &fid, &vid);
81
82 if (err) {
83 printf("can't get fid, vid from MSR\n");
84 printf("Possible trouble: you don't run a powernow-k8 capable cpu\n");
85 printf("or you are not root, or the msr driver is not present\n");
86 exit(1);
87 }
88
89
90 printf("cpu %d currently at %d MHz and %d mV\n",
91 cpu,
92 find_freq_from_fid(fid),
93 find_millivolts_from_vid(vid));
94
95 return 0;
96}
diff --git a/tools/power/cpupower/debug/kernel/Makefile b/tools/power/cpupower/debug/kernel/Makefile
new file mode 100644
index 00000000000..96b146fe6f8
--- /dev/null
+++ b/tools/power/cpupower/debug/kernel/Makefile
@@ -0,0 +1,23 @@
1obj-m :=
2
3KDIR := /lib/modules/$(shell uname -r)/build
4PWD := $(shell pwd)
5KMISC := /lib/modules/$(shell uname -r)/cpufrequtils/
6
7ifeq ("$(CONFIG_X86_TSC)", "y")
8 obj-m += cpufreq-test_tsc.o
9endif
10
11default:
12 $(MAKE) -C $(KDIR) M=$(PWD)
13
14clean:
15 - rm -rf *.o *.ko .tmp-versions .*.cmd .*.mod.* *.mod.c
16 - rm -rf .tmp_versions* Module.symvers modules.order
17
18install: default
19 install -d $(KMISC)
20 install -m 644 -c *.ko $(KMISC)
21 /sbin/depmod -a
22
23all: default
diff --git a/tools/power/cpupower/debug/kernel/cpufreq-test_tsc.c b/tools/power/cpupower/debug/kernel/cpufreq-test_tsc.c
new file mode 100644
index 00000000000..66cace601e5
--- /dev/null
+++ b/tools/power/cpupower/debug/kernel/cpufreq-test_tsc.c
@@ -0,0 +1,113 @@
1/*
2 * test module to check whether the TSC-based delay routine continues
3 * to work properly after cpufreq transitions. Needs ACPI to work
4 * properly.
5 *
6 * Based partly on the Power Management Timer (PMTMR) code to be found
7 * in arch/i386/kernel/timers/timer_pm.c on recent 2.6. kernels, especially
8 * code written by John Stultz. The read_pmtmr function was copied verbatim
9 * from that file.
10 *
11 * (C) 2004 Dominik Brodowski
12 *
13 * To use:
14 * 1.) pass clock=tsc to the kernel on your bootloader
15 * 2.) modprobe this module (it'll fail)
16 * 3.) change CPU frequency
17 * 4.) modprobe this module again
18 * 5.) if the third value, "diff_pmtmr", changes between 2. and 4., the
19 * TSC-based delay routine on the Linux kernel does not correctly
20 * handle the cpufreq transition. Please report this to
21 * cpufreq@vger.kernel.org
22 */
23
24#include <linux/kernel.h>
25#include <linux/module.h>
26#include <linux/init.h>
27#include <linux/delay.h>
28
29#include <asm/io.h>
30
31#include <acpi/acpi_bus.h>
32#include <acpi/acpi_drivers.h>
33
34static int pm_tmr_ioport = 0;
35
36/*helper function to safely read acpi pm timesource*/
37static u32 read_pmtmr(void)
38{
39 u32 v1=0,v2=0,v3=0;
40 /* It has been reported that because of various broken
41 * chipsets (ICH4, PIIX4 and PIIX4E) where the ACPI PM time
42 * source is not latched, so you must read it multiple
43 * times to insure a safe value is read.
44 */
45 do {
46 v1 = inl(pm_tmr_ioport);
47 v2 = inl(pm_tmr_ioport);
48 v3 = inl(pm_tmr_ioport);
49 } while ((v1 > v2 && v1 < v3) || (v2 > v3 && v2 < v1)
50 || (v3 > v1 && v3 < v2));
51
52 /* mask the output to 24 bits */
53 return (v2 & 0xFFFFFF);
54}
55
56static int __init cpufreq_test_tsc(void)
57{
58 u32 now, then, diff;
59 u64 now_tsc, then_tsc, diff_tsc;
60 int i;
61
62 /* the following code snipped is copied from arch/x86/kernel/acpi/boot.c
63 of Linux v2.6.25. */
64
65 /* detect the location of the ACPI PM Timer */
66 if (acpi_gbl_FADT.header.revision >= FADT2_REVISION_ID) {
67 /* FADT rev. 2 */
68 if (acpi_gbl_FADT.xpm_timer_block.space_id !=
69 ACPI_ADR_SPACE_SYSTEM_IO)
70 return 0;
71
72 pm_tmr_ioport = acpi_gbl_FADT.xpm_timer_block.address;
73 /*
74 * "X" fields are optional extensions to the original V1.0
75 * fields, so we must selectively expand V1.0 fields if the
76 * corresponding X field is zero.
77 */
78 if (!pm_tmr_ioport)
79 pm_tmr_ioport = acpi_gbl_FADT.pm_timer_block;
80 } else {
81 /* FADT rev. 1 */
82 pm_tmr_ioport = acpi_gbl_FADT.pm_timer_block;
83 }
84
85 printk(KERN_DEBUG "start--> \n");
86 then = read_pmtmr();
87 rdtscll(then_tsc);
88 for (i=0;i<20;i++) {
89 mdelay(100);
90 now = read_pmtmr();
91 rdtscll(now_tsc);
92 diff = (now - then) & 0xFFFFFF;
93 diff_tsc = now_tsc - then_tsc;
94 printk(KERN_DEBUG "t1: %08u t2: %08u diff_pmtmr: %08u diff_tsc: %016llu\n", then, now, diff, diff_tsc);
95 then = now;
96 then_tsc = now_tsc;
97 }
98 printk(KERN_DEBUG "<-- end \n");
99 return -ENODEV;
100}
101
102static void __exit cpufreq_none(void)
103{
104 return;
105}
106
107module_init(cpufreq_test_tsc)
108module_exit(cpufreq_none)
109
110
111MODULE_AUTHOR("Dominik Brodowski");
112MODULE_DESCRIPTION("Verify the TSC cpufreq notifier working correctly -- needs ACPI-enabled system");
113MODULE_LICENSE ("GPL");
diff --git a/tools/power/cpupower/debug/x86_64/Makefile b/tools/power/cpupower/debug/x86_64/Makefile
new file mode 100644
index 00000000000..3326217dd31
--- /dev/null
+++ b/tools/power/cpupower/debug/x86_64/Makefile
@@ -0,0 +1,14 @@
1default: all
2
3centrino-decode: ../i386/centrino-decode.c
4 $(CC) $(CFLAGS) -o $@ $<
5
6powernow-k8-decode: ../i386/powernow-k8-decode.c
7 $(CC) $(CFLAGS) -o $@ $<
8
9all: centrino-decode powernow-k8-decode
10
11clean:
12 rm -rf centrino-decode powernow-k8-decode
13
14.PHONY: all default clean
diff --git a/tools/power/cpupower/lib/cpufreq.c b/tools/power/cpupower/lib/cpufreq.c
new file mode 100644
index 00000000000..d961101d1ce
--- /dev/null
+++ b/tools/power/cpupower/lib/cpufreq.c
@@ -0,0 +1,208 @@
1/*
2 * (C) 2004-2009 Dominik Brodowski <linux@dominikbrodowski.de>
3 *
4 * Licensed under the terms of the GNU GPL License version 2.
5 */
6
7
8#include <stdio.h>
9#include <errno.h>
10#include <stdlib.h>
11#include <string.h>
12
13#include "cpufreq.h"
14#include "sysfs.h"
15
16int cpufreq_cpu_exists(unsigned int cpu)
17{
18 return sysfs_cpu_exists(cpu);
19}
20
21unsigned long cpufreq_get_freq_kernel(unsigned int cpu)
22{
23 return sysfs_get_freq_kernel(cpu);
24}
25
26unsigned long cpufreq_get_freq_hardware(unsigned int cpu)
27{
28 return sysfs_get_freq_hardware(cpu);
29}
30
31unsigned long cpufreq_get_transition_latency(unsigned int cpu)
32{
33 return sysfs_get_freq_transition_latency(cpu);
34}
35
36int cpufreq_get_hardware_limits(unsigned int cpu,
37 unsigned long *min,
38 unsigned long *max)
39{
40 if ((!min) || (!max))
41 return -EINVAL;
42 return sysfs_get_freq_hardware_limits(cpu, min, max);
43}
44
45char *cpufreq_get_driver(unsigned int cpu)
46{
47 return sysfs_get_freq_driver(cpu);
48}
49
50void cpufreq_put_driver(char *ptr)
51{
52 if (!ptr)
53 return;
54 free(ptr);
55}
56
57struct cpufreq_policy *cpufreq_get_policy(unsigned int cpu)
58{
59 return sysfs_get_freq_policy(cpu);
60}
61
62void cpufreq_put_policy(struct cpufreq_policy *policy)
63{
64 if ((!policy) || (!policy->governor))
65 return;
66
67 free(policy->governor);
68 policy->governor = NULL;
69 free(policy);
70}
71
72struct cpufreq_available_governors *cpufreq_get_available_governors(unsigned
73 int cpu)
74{
75 return sysfs_get_freq_available_governors(cpu);
76}
77
78void cpufreq_put_available_governors(struct cpufreq_available_governors *any)
79{
80 struct cpufreq_available_governors *tmp, *next;
81
82 if (!any)
83 return;
84
85 tmp = any->first;
86 while (tmp) {
87 next = tmp->next;
88 if (tmp->governor)
89 free(tmp->governor);
90 free(tmp);
91 tmp = next;
92 }
93}
94
95
96struct cpufreq_available_frequencies
97*cpufreq_get_available_frequencies(unsigned int cpu)
98{
99 return sysfs_get_available_frequencies(cpu);
100}
101
102void cpufreq_put_available_frequencies(struct cpufreq_available_frequencies
103 *any) {
104 struct cpufreq_available_frequencies *tmp, *next;
105
106 if (!any)
107 return;
108
109 tmp = any->first;
110 while (tmp) {
111 next = tmp->next;
112 free(tmp);
113 tmp = next;
114 }
115}
116
117
118struct cpufreq_affected_cpus *cpufreq_get_affected_cpus(unsigned int cpu)
119{
120 return sysfs_get_freq_affected_cpus(cpu);
121}
122
123void cpufreq_put_affected_cpus(struct cpufreq_affected_cpus *any)
124{
125 struct cpufreq_affected_cpus *tmp, *next;
126
127 if (!any)
128 return;
129
130 tmp = any->first;
131 while (tmp) {
132 next = tmp->next;
133 free(tmp);
134 tmp = next;
135 }
136}
137
138
139struct cpufreq_affected_cpus *cpufreq_get_related_cpus(unsigned int cpu)
140{
141 return sysfs_get_freq_related_cpus(cpu);
142}
143
144void cpufreq_put_related_cpus(struct cpufreq_affected_cpus *any)
145{
146 cpufreq_put_affected_cpus(any);
147}
148
149
150int cpufreq_set_policy(unsigned int cpu, struct cpufreq_policy *policy)
151{
152 if (!policy || !(policy->governor))
153 return -EINVAL;
154
155 return sysfs_set_freq_policy(cpu, policy);
156}
157
158
159int cpufreq_modify_policy_min(unsigned int cpu, unsigned long min_freq)
160{
161 return sysfs_modify_freq_policy_min(cpu, min_freq);
162}
163
164
165int cpufreq_modify_policy_max(unsigned int cpu, unsigned long max_freq)
166{
167 return sysfs_modify_freq_policy_max(cpu, max_freq);
168}
169
170
171int cpufreq_modify_policy_governor(unsigned int cpu, char *governor)
172{
173 if ((!governor) || (strlen(governor) > 19))
174 return -EINVAL;
175
176 return sysfs_modify_freq_policy_governor(cpu, governor);
177}
178
179int cpufreq_set_frequency(unsigned int cpu, unsigned long target_frequency)
180{
181 return sysfs_set_frequency(cpu, target_frequency);
182}
183
184struct cpufreq_stats *cpufreq_get_stats(unsigned int cpu,
185 unsigned long long *total_time)
186{
187 return sysfs_get_freq_stats(cpu, total_time);
188}
189
190void cpufreq_put_stats(struct cpufreq_stats *any)
191{
192 struct cpufreq_stats *tmp, *next;
193
194 if (!any)
195 return;
196
197 tmp = any->first;
198 while (tmp) {
199 next = tmp->next;
200 free(tmp);
201 tmp = next;
202 }
203}
204
205unsigned long cpufreq_get_transitions(unsigned int cpu)
206{
207 return sysfs_get_freq_transitions(cpu);
208}
diff --git a/tools/power/cpupower/lib/cpufreq.h b/tools/power/cpupower/lib/cpufreq.h
new file mode 100644
index 00000000000..3aae8e7a083
--- /dev/null
+++ b/tools/power/cpupower/lib/cpufreq.h
@@ -0,0 +1,223 @@
1/*
2 * cpufreq.h - definitions for libcpufreq
3 *
4 * Copyright (C) 2004-2009 Dominik Brodowski <linux@dominikbrodowski.de>
5 *
6 * This program is free software; you can redistribute it and/or modify
7 * it under the terms of the GNU General Public License as published by
8 * the Free Software Foundation, version 2 of the License.
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#ifndef _CPUFREQ_H
21#define _CPUFREQ_H 1
22
23struct cpufreq_policy {
24 unsigned long min;
25 unsigned long max;
26 char *governor;
27};
28
29struct cpufreq_available_governors {
30 char *governor;
31 struct cpufreq_available_governors *next;
32 struct cpufreq_available_governors *first;
33};
34
35struct cpufreq_available_frequencies {
36 unsigned long frequency;
37 struct cpufreq_available_frequencies *next;
38 struct cpufreq_available_frequencies *first;
39};
40
41
42struct cpufreq_affected_cpus {
43 unsigned int cpu;
44 struct cpufreq_affected_cpus *next;
45 struct cpufreq_affected_cpus *first;
46};
47
48struct cpufreq_stats {
49 unsigned long frequency;
50 unsigned long long time_in_state;
51 struct cpufreq_stats *next;
52 struct cpufreq_stats *first;
53};
54
55
56
57#ifdef __cplusplus
58extern "C" {
59#endif
60
61/*
62 * returns 0 if the specified CPU is present (it doesn't say
63 * whether it is online!), and an error value if not.
64 */
65
66extern int cpufreq_cpu_exists(unsigned int cpu);
67
68/* determine current CPU frequency
69 * - _kernel variant means kernel's opinion of CPU frequency
70 * - _hardware variant means actual hardware CPU frequency,
71 * which is only available to root.
72 *
73 * returns 0 on failure, else frequency in kHz.
74 */
75
76extern unsigned long cpufreq_get_freq_kernel(unsigned int cpu);
77
78extern unsigned long cpufreq_get_freq_hardware(unsigned int cpu);
79
80#define cpufreq_get(cpu) cpufreq_get_freq_kernel(cpu);
81
82
83/* determine CPU transition latency
84 *
85 * returns 0 on failure, else transition latency in 10^(-9) s = nanoseconds
86 */
87extern unsigned long cpufreq_get_transition_latency(unsigned int cpu);
88
89
90/* determine hardware CPU frequency limits
91 *
92 * These may be limited further by thermal, energy or other
93 * considerations by cpufreq policy notifiers in the kernel.
94 */
95
96extern int cpufreq_get_hardware_limits(unsigned int cpu,
97 unsigned long *min,
98 unsigned long *max);
99
100
101/* determine CPUfreq driver used
102 *
103 * Remember to call cpufreq_put_driver when no longer needed
104 * to avoid memory leakage, please.
105 */
106
107extern char *cpufreq_get_driver(unsigned int cpu);
108
109extern void cpufreq_put_driver(char *ptr);
110
111
112/* determine CPUfreq policy currently used
113 *
114 * Remember to call cpufreq_put_policy when no longer needed
115 * to avoid memory leakage, please.
116 */
117
118
119extern struct cpufreq_policy *cpufreq_get_policy(unsigned int cpu);
120
121extern void cpufreq_put_policy(struct cpufreq_policy *policy);
122
123
124/* determine CPUfreq governors currently available
125 *
126 * may be modified by modprobe'ing or rmmod'ing other governors. Please
127 * free allocated memory by calling cpufreq_put_available_governors
128 * after use.
129 */
130
131
132extern struct cpufreq_available_governors
133*cpufreq_get_available_governors(unsigned int cpu);
134
135extern void cpufreq_put_available_governors(
136 struct cpufreq_available_governors *first);
137
138
139/* determine CPU frequency states available
140 *
141 * Only present on _some_ ->target() cpufreq drivers. For information purposes
142 * only. Please free allocated memory by calling
143 * cpufreq_put_available_frequencies after use.
144 */
145
146extern struct cpufreq_available_frequencies
147*cpufreq_get_available_frequencies(unsigned int cpu);
148
149extern void cpufreq_put_available_frequencies(
150 struct cpufreq_available_frequencies *first);
151
152
153/* determine affected CPUs
154 *
155 * Remember to call cpufreq_put_affected_cpus when no longer needed
156 * to avoid memory leakage, please.
157 */
158
159extern struct cpufreq_affected_cpus *cpufreq_get_affected_cpus(unsigned
160 int cpu);
161
162extern void cpufreq_put_affected_cpus(struct cpufreq_affected_cpus *first);
163
164
165/* determine related CPUs
166 *
167 * Remember to call cpufreq_put_related_cpus when no longer needed
168 * to avoid memory leakage, please.
169 */
170
171extern struct cpufreq_affected_cpus *cpufreq_get_related_cpus(unsigned
172 int cpu);
173
174extern void cpufreq_put_related_cpus(struct cpufreq_affected_cpus *first);
175
176
177/* determine stats for cpufreq subsystem
178 *
179 * This is not available in all kernel versions or configurations.
180 */
181
182extern struct cpufreq_stats *cpufreq_get_stats(unsigned int cpu,
183 unsigned long long *total_time);
184
185extern void cpufreq_put_stats(struct cpufreq_stats *stats);
186
187extern unsigned long cpufreq_get_transitions(unsigned int cpu);
188
189
190/* set new cpufreq policy
191 *
192 * Tries to set the passed policy as new policy as close as possible,
193 * but results may differ depending e.g. on governors being available.
194 */
195
196extern int cpufreq_set_policy(unsigned int cpu, struct cpufreq_policy *policy);
197
198
199/* modify a policy by only changing min/max freq or governor
200 *
201 * Does not check whether result is what was intended.
202 */
203
204extern int cpufreq_modify_policy_min(unsigned int cpu, unsigned long min_freq);
205extern int cpufreq_modify_policy_max(unsigned int cpu, unsigned long max_freq);
206extern int cpufreq_modify_policy_governor(unsigned int cpu, char *governor);
207
208
209/* set a specific frequency
210 *
211 * Does only work if userspace governor can be used and no external
212 * interference (other calls to this function or to set/modify_policy)
213 * occurs. Also does not work on ->range() cpufreq drivers.
214 */
215
216extern int cpufreq_set_frequency(unsigned int cpu,
217 unsigned long target_frequency);
218
219#ifdef __cplusplus
220}
221#endif
222
223#endif /* _CPUFREQ_H */
diff --git a/tools/power/cpupower/lib/sysfs.c b/tools/power/cpupower/lib/sysfs.c
new file mode 100644
index 00000000000..870713a75a8
--- /dev/null
+++ b/tools/power/cpupower/lib/sysfs.c
@@ -0,0 +1,672 @@
1/*
2 * (C) 2004-2009 Dominik Brodowski <linux@dominikbrodowski.de>
3 *
4 * Licensed under the terms of the GNU GPL License version 2.
5 */
6
7#include <stdio.h>
8#include <errno.h>
9#include <stdlib.h>
10#include <string.h>
11#include <limits.h>
12#include <sys/types.h>
13#include <sys/stat.h>
14#include <fcntl.h>
15#include <unistd.h>
16
17#include "cpufreq.h"
18
19#define PATH_TO_CPU "/sys/devices/system/cpu/"
20#define MAX_LINE_LEN 4096
21#define SYSFS_PATH_MAX 255
22
23
24static unsigned int sysfs_read_file(const char *path, char *buf, size_t buflen)
25{
26 int fd;
27 ssize_t numread;
28
29 fd = open(path, O_RDONLY);
30 if (fd == -1)
31 return 0;
32
33 numread = read(fd, buf, buflen - 1);
34 if (numread < 1) {
35 close(fd);
36 return 0;
37 }
38
39 buf[numread] = '\0';
40 close(fd);
41
42 return (unsigned int) numread;
43}
44
45
46/* CPUFREQ sysfs access **************************************************/
47
48/* helper function to read file from /sys into given buffer */
49/* fname is a relative path under "cpuX/cpufreq" dir */
50static unsigned int sysfs_cpufreq_read_file(unsigned int cpu, const char *fname,
51 char *buf, size_t buflen)
52{
53 char path[SYSFS_PATH_MAX];
54
55 snprintf(path, sizeof(path), PATH_TO_CPU "cpu%u/cpufreq/%s",
56 cpu, fname);
57 return sysfs_read_file(path, buf, buflen);
58}
59
60/* helper function to write a new value to a /sys file */
61/* fname is a relative path under "cpuX/cpufreq" dir */
62static unsigned int sysfs_cpufreq_write_file(unsigned int cpu,
63 const char *fname,
64 const char *value, size_t len)
65{
66 char path[SYSFS_PATH_MAX];
67 int fd;
68 ssize_t numwrite;
69
70 snprintf(path, sizeof(path), PATH_TO_CPU "cpu%u/cpufreq/%s",
71 cpu, fname);
72
73 fd = open(path, O_WRONLY);
74 if (fd == -1)
75 return 0;
76
77 numwrite = write(fd, value, len);
78 if (numwrite < 1) {
79 close(fd);
80 return 0;
81 }
82
83 close(fd);
84
85 return (unsigned int) numwrite;
86}
87
88/* read access to files which contain one numeric value */
89
90enum cpufreq_value {
91 CPUINFO_CUR_FREQ,
92 CPUINFO_MIN_FREQ,
93 CPUINFO_MAX_FREQ,
94 CPUINFO_LATENCY,
95 SCALING_CUR_FREQ,
96 SCALING_MIN_FREQ,
97 SCALING_MAX_FREQ,
98 STATS_NUM_TRANSITIONS,
99 MAX_CPUFREQ_VALUE_READ_FILES
100};
101
102static const char *cpufreq_value_files[MAX_CPUFREQ_VALUE_READ_FILES] = {
103 [CPUINFO_CUR_FREQ] = "cpuinfo_cur_freq",
104 [CPUINFO_MIN_FREQ] = "cpuinfo_min_freq",
105 [CPUINFO_MAX_FREQ] = "cpuinfo_max_freq",
106 [CPUINFO_LATENCY] = "cpuinfo_transition_latency",
107 [SCALING_CUR_FREQ] = "scaling_cur_freq",
108 [SCALING_MIN_FREQ] = "scaling_min_freq",
109 [SCALING_MAX_FREQ] = "scaling_max_freq",
110 [STATS_NUM_TRANSITIONS] = "stats/total_trans"
111};
112
113
114static unsigned long sysfs_cpufreq_get_one_value(unsigned int cpu,
115 enum cpufreq_value which)
116{
117 unsigned long value;
118 unsigned int len;
119 char linebuf[MAX_LINE_LEN];
120 char *endp;
121
122 if (which >= MAX_CPUFREQ_VALUE_READ_FILES)
123 return 0;
124
125 len = sysfs_cpufreq_read_file(cpu, cpufreq_value_files[which],
126 linebuf, sizeof(linebuf));
127
128 if (len == 0)
129 return 0;
130
131 value = strtoul(linebuf, &endp, 0);
132
133 if (endp == linebuf || errno == ERANGE)
134 return 0;
135
136 return value;
137}
138
139/* read access to files which contain one string */
140
141enum cpufreq_string {
142 SCALING_DRIVER,
143 SCALING_GOVERNOR,
144 MAX_CPUFREQ_STRING_FILES
145};
146
147static const char *cpufreq_string_files[MAX_CPUFREQ_STRING_FILES] = {
148 [SCALING_DRIVER] = "scaling_driver",
149 [SCALING_GOVERNOR] = "scaling_governor",
150};
151
152
153static char *sysfs_cpufreq_get_one_string(unsigned int cpu,
154 enum cpufreq_string which)
155{
156 char linebuf[MAX_LINE_LEN];
157 char *result;
158 unsigned int len;
159
160 if (which >= MAX_CPUFREQ_STRING_FILES)
161 return NULL;
162
163 len = sysfs_cpufreq_read_file(cpu, cpufreq_string_files[which],
164 linebuf, sizeof(linebuf));
165 if (len == 0)
166 return NULL;
167
168 result = strdup(linebuf);
169 if (result == NULL)
170 return NULL;
171
172 if (result[strlen(result) - 1] == '\n')
173 result[strlen(result) - 1] = '\0';
174
175 return result;
176}
177
178/* write access */
179
180enum cpufreq_write {
181 WRITE_SCALING_MIN_FREQ,
182 WRITE_SCALING_MAX_FREQ,
183 WRITE_SCALING_GOVERNOR,
184 WRITE_SCALING_SET_SPEED,
185 MAX_CPUFREQ_WRITE_FILES
186};
187
188static const char *cpufreq_write_files[MAX_CPUFREQ_WRITE_FILES] = {
189 [WRITE_SCALING_MIN_FREQ] = "scaling_min_freq",
190 [WRITE_SCALING_MAX_FREQ] = "scaling_max_freq",
191 [WRITE_SCALING_GOVERNOR] = "scaling_governor",
192 [WRITE_SCALING_SET_SPEED] = "scaling_setspeed",
193};
194
195static int sysfs_cpufreq_write_one_value(unsigned int cpu,
196 enum cpufreq_write which,
197 const char *new_value, size_t len)
198{
199 if (which >= MAX_CPUFREQ_WRITE_FILES)
200 return 0;
201
202 if (sysfs_cpufreq_write_file(cpu, cpufreq_write_files[which],
203 new_value, len) != len)
204 return -ENODEV;
205
206 return 0;
207};
208
209unsigned long sysfs_get_freq_kernel(unsigned int cpu)
210{
211 return sysfs_cpufreq_get_one_value(cpu, SCALING_CUR_FREQ);
212}
213
214unsigned long sysfs_get_freq_hardware(unsigned int cpu)
215{
216 return sysfs_cpufreq_get_one_value(cpu, CPUINFO_CUR_FREQ);
217}
218
219unsigned long sysfs_get_freq_transition_latency(unsigned int cpu)
220{
221 return sysfs_cpufreq_get_one_value(cpu, CPUINFO_LATENCY);
222}
223
224int sysfs_get_freq_hardware_limits(unsigned int cpu,
225 unsigned long *min,
226 unsigned long *max)
227{
228 if ((!min) || (!max))
229 return -EINVAL;
230
231 *min = sysfs_cpufreq_get_one_value(cpu, CPUINFO_MIN_FREQ);
232 if (!*min)
233 return -ENODEV;
234
235 *max = sysfs_cpufreq_get_one_value(cpu, CPUINFO_MAX_FREQ);
236 if (!*max)
237 return -ENODEV;
238
239 return 0;
240}
241
242char *sysfs_get_freq_driver(unsigned int cpu)
243{
244 return sysfs_cpufreq_get_one_string(cpu, SCALING_DRIVER);
245}
246
247struct cpufreq_policy *sysfs_get_freq_policy(unsigned int cpu)
248{
249 struct cpufreq_policy *policy;
250
251 policy = malloc(sizeof(struct cpufreq_policy));
252 if (!policy)
253 return NULL;
254
255 policy->governor = sysfs_cpufreq_get_one_string(cpu, SCALING_GOVERNOR);
256 if (!policy->governor) {
257 free(policy);
258 return NULL;
259 }
260 policy->min = sysfs_cpufreq_get_one_value(cpu, SCALING_MIN_FREQ);
261 policy->max = sysfs_cpufreq_get_one_value(cpu, SCALING_MAX_FREQ);
262 if ((!policy->min) || (!policy->max)) {
263 free(policy->governor);
264 free(policy);
265 return NULL;
266 }
267
268 return policy;
269}
270
271struct cpufreq_available_governors *
272sysfs_get_freq_available_governors(unsigned int cpu) {
273 struct cpufreq_available_governors *first = NULL;
274 struct cpufreq_available_governors *current = NULL;
275 char linebuf[MAX_LINE_LEN];
276 unsigned int pos, i;
277 unsigned int len;
278
279 len = sysfs_cpufreq_read_file(cpu, "scaling_available_governors",
280 linebuf, sizeof(linebuf));
281 if (len == 0)
282 return NULL;
283
284 pos = 0;
285 for (i = 0; i < len; i++) {
286 if (linebuf[i] == ' ' || linebuf[i] == '\n') {
287 if (i - pos < 2)
288 continue;
289 if (current) {
290 current->next = malloc(sizeof(*current));
291 if (!current->next)
292 goto error_out;
293 current = current->next;
294 } else {
295 first = malloc(sizeof(*first));
296 if (!first)
297 goto error_out;
298 current = first;
299 }
300 current->first = first;
301 current->next = NULL;
302
303 current->governor = malloc(i - pos + 1);
304 if (!current->governor)
305 goto error_out;
306
307 memcpy(current->governor, linebuf + pos, i - pos);
308 current->governor[i - pos] = '\0';
309 pos = i + 1;
310 }
311 }
312
313 return first;
314
315 error_out:
316 while (first) {
317 current = first->next;
318 if (first->governor)
319 free(first->governor);
320 free(first);
321 first = current;
322 }
323 return NULL;
324}
325
326
327struct cpufreq_available_frequencies *
328sysfs_get_available_frequencies(unsigned int cpu) {
329 struct cpufreq_available_frequencies *first = NULL;
330 struct cpufreq_available_frequencies *current = NULL;
331 char one_value[SYSFS_PATH_MAX];
332 char linebuf[MAX_LINE_LEN];
333 unsigned int pos, i;
334 unsigned int len;
335
336 len = sysfs_cpufreq_read_file(cpu, "scaling_available_frequencies",
337 linebuf, sizeof(linebuf));
338 if (len == 0)
339 return NULL;
340
341 pos = 0;
342 for (i = 0; i < len; i++) {
343 if (linebuf[i] == ' ' || linebuf[i] == '\n') {
344 if (i - pos < 2)
345 continue;
346 if (i - pos >= SYSFS_PATH_MAX)
347 goto error_out;
348 if (current) {
349 current->next = malloc(sizeof(*current));
350 if (!current->next)
351 goto error_out;
352 current = current->next;
353 } else {
354 first = malloc(sizeof(*first));
355 if (!first)
356 goto error_out;
357 current = first;
358 }
359 current->first = first;
360 current->next = NULL;
361
362 memcpy(one_value, linebuf + pos, i - pos);
363 one_value[i - pos] = '\0';
364 if (sscanf(one_value, "%lu", &current->frequency) != 1)
365 goto error_out;
366
367 pos = i + 1;
368 }
369 }
370
371 return first;
372
373 error_out:
374 while (first) {
375 current = first->next;
376 free(first);
377 first = current;
378 }
379 return NULL;
380}
381
382static struct cpufreq_affected_cpus *sysfs_get_cpu_list(unsigned int cpu,
383 const char *file)
384{
385 struct cpufreq_affected_cpus *first = NULL;
386 struct cpufreq_affected_cpus *current = NULL;
387 char one_value[SYSFS_PATH_MAX];
388 char linebuf[MAX_LINE_LEN];
389 unsigned int pos, i;
390 unsigned int len;
391
392 len = sysfs_cpufreq_read_file(cpu, file, linebuf, sizeof(linebuf));
393 if (len == 0)
394 return NULL;
395
396 pos = 0;
397 for (i = 0; i < len; i++) {
398 if (i == len || linebuf[i] == ' ' || linebuf[i] == '\n') {
399 if (i - pos < 1)
400 continue;
401 if (i - pos >= SYSFS_PATH_MAX)
402 goto error_out;
403 if (current) {
404 current->next = malloc(sizeof(*current));
405 if (!current->next)
406 goto error_out;
407 current = current->next;
408 } else {
409 first = malloc(sizeof(*first));
410 if (!first)
411 goto error_out;
412 current = first;
413 }
414 current->first = first;
415 current->next = NULL;
416
417 memcpy(one_value, linebuf + pos, i - pos);
418 one_value[i - pos] = '\0';
419
420 if (sscanf(one_value, "%u", &current->cpu) != 1)
421 goto error_out;
422
423 pos = i + 1;
424 }
425 }
426
427 return first;
428
429 error_out:
430 while (first) {
431 current = first->next;
432 free(first);
433 first = current;
434 }
435 return NULL;
436}
437
438struct cpufreq_affected_cpus *sysfs_get_freq_affected_cpus(unsigned int cpu)
439{
440 return sysfs_get_cpu_list(cpu, "affected_cpus");
441}
442
443struct cpufreq_affected_cpus *sysfs_get_freq_related_cpus(unsigned int cpu)
444{
445 return sysfs_get_cpu_list(cpu, "related_cpus");
446}
447
448struct cpufreq_stats *sysfs_get_freq_stats(unsigned int cpu,
449 unsigned long long *total_time) {
450 struct cpufreq_stats *first = NULL;
451 struct cpufreq_stats *current = NULL;
452 char one_value[SYSFS_PATH_MAX];
453 char linebuf[MAX_LINE_LEN];
454 unsigned int pos, i;
455 unsigned int len;
456
457 len = sysfs_cpufreq_read_file(cpu, "stats/time_in_state",
458 linebuf, sizeof(linebuf));
459 if (len == 0)
460 return NULL;
461
462 *total_time = 0;
463 pos = 0;
464 for (i = 0; i < len; i++) {
465 if (i == strlen(linebuf) || linebuf[i] == '\n') {
466 if (i - pos < 2)
467 continue;
468 if ((i - pos) >= SYSFS_PATH_MAX)
469 goto error_out;
470 if (current) {
471 current->next = malloc(sizeof(*current));
472 if (!current->next)
473 goto error_out;
474 current = current->next;
475 } else {
476 first = malloc(sizeof(*first));
477 if (!first)
478 goto error_out;
479 current = first;
480 }
481 current->first = first;
482 current->next = NULL;
483
484 memcpy(one_value, linebuf + pos, i - pos);
485 one_value[i - pos] = '\0';
486 if (sscanf(one_value, "%lu %llu",
487 &current->frequency,
488 &current->time_in_state) != 2)
489 goto error_out;
490
491 *total_time = *total_time + current->time_in_state;
492 pos = i + 1;
493 }
494 }
495
496 return first;
497
498 error_out:
499 while (first) {
500 current = first->next;
501 free(first);
502 first = current;
503 }
504 return NULL;
505}
506
507unsigned long sysfs_get_freq_transitions(unsigned int cpu)
508{
509 return sysfs_cpufreq_get_one_value(cpu, STATS_NUM_TRANSITIONS);
510}
511
512static int verify_gov(char *new_gov, char *passed_gov)
513{
514 unsigned int i, j = 0;
515
516 if (!passed_gov || (strlen(passed_gov) > 19))
517 return -EINVAL;
518
519 strncpy(new_gov, passed_gov, 20);
520 for (i = 0; i < 20; i++) {
521 if (j) {
522 new_gov[i] = '\0';
523 continue;
524 }
525 if ((new_gov[i] >= 'a') && (new_gov[i] <= 'z'))
526 continue;
527
528 if ((new_gov[i] >= 'A') && (new_gov[i] <= 'Z'))
529 continue;
530
531 if (new_gov[i] == '-')
532 continue;
533
534 if (new_gov[i] == '_')
535 continue;
536
537 if (new_gov[i] == '\0') {
538 j = 1;
539 continue;
540 }
541 return -EINVAL;
542 }
543 new_gov[19] = '\0';
544 return 0;
545}
546
547int sysfs_modify_freq_policy_governor(unsigned int cpu, char *governor)
548{
549 char new_gov[SYSFS_PATH_MAX];
550
551 if (!governor)
552 return -EINVAL;
553
554 if (verify_gov(new_gov, governor))
555 return -EINVAL;
556
557 return sysfs_cpufreq_write_one_value(cpu, WRITE_SCALING_GOVERNOR,
558 new_gov, strlen(new_gov));
559};
560
561int sysfs_modify_freq_policy_max(unsigned int cpu, unsigned long max_freq)
562{
563 char value[SYSFS_PATH_MAX];
564
565 snprintf(value, SYSFS_PATH_MAX, "%lu", max_freq);
566
567 return sysfs_cpufreq_write_one_value(cpu, WRITE_SCALING_MAX_FREQ,
568 value, strlen(value));
569};
570
571
572int sysfs_modify_freq_policy_min(unsigned int cpu, unsigned long min_freq)
573{
574 char value[SYSFS_PATH_MAX];
575
576 snprintf(value, SYSFS_PATH_MAX, "%lu", min_freq);
577
578 return sysfs_cpufreq_write_one_value(cpu, WRITE_SCALING_MIN_FREQ,
579 value, strlen(value));
580};
581
582
583int sysfs_set_freq_policy(unsigned int cpu, struct cpufreq_policy *policy)
584{
585 char min[SYSFS_PATH_MAX];
586 char max[SYSFS_PATH_MAX];
587 char gov[SYSFS_PATH_MAX];
588 int ret;
589 unsigned long old_min;
590 int write_max_first;
591
592 if (!policy || !(policy->governor))
593 return -EINVAL;
594
595 if (policy->max < policy->min)
596 return -EINVAL;
597
598 if (verify_gov(gov, policy->governor))
599 return -EINVAL;
600
601 snprintf(min, SYSFS_PATH_MAX, "%lu", policy->min);
602 snprintf(max, SYSFS_PATH_MAX, "%lu", policy->max);
603
604 old_min = sysfs_cpufreq_get_one_value(cpu, SCALING_MIN_FREQ);
605 write_max_first = (old_min && (policy->max < old_min) ? 0 : 1);
606
607 if (write_max_first) {
608 ret = sysfs_cpufreq_write_one_value(cpu, WRITE_SCALING_MAX_FREQ,
609 max, strlen(max));
610 if (ret)
611 return ret;
612 }
613
614 ret = sysfs_cpufreq_write_one_value(cpu, WRITE_SCALING_MIN_FREQ, min,
615 strlen(min));
616 if (ret)
617 return ret;
618
619 if (!write_max_first) {
620 ret = sysfs_cpufreq_write_one_value(cpu, WRITE_SCALING_MAX_FREQ,
621 max, strlen(max));
622 if (ret)
623 return ret;
624 }
625
626 return sysfs_cpufreq_write_one_value(cpu, WRITE_SCALING_GOVERNOR,
627 gov, strlen(gov));
628}
629
630int sysfs_set_frequency(unsigned int cpu, unsigned long target_frequency)
631{
632 struct cpufreq_policy *pol = sysfs_get_freq_policy(cpu);
633 char userspace_gov[] = "userspace";
634 char freq[SYSFS_PATH_MAX];
635 int ret;
636
637 if (!pol)
638 return -ENODEV;
639
640 if (strncmp(pol->governor, userspace_gov, 9) != 0) {
641 ret = sysfs_modify_freq_policy_governor(cpu, userspace_gov);
642 if (ret) {
643 cpufreq_put_policy(pol);
644 return ret;
645 }
646 }
647
648 cpufreq_put_policy(pol);
649
650 snprintf(freq, SYSFS_PATH_MAX, "%lu", target_frequency);
651
652 return sysfs_cpufreq_write_one_value(cpu, WRITE_SCALING_SET_SPEED,
653 freq, strlen(freq));
654}
655
656/* CPUFREQ sysfs access **************************************************/
657
658/* General sysfs access **************************************************/
659int sysfs_cpu_exists(unsigned int cpu)
660{
661 char file[SYSFS_PATH_MAX];
662 struct stat statbuf;
663
664 snprintf(file, SYSFS_PATH_MAX, PATH_TO_CPU "cpu%u/", cpu);
665
666 if (stat(file, &statbuf) != 0)
667 return -ENOSYS;
668
669 return S_ISDIR(statbuf.st_mode) ? 0 : -ENOSYS;
670}
671
672/* General sysfs access **************************************************/
diff --git a/tools/power/cpupower/lib/sysfs.h b/tools/power/cpupower/lib/sysfs.h
new file mode 100644
index 00000000000..c76a5e0af50
--- /dev/null
+++ b/tools/power/cpupower/lib/sysfs.h
@@ -0,0 +1,31 @@
1/* General */
2extern unsigned int sysfs_cpu_exists(unsigned int cpu);
3
4/* CPUfreq */
5extern unsigned long sysfs_get_freq_kernel(unsigned int cpu);
6extern unsigned long sysfs_get_freq_hardware(unsigned int cpu);
7extern unsigned long sysfs_get_freq_transition_latency(unsigned int cpu);
8extern int sysfs_get_freq_hardware_limits(unsigned int cpu,
9 unsigned long *min, unsigned long *max);
10extern char *sysfs_get_freq_driver(unsigned int cpu);
11extern struct cpufreq_policy *sysfs_get_freq_policy(unsigned int cpu);
12extern struct cpufreq_available_governors *sysfs_get_freq_available_governors(
13 unsigned int cpu);
14extern struct cpufreq_available_frequencies *sysfs_get_available_frequencies(
15 unsigned int cpu);
16extern struct cpufreq_affected_cpus *sysfs_get_freq_affected_cpus(
17 unsigned int cpu);
18extern struct cpufreq_affected_cpus *sysfs_get_freq_related_cpus(
19 unsigned int cpu);
20extern struct cpufreq_stats *sysfs_get_freq_stats(unsigned int cpu,
21 unsigned long long *total_time);
22extern unsigned long sysfs_get_freq_transitions(unsigned int cpu);
23extern int sysfs_set_freq_policy(unsigned int cpu,
24 struct cpufreq_policy *policy);
25extern int sysfs_modify_freq_policy_min(unsigned int cpu,
26 unsigned long min_freq);
27extern int sysfs_modify_freq_policy_max(unsigned int cpu,
28 unsigned long max_freq);
29extern int sysfs_modify_freq_policy_governor(unsigned int cpu, char *governor);
30extern int sysfs_set_frequency(unsigned int cpu,
31 unsigned long target_frequency);
diff --git a/tools/power/cpupower/man/cpupower-frequency-info.1 b/tools/power/cpupower/man/cpupower-frequency-info.1
new file mode 100644
index 00000000000..bb60a8d1e45
--- /dev/null
+++ b/tools/power/cpupower/man/cpupower-frequency-info.1
@@ -0,0 +1,76 @@
1.TH "cpupower-frequency-info" "1" "0.1" "Mattia Dongili" ""
2.SH "NAME"
3.LP
4cpupower frequency\-info \- Utility to retrieve cpufreq kernel information
5.SH "SYNTAX"
6.LP
7cpupower [ \-c cpulist ] frequency\-info [\fIoptions\fP]
8.SH "DESCRIPTION"
9.LP
10A small tool which prints out cpufreq information helpful to developers and interested users.
11.SH "OPTIONS"
12.LP
13.TP
14\fB\-e\fR \fB\-\-debug\fR
15Prints out debug information.
16.TP
17\fB\-f\fR \fB\-\-freq\fR
18Get frequency the CPU currently runs at, according to the cpufreq core.
19.TP
20\fB\-w\fR \fB\-\-hwfreq\fR
21Get frequency the CPU currently runs at, by reading it from hardware (only available to root).
22.TP
23\fB\-l\fR \fB\-\-hwlimits\fR
24Determine the minimum and maximum CPU frequency allowed.
25.TP
26\fB\-d\fR \fB\-\-driver\fR
27Determines the used cpufreq kernel driver.
28.TP
29\fB\-p\fR \fB\-\-policy\fR
30Gets the currently used cpufreq policy.
31.TP
32\fB\-g\fR \fB\-\-governors\fR
33Determines available cpufreq governors.
34.TP
35\fB\-a\fR \fB\-\-related\-cpus\fR
36Determines which CPUs run at the same hardware frequency.
37.TP
38\fB\-a\fR \fB\-\-affected\-cpus\fR
39Determines which CPUs need to have their frequency coordinated by software.
40.TP
41\fB\-s\fR \fB\-\-stats\fR
42Shows cpufreq statistics if available.
43.TP
44\fB\-y\fR \fB\-\-latency\fR
45Determines the maximum latency on CPU frequency changes.
46.TP
47\fB\-o\fR \fB\-\-proc\fR
48Prints out information like provided by the /proc/cpufreq interface in 2.4. and early 2.6. kernels.
49.TP
50\fB\-m\fR \fB\-\-human\fR
51human\-readable output for the \-f, \-w, \-s and \-y parameters.
52.TP
53\fB\-h\fR \fB\-\-help\fR
54Prints out the help screen.
55.SH "REMARKS"
56.LP
57By default only values of core zero are displayed. How to display settings of
58other cores is described in the cpupower(1) manpage in the \-\-cpu option section.
59.LP
60You can't specify more than one of the output specific options \-o \-e \-a \-g \-p \-d \-l \-w \-f \-y.
61.LP
62You also can't specify the \-o option combined with the \-c option.
63.SH "FILES"
64.nf
65\fI/sys/devices/system/cpu/cpu*/cpufreq/\fP
66\fI/proc/cpufreq\fP (deprecated)
67\fI/proc/sys/cpu/\fP (deprecated)
68.fi
69.SH "AUTHORS"
70.nf
71Dominik Brodowski <linux@brodo.de> \- author
72Mattia Dongili<malattia@gmail.com> \- first autolibtoolization
73.fi
74.SH "SEE ALSO"
75.LP
76cpupower\-frequency\-set(1), cpupower(1)
diff --git a/tools/power/cpupower/man/cpupower-frequency-set.1 b/tools/power/cpupower/man/cpupower-frequency-set.1
new file mode 100644
index 00000000000..685f469093a
--- /dev/null
+++ b/tools/power/cpupower/man/cpupower-frequency-set.1
@@ -0,0 +1,54 @@
1.TH "cpupower-freqency-set" "1" "0.1" "Mattia Dongili" ""
2.SH "NAME"
3.LP
4cpupower frequency\-set \- A small tool which allows to modify cpufreq settings.
5.SH "SYNTAX"
6.LP
7cpupower [ \-c cpu ] frequency\-set [\fIoptions\fP]
8.SH "DESCRIPTION"
9.LP
10cpupower frequency\-set allows you to modify cpufreq settings without having to type e.g. "/sys/devices/system/cpu/cpu0/cpufreq/scaling_set_speed" all the time.
11.SH "OPTIONS"
12.LP
13.TP
14\fB\-d\fR \fB\-\-min\fR <FREQ>
15new minimum CPU frequency the governor may select.
16.TP
17\fB\-u\fR \fB\-\-max\fR <FREQ>
18new maximum CPU frequency the governor may select.
19.TP
20\fB\-g\fR \fB\-\-governor\fR <GOV>
21new cpufreq governor.
22.TP
23\fB\-f\fR \fB\-\-freq\fR <FREQ>
24specific frequency to be set. Requires userspace governor to be available and loaded.
25.TP
26\fB\-r\fR \fB\-\-related\fR
27modify all hardware-related CPUs at the same time
28.TP
29\fB\-h\fR \fB\-\-help\fR
30Prints out the help screen.
31.SH "REMARKS"
32.LP
33By default values are applied on all cores. How to modify single core
34configurations is described in the cpupower(1) manpage in the \-\-cpu option section.
35.LP
36The \-f FREQ, \-\-freq FREQ parameter cannot be combined with any other parameter.
37.LP
38FREQuencies can be passed in Hz, kHz (default), MHz, GHz, or THz by postfixing the value with the wanted unit name, without any space (frequency in kHz =^ Hz * 0.001 =^ MHz * 1000 =^ GHz * 1000000).
39.LP
40On Linux kernels up to 2.6.29, the \-r or \-\-related parameter is ignored.
41.SH "FILES"
42.nf
43\fI/sys/devices/system/cpu/cpu*/cpufreq/\fP
44\fI/proc/cpufreq\fP (deprecated)
45\fI/proc/sys/cpu/\fP (deprecated)
46.fi
47.SH "AUTHORS"
48.nf
49Dominik Brodowski <linux@brodo.de> \- author
50Mattia Dongili<malattia@gmail.com> \- first autolibtoolization
51.fi
52.SH "SEE ALSO"
53.LP
54cpupower\-frequency\-info(1), cpupower(1)
diff --git a/tools/power/cpupower/man/cpupower-info.1 b/tools/power/cpupower/man/cpupower-info.1
new file mode 100644
index 00000000000..58e21196f17
--- /dev/null
+++ b/tools/power/cpupower/man/cpupower-info.1
@@ -0,0 +1,19 @@
1.TH CPUPOWER\-INFO "1" "22/02/2011" "" "cpupower Manual"
2.SH NAME
3cpupower\-info \- Shows processor power related kernel or hardware configurations
4.SH SYNOPSIS
5.ft B
6.B cpupower info [ \-b ] [ \-s ] [ \-m ]
7
8.SH DESCRIPTION
9\fBcpupower info \fP shows kernel configurations or processor hardware
10registers affecting processor power saving policies.
11
12Some options are platform wide, some affect single cores. By default values
13of core zero are displayed only. cpupower --cpu all cpuinfo will show the
14settings of all cores, see cpupower(1) how to choose specific cores.
15
16.SH "SEE ALSO"
17Options are described in detail in:
18
19cpupower(1), cpupower-set(1)
diff --git a/tools/power/cpupower/man/cpupower-monitor.1 b/tools/power/cpupower/man/cpupower-monitor.1
new file mode 100644
index 00000000000..d5cfa265c3d
--- /dev/null
+++ b/tools/power/cpupower/man/cpupower-monitor.1
@@ -0,0 +1,179 @@
1.TH CPUPOWER\-MONITOR "1" "22/02/2011" "" "cpupower Manual"
2.SH NAME
3cpupower\-monitor \- Report processor frequency and idle statistics
4.SH SYNOPSIS
5.ft B
6.B cpupower monitor
7.RB "\-l"
8
9.B cpupower monitor
10.RB [ "\-m <mon1>," [ "<mon2>,..." ] ]
11.RB [ "\-i seconds" ]
12.br
13.B cpupower monitor
14.RB [ "\-m <mon1>," [ "<mon2>,..." ] ]
15.RB command
16.br
17.SH DESCRIPTION
18\fBcpupower-monitor \fP reports processor topology, frequency and idle power
19state statistics. Either \fBcommand\fP is forked and
20statistics are printed upon its completion, or statistics are printed periodically.
21
22\fBcpupower-monitor \fP implements independent processor sleep state and
23frequency counters. Some are retrieved from kernel statistics, some are
24directly reading out hardware registers. Use \-l to get an overview which are
25supported on your system.
26
27.SH Options
28.PP
29\-l
30.RS 4
31List available monitors on your system. Additional details about each monitor
32are shown:
33.RS 2
34.IP \(bu
35The name in quotation marks which can be passed to the \-m parameter.
36.IP \(bu
37The number of different counters the monitor supports in brackets.
38.IP \(bu
39The amount of time in seconds the counters might overflow, due to
40implementation constraints.
41.IP \(bu
42The name and a description of each counter and its processor hierarchy level
43coverage in square brackets:
44.RS 4
45.IP \(bu
46[T] \-> Thread
47.IP \(bu
48[C] \-> Core
49.IP \(bu
50[P] \-> Processor Package (Socket)
51.IP \(bu
52[M] \-> Machine/Platform wide counter
53.RE
54.RE
55.RE
56.PP
57\-m <mon1>,<mon2>,...
58.RS 4
59Only display specific monitors. Use the monitor string(s) provided by \-l option.
60.RE
61.PP
62\-i seconds
63.RS 4
64Measure intervall.
65.RE
66.PP
67command
68.RS 4
69Measure idle and frequency characteristics of an arbitrary command/workload.
70The executable \fBcommand\fP is forked and upon its exit, statistics gathered since it was
71forked are displayed.
72.RE
73.PP
74\-v
75.RS 4
76Increase verbosity if the binary was compiled with the DEBUG option set.
77.RE
78
79.SH MONITOR DESCRIPTIONS
80.SS "Idle_Stats"
81Shows statistics of the cpuidle kernel subsystem. Values are retrieved from
82/sys/devices/system/cpu/cpu*/cpuidle/state*/.
83The kernel updates these values every time an idle state is entered or
84left. Therefore there can be some inaccuracy when cores are in an idle
85state for some time when the measure starts or ends. In worst case it can happen
86that one core stayed in an idle state for the whole measure time and the idle
87state usage time as exported by the kernel did not get updated. In this case
88a state residency of 0 percent is shown while it was 100.
89
90.SS "Mperf"
91The name comes from the aperf/mperf (average and maximum) MSR registers used
92which are available on recent X86 processors. It shows the average frequency
93(including boost frequencies).
94The fact that on all recent hardware the mperf timer stops ticking in any idle
95state it is also used to show C0 (processor is active) and Cx (processor is in
96any sleep state) times. These counters do not have the inaccuracy restrictions
97the "Idle_Stats" counters may show.
98May work poorly on Linux-2.6.20 through 2.6.29, as the \fBacpi-cpufreq \fP
99kernel frequency driver periodically cleared aperf/mperf registers in those
100kernels.
101
102.SS "Nehalem" "SandyBridge"
103Intel Core and Package sleep state counters.
104Threads (hyperthreaded cores) may not be able to enter deeper core states if
105its sibling is utilized.
106Deepest package sleep states may in reality show up as machine/platform wide
107sleep states and can only be entered if all cores are idle. Look up Intel
108manuals (some are provided in the References section) for further details.
109
110.SS "Ontario" "Liano"
111AMD laptop and desktop processor (family 12h and 14h) sleep state counters.
112The registers are accessed via PCI and therefore can still be read out while
113cores have been offlined.
114
115There is one special counter: NBP1 (North Bridge P1).
116This one always returns 0 or 1, depending on whether the North Bridge P1
117power state got entered at least once during measure time.
118Being able to enter NBP1 state also depends on graphics power management.
119Therefore this counter can be used to verify whether the graphics' driver
120power management is working as expected.
121
122.SH EXAMPLES
123
124cpupower monitor -l" may show:
125.RS 4
126Monitor "Mperf" (3 states) \- Might overflow after 922000000 s
127
128 ...
129
130Monitor "Idle_Stats" (3 states) \- Might overflow after 4294967295 s
131
132 ...
133
134.RE
135cpupower monitor \-m "Idle_Stats,Mperf" scp /tmp/test /nfs/tmp
136
137Monitor the scp command, show both Mperf and Idle_Stats states counter
138statistics, but in exchanged order.
139
140
141
142.RE
143Be careful that the typical command to fully utilize one CPU by doing:
144
145cpupower monitor cat /dev/zero >/dev/null
146
147Does not work as expected, because the measured output is redirected to
148/dev/null. This could get workarounded by putting the line into an own, tiny
149shell script. Hit CTRL\-c to terminate the command and get the measure output
150displayed.
151
152.SH REFERENCES
153"BIOS and Kernel Developer’s Guide (BKDG) for AMD Family 14h Processors"
154http://support.amd.com/us/Processor_TechDocs/43170.pdf
155
156"Intel® Turbo Boost Technology
157in Intel® Core™ Microarchitecture (Nehalem) Based Processors"
158http://download.intel.com/design/processor/applnots/320354.pdf
159
160"Intel® 64 and IA-32 Architectures Software Developer's Manual
161Volume 3B: System Programming Guide"
162http://www.intel.com/products/processor/manuals
163
164.SH FILES
165.ta
166.nf
167/dev/cpu/*/msr
168/sys/devices/system/cpu/cpu*/cpuidle/state*/.
169.fi
170
171.SH "SEE ALSO"
172powertop(8), msr(4), vmstat(8)
173.PP
174.SH AUTHORS
175.nf
176Written by Thomas Renninger <trenn@suse.de>
177
178Nehalem, SandyBridge monitors and command passing
179based on turbostat.8 from Len Brown <len.brown@intel.com>
diff --git a/tools/power/cpupower/man/cpupower-set.1 b/tools/power/cpupower/man/cpupower-set.1
new file mode 100644
index 00000000000..c4954a9fe4e
--- /dev/null
+++ b/tools/power/cpupower/man/cpupower-set.1
@@ -0,0 +1,103 @@
1.TH CPUPOWER\-SET "1" "22/02/2011" "" "cpupower Manual"
2.SH NAME
3cpupower\-set \- Set processor power related kernel or hardware configurations
4.SH SYNOPSIS
5.ft B
6.B cpupower set [ \-b VAL ] [ \-s VAL ] [ \-m VAL ]
7
8
9.SH DESCRIPTION
10\fBcpupower set \fP sets kernel configurations or directly accesses hardware
11registers affecting processor power saving policies.
12
13Some options are platform wide, some affect single cores. By default values
14are applied on all cores. How to modify single core configurations is
15described in the cpupower(1) manpage in the \-\-cpu option section. Whether an
16option affects the whole system or can be applied to individual cores is
17described in the Options sections.
18
19Use \fBcpupower info \fP to read out current settings and whether they are
20supported on the system at all.
21
22.SH Options
23.PP
24\-\-perf-bias, \-b
25.RS 4
26Sets a register on supported Intel processore which allows software to convey
27its policy for the relative importance of performance versus energy savings to
28the processor.
29
30The range of valid numbers is 0-15, where 0 is maximum
31performance and 15 is maximum energy efficiency.
32
33The processor uses this information in model-specific ways
34when it must select trade-offs between performance and
35energy efficiency.
36
37This policy hint does not supersede Processor Performance states
38(P-states) or CPU Idle power states (C-states), but allows
39software to have influence where it would otherwise be unable
40to express a preference.
41
42For example, this setting may tell the hardware how
43aggressively or conservatively to control frequency
44in the "turbo range" above the explicitly OS-controlled
45P-state frequency range. It may also tell the hardware
46how aggressively it should enter the OS requested C-states.
47
48This option can be applied to individual cores only via the \-\-cpu option,
49cpupower(1).
50
51Setting the performance bias value on one CPU can modify the setting on
52related CPUs as well (for example all CPUs on one socket), because of
53hardware restrictions.
54Use \fBcpupower -c all info -b\fP to verify.
55
56This options needs the msr kernel driver (CONFIG_X86_MSR) loaded.
57.RE
58.PP
59\-\-sched\-mc, \-m [ VAL ]
60.RE
61\-\-sched\-smt, \-s [ VAL ]
62.RS 4
63\-\-sched\-mc utilizes cores in one processor package/socket first before
64processes are scheduled to other processor packages/sockets.
65
66\-\-sched\-smt utilizes thread siblings of one processor core first before
67processes are scheduled to other cores.
68
69The impact on power consumption and performance (positiv or negativ) heavily
70depends on processor support for deep sleep states, frequency scaling and
71frequency boost modes and their dependencies between other thread siblings
72and processor cores.
73
74Taken over from kernel documentation:
75
76Adjust the kernel's multi-core scheduler support.
77
78Possible values are:
79.RS 2
800 - No power saving load balance (default value)
81
821 - Fill one thread/core/package first for long running threads
83
842 - Also bias task wakeups to semi-idle cpu package for power
85savings
86.RE
87
88sched_mc_power_savings is dependent upon SCHED_MC, which is
89itself architecture dependent.
90
91sched_smt_power_savings is dependent upon SCHED_SMT, which
92is itself architecture dependent.
93
94The two files are independent of each other. It is possible
95that one file may be present without the other.
96
97.SH "SEE ALSO"
98cpupower-info(1), cpupower-monitor(1), powertop(1)
99.PP
100.SH AUTHORS
101.nf
102\-\-perf\-bias parts written by Len Brown <len.brown@intel.com>
103Thomas Renninger <trenn@suse.de>
diff --git a/tools/power/cpupower/man/cpupower.1 b/tools/power/cpupower/man/cpupower.1
new file mode 100644
index 00000000000..baf741d06e8
--- /dev/null
+++ b/tools/power/cpupower/man/cpupower.1
@@ -0,0 +1,72 @@
1.TH CPUPOWER "1" "07/03/2011" "" "cpupower Manual"
2.SH NAME
3cpupower \- Shows and sets processor power related values
4.SH SYNOPSIS
5.ft B
6.B cpupower [ \-c cpulist ] <command> [ARGS]
7
8.B cpupower \-v|\-\-version
9
10.B cpupower \-h|\-\-help
11
12.SH DESCRIPTION
13\fBcpupower \fP is a collection of tools to examine and tune power saving
14related features of your processor.
15
16The manpages of the commands (cpupower\-<command>(1)) provide detailed
17descriptions of supported features. Run \fBcpupower help\fP to get an overview
18of supported commands.
19
20.SH Options
21.PP
22\-\-help, \-h
23.RS 4
24Shows supported commands and general usage.
25.RE
26.PP
27\-\-cpu cpulist, \-c cpulist
28.RS 4
29Only show or set values for specific cores.
30This option is not supported by all commands, details can be found in the
31manpages of the commands.
32
33Some commands access all cores (typically the *\-set commands), some only
34the first core (typically the *\-info commands) by default.
35
36The syntax for <cpulist> is based on how the kernel exports CPU bitmasks via
37sysfs files. Some examples:
38.RS 4
39.TP 16
40Input
41Equivalent to
42.TP
43all
44all cores
45.TP
460\-3
470,1,2,3
48.TP
490\-7:2
500,2,4,6
51.TP
521,3,5-7
531,3,5,6,7
54.TP
550\-3:2,8\-15:4
560,2,8,12
57.RE
58.RE
59.PP
60\-\-version, \-v
61.RS 4
62Print the package name and version number.
63
64.SH "SEE ALSO"
65cpupower-set(1), cpupower-info(1), cpupower-idle(1),
66cpupower-frequency-set(1), cpupower-frequency-info(1), cpupower-monitor(1),
67powertop(1)
68.PP
69.SH AUTHORS
70.nf
71\-\-perf\-bias parts written by Len Brown <len.brown@intel.com>
72Thomas Renninger <trenn@suse.de>
diff --git a/tools/power/cpupower/po/cs.po b/tools/power/cpupower/po/cs.po
new file mode 100644
index 00000000000..cb22c45c506
--- /dev/null
+++ b/tools/power/cpupower/po/cs.po
@@ -0,0 +1,944 @@
1# translation of cs.po to Czech
2# Czech translation for cpufrequtils package
3# Czech messages for cpufrequtils.
4# Copyright (C) 2007 kavol
5# This file is distributed under the same license as the cpufrequtils package.
6#
7# Karel Volný <kavol@seznam.cz>, 2007, 2008.
8msgid ""
9msgstr ""
10"Project-Id-Version: cs\n"
11"Report-Msgid-Bugs-To: \n"
12"POT-Creation-Date: 2011-03-08 17:03+0100\n"
13"PO-Revision-Date: 2008-06-11 16:26+0200\n"
14"Last-Translator: Karel Volný <kavol@seznam.cz>\n"
15"Language-Team: Czech <diskuze@lists.l10n.cz>\n"
16"Language: cs\n"
17"MIME-Version: 1.0\n"
18"Content-Type: text/plain; charset=UTF-8\n"
19"Content-Transfer-Encoding: 8bit\n"
20"Plural-Forms: nplurals=3; plural=(n==1) ? 0 : (n>=2 && n<=4) ? 1 : 2;\n"
21"X-Generator: KBabel 1.11.4\n"
22
23#: utils/idle_monitor/nhm_idle.c:36
24msgid "Processor Core C3"
25msgstr ""
26
27#: utils/idle_monitor/nhm_idle.c:43
28msgid "Processor Core C6"
29msgstr ""
30
31#: utils/idle_monitor/nhm_idle.c:51
32msgid "Processor Package C3"
33msgstr ""
34
35#: utils/idle_monitor/nhm_idle.c:58 utils/idle_monitor/amd_fam14h_idle.c:70
36msgid "Processor Package C6"
37msgstr ""
38
39#: utils/idle_monitor/snb_idle.c:33
40msgid "Processor Core C7"
41msgstr ""
42
43#: utils/idle_monitor/snb_idle.c:40
44msgid "Processor Package C2"
45msgstr ""
46
47#: utils/idle_monitor/snb_idle.c:47
48msgid "Processor Package C7"
49msgstr ""
50
51#: utils/idle_monitor/amd_fam14h_idle.c:56
52msgid "Package in sleep state (PC1 or deeper)"
53msgstr ""
54
55#: utils/idle_monitor/amd_fam14h_idle.c:63
56msgid "Processor Package C1"
57msgstr ""
58
59#: utils/idle_monitor/amd_fam14h_idle.c:77
60msgid "North Bridge P1 boolean counter (returns 0 or 1)"
61msgstr ""
62
63#: utils/idle_monitor/mperf_monitor.c:35
64msgid "Processor Core not idle"
65msgstr ""
66
67#: utils/idle_monitor/mperf_monitor.c:42
68msgid "Processor Core in an idle state"
69msgstr ""
70
71#: utils/idle_monitor/mperf_monitor.c:50
72msgid "Average Frequency (including boost) in MHz"
73msgstr ""
74
75#: utils/idle_monitor/cpupower-monitor.c:66
76#, c-format
77msgid ""
78"cpupower monitor: [-h] [ [-t] | [-l] | [-m <mon1>,[<mon2>] ] ] [-i "
79"interval_sec | -c command ...]\n"
80msgstr ""
81
82#: utils/idle_monitor/cpupower-monitor.c:69
83#, c-format
84msgid ""
85"cpupower monitor: [-v] [-h] [ [-t] | [-l] | [-m <mon1>,[<mon2>] ] ] [-i "
86"interval_sec | -c command ...]\n"
87msgstr ""
88
89#: utils/idle_monitor/cpupower-monitor.c:71
90#, c-format
91msgid "\t -v: be more verbose\n"
92msgstr ""
93
94#: utils/idle_monitor/cpupower-monitor.c:73
95#, c-format
96msgid "\t -h: print this help\n"
97msgstr ""
98
99#: utils/idle_monitor/cpupower-monitor.c:74
100#, c-format
101msgid "\t -i: time intervall to measure for in seconds (default 1)\n"
102msgstr ""
103
104#: utils/idle_monitor/cpupower-monitor.c:75
105#, c-format
106msgid "\t -t: show CPU topology/hierarchy\n"
107msgstr ""
108
109#: utils/idle_monitor/cpupower-monitor.c:76
110#, c-format
111msgid "\t -l: list available CPU sleep monitors (for use with -m)\n"
112msgstr ""
113
114#: utils/idle_monitor/cpupower-monitor.c:77
115#, c-format
116msgid "\t -m: show specific CPU sleep monitors only (in same order)\n"
117msgstr ""
118
119#: utils/idle_monitor/cpupower-monitor.c:79
120#, c-format
121msgid ""
122"only one of: -t, -l, -m are allowed\n"
123"If none of them is passed,"
124msgstr ""
125
126#: utils/idle_monitor/cpupower-monitor.c:80
127#, c-format
128msgid " all supported monitors are shown\n"
129msgstr ""
130
131#: utils/idle_monitor/cpupower-monitor.c:197
132#, c-format
133msgid "Monitor %s, Counter %s has no count function. Implementation error\n"
134msgstr ""
135
136#: utils/idle_monitor/cpupower-monitor.c:207
137#, c-format
138msgid " *is offline\n"
139msgstr ""
140
141#: utils/idle_monitor/cpupower-monitor.c:236
142#, c-format
143msgid "%s: max monitor name length (%d) exceeded\n"
144msgstr ""
145
146#: utils/idle_monitor/cpupower-monitor.c:250
147#, c-format
148msgid "No matching monitor found in %s, try -l option\n"
149msgstr ""
150
151#: utils/idle_monitor/cpupower-monitor.c:266
152#, c-format
153msgid "Monitor \"%s\" (%d states) - Might overflow after %u s\n"
154msgstr ""
155
156#: utils/idle_monitor/cpupower-monitor.c:319
157#, c-format
158msgid "%s took %.5f seconds and exited with status %d\n"
159msgstr ""
160
161#: utils/idle_monitor/cpupower-monitor.c:406
162#, c-format
163msgid "Cannot read number of available processors\n"
164msgstr ""
165
166#: utils/idle_monitor/cpupower-monitor.c:417
167#, c-format
168msgid "Available monitor %s needs root access\n"
169msgstr ""
170
171#: utils/idle_monitor/cpupower-monitor.c:428
172#, c-format
173msgid "No HW Cstate monitors found\n"
174msgstr ""
175
176#: utils/cpupower.c:78
177#, c-format
178msgid "cpupower [ -c cpulist ] subcommand [ARGS]\n"
179msgstr ""
180
181#: utils/cpupower.c:79
182#, c-format
183msgid "cpupower --version\n"
184msgstr ""
185
186#: utils/cpupower.c:80
187#, c-format
188msgid "Supported subcommands are:\n"
189msgstr ""
190
191#: utils/cpupower.c:83
192#, c-format
193msgid ""
194"\n"
195"Some subcommands can make use of the -c cpulist option.\n"
196msgstr ""
197
198#: utils/cpupower.c:84
199#, c-format
200msgid "Look at the general cpupower manpage how to use it\n"
201msgstr ""
202
203#: utils/cpupower.c:85
204#, c-format
205msgid "and read up the subcommand's manpage whether it is supported.\n"
206msgstr ""
207
208#: utils/cpupower.c:86
209#, c-format
210msgid ""
211"\n"
212"Use cpupower help subcommand for getting help for above subcommands.\n"
213msgstr ""
214
215#: utils/cpupower.c:91
216#, c-format
217msgid "Report errors and bugs to %s, please.\n"
218msgstr ""
219"Chyby v programu prosím hlaste na %s (anglicky).\n"
220"Chyby v pÅ™ekladu prosím hlaste na kavol@seznam.cz (Äesky ;-)\n"
221
222#: utils/cpupower.c:114
223#, c-format
224msgid "Error parsing cpu list\n"
225msgstr ""
226
227#: utils/cpupower.c:172
228#, c-format
229msgid "Subcommand %s needs root privileges\n"
230msgstr ""
231
232#: utils/cpufreq-info.c:31
233#, c-format
234msgid "Couldn't count the number of CPUs (%s: %s), assuming 1\n"
235msgstr "Nelze zjistit poÄet CPU (%s: %s), pÅ™edpokládá se 1.\n"
236
237#: utils/cpufreq-info.c:63
238#, c-format
239msgid ""
240" minimum CPU frequency - maximum CPU frequency - governor\n"
241msgstr ""
242" minimální frekvence CPU - maximální frekvence CPU - regulátor\n"
243
244#: utils/cpufreq-info.c:151
245#, c-format
246msgid "Error while evaluating Boost Capabilities on CPU %d -- are you root?\n"
247msgstr ""
248
249#. P state changes via MSR are identified via cpuid 80000007
250#. on Intel and AMD, but we assume boost capable machines can do that
251#. if (cpuid_eax(0x80000000) >= 0x80000007
252#. && (cpuid_edx(0x80000007) & (1 << 7)))
253#.
254#: utils/cpufreq-info.c:161
255#, c-format
256msgid " boost state support: \n"
257msgstr ""
258
259#: utils/cpufreq-info.c:163
260#, c-format
261msgid " Supported: %s\n"
262msgstr ""
263
264#: utils/cpufreq-info.c:163 utils/cpufreq-info.c:164
265msgid "yes"
266msgstr ""
267
268#: utils/cpufreq-info.c:163 utils/cpufreq-info.c:164
269msgid "no"
270msgstr ""
271
272#: utils/cpufreq-info.c:164
273#, fuzzy, c-format
274msgid " Active: %s\n"
275msgstr " ovladaÄ: %s\n"
276
277#: utils/cpufreq-info.c:177
278#, c-format
279msgid " Boost States: %d\n"
280msgstr ""
281
282#: utils/cpufreq-info.c:178
283#, c-format
284msgid " Total States: %d\n"
285msgstr ""
286
287#: utils/cpufreq-info.c:181
288#, c-format
289msgid " Pstate-Pb%d: %luMHz (boost state)\n"
290msgstr ""
291
292#: utils/cpufreq-info.c:184
293#, c-format
294msgid " Pstate-P%d: %luMHz\n"
295msgstr ""
296
297#: utils/cpufreq-info.c:211
298#, c-format
299msgid " no or unknown cpufreq driver is active on this CPU\n"
300msgstr " pro tento CPU není aktivní žádný známý ovladaÄ cpufreq\n"
301
302#: utils/cpufreq-info.c:213
303#, c-format
304msgid " driver: %s\n"
305msgstr " ovladaÄ: %s\n"
306
307#: utils/cpufreq-info.c:219
308#, fuzzy, c-format
309msgid " CPUs which run at the same hardware frequency: "
310msgstr " CPU, které musí měnit frekvenci zároveň: "
311
312#: utils/cpufreq-info.c:230
313#, fuzzy, c-format
314msgid " CPUs which need to have their frequency coordinated by software: "
315msgstr " CPU, které musí měnit frekvenci zároveň: "
316
317#: utils/cpufreq-info.c:241
318#, c-format
319msgid " maximum transition latency: "
320msgstr ""
321
322#: utils/cpufreq-info.c:247
323#, c-format
324msgid " hardware limits: "
325msgstr " hardwarové meze: "
326
327#: utils/cpufreq-info.c:256
328#, c-format
329msgid " available frequency steps: "
330msgstr " dostupné frekvence: "
331
332#: utils/cpufreq-info.c:269
333#, c-format
334msgid " available cpufreq governors: "
335msgstr " dostupné regulátory: "
336
337#: utils/cpufreq-info.c:280
338#, c-format
339msgid " current policy: frequency should be within "
340msgstr " souÄasná taktika: frekvence by mÄ›la být mezi "
341
342#: utils/cpufreq-info.c:282
343#, c-format
344msgid " and "
345msgstr " a "
346
347#: utils/cpufreq-info.c:286
348#, c-format
349msgid ""
350"The governor \"%s\" may decide which speed to use\n"
351" within this range.\n"
352msgstr ""
353" Regulátor \"%s\" může rozhodnout jakou frekvenci použít\n"
354" v těchto mezích.\n"
355
356#: utils/cpufreq-info.c:293
357#, c-format
358msgid " current CPU frequency is "
359msgstr " souÄasná frekvence CPU je "
360
361#: utils/cpufreq-info.c:296
362#, c-format
363msgid " (asserted by call to hardware)"
364msgstr " (zjištěno hardwarovým voláním)"
365
366#: utils/cpufreq-info.c:304
367#, c-format
368msgid " cpufreq stats: "
369msgstr " statistika cpufreq: "
370
371#: utils/cpufreq-info.c:472
372#, fuzzy, c-format
373msgid "Usage: cpupower freqinfo [options]\n"
374msgstr "Užití: cpufreq-info [pÅ™epínaÄe]\n"
375
376#: utils/cpufreq-info.c:473 utils/cpufreq-set.c:26 utils/cpupower-set.c:23
377#: utils/cpupower-info.c:22 utils/cpuidle-info.c:148
378#, c-format
379msgid "Options:\n"
380msgstr "PÅ™epínaÄe:\n"
381
382#: utils/cpufreq-info.c:474
383#, fuzzy, c-format
384msgid " -e, --debug Prints out debug information [default]\n"
385msgstr " -e, --debug Vypíše ladicí informace\n"
386
387#: utils/cpufreq-info.c:475
388#, c-format
389msgid ""
390" -f, --freq Get frequency the CPU currently runs at, according\n"
391" to the cpufreq core *\n"
392msgstr ""
393" -f, --freq Zjistí aktuální frekvenci, na které CPU běží\n"
394" podle cpufreq *\n"
395
396#: utils/cpufreq-info.c:477
397#, c-format
398msgid ""
399" -w, --hwfreq Get frequency the CPU currently runs at, by reading\n"
400" it from hardware (only available to root) *\n"
401msgstr ""
402" -w, --hwfreq Zjistí aktuální frekvenci, na které CPU běží\n"
403" z hardware (dostupné jen uživateli root) *\n"
404
405#: utils/cpufreq-info.c:479
406#, c-format
407msgid ""
408" -l, --hwlimits Determine the minimum and maximum CPU frequency "
409"allowed *\n"
410msgstr ""
411" -l, --hwlimits Zjistí minimální a maximální dostupnou frekvenci CPU "
412"*\n"
413
414#: utils/cpufreq-info.c:480
415#, c-format
416msgid " -d, --driver Determines the used cpufreq kernel driver *\n"
417msgstr " -d, --driver Zjistí aktivní ovladaÄ cpufreq *\n"
418
419#: utils/cpufreq-info.c:481
420#, c-format
421msgid " -p, --policy Gets the currently used cpufreq policy *\n"
422msgstr " -p, --policy Zjistí aktuální taktiku cpufreq *\n"
423
424#: utils/cpufreq-info.c:482
425#, c-format
426msgid " -g, --governors Determines available cpufreq governors *\n"
427msgstr " -g, --governors Zjistí dostupné regulátory cpufreq *\n"
428
429#: utils/cpufreq-info.c:483
430#, fuzzy, c-format
431msgid ""
432" -r, --related-cpus Determines which CPUs run at the same hardware "
433"frequency *\n"
434msgstr ""
435" -a, --affected-cpus Zjistí, které CPU musí měnit frekvenci zároveň *\n"
436
437#: utils/cpufreq-info.c:484
438#, fuzzy, c-format
439msgid ""
440" -a, --affected-cpus Determines which CPUs need to have their frequency\n"
441" coordinated by software *\n"
442msgstr ""
443" -a, --affected-cpus Zjistí, které CPU musí měnit frekvenci zároveň *\n"
444
445#: utils/cpufreq-info.c:486
446#, c-format
447msgid " -s, --stats Shows cpufreq statistics if available\n"
448msgstr " -s, --stats Zobrazí statistiku cpufreq, je-li dostupná\n"
449
450#: utils/cpufreq-info.c:487
451#, fuzzy, c-format
452msgid ""
453" -y, --latency Determines the maximum latency on CPU frequency "
454"changes *\n"
455msgstr ""
456" -l, --hwlimits Zjistí minimální a maximální dostupnou frekvenci CPU "
457"*\n"
458
459#: utils/cpufreq-info.c:488
460#, c-format
461msgid " -b, --boost Checks for turbo or boost modes *\n"
462msgstr ""
463
464#: utils/cpufreq-info.c:489
465#, c-format
466msgid ""
467" -o, --proc Prints out information like provided by the /proc/"
468"cpufreq\n"
469" interface in 2.4. and early 2.6. kernels\n"
470msgstr ""
471" -o, --proc Vypíše informace ve formátu, jaký používalo rozhraní\n"
472" /proc/cpufreq v kernelech Å™ady 2.4 a Äasné 2.6\n"
473
474#: utils/cpufreq-info.c:491
475#, fuzzy, c-format
476msgid ""
477" -m, --human human-readable output for the -f, -w, -s and -y "
478"parameters\n"
479msgstr ""
480" -m, --human Výstup parametrů -f, -w a -s v „lidmi Äitelném“ "
481"formátu\n"
482
483#: utils/cpufreq-info.c:492 utils/cpuidle-info.c:152
484#, c-format
485msgid " -h, --help Prints out this screen\n"
486msgstr " -h, --help Vypíše tuto nápovědu\n"
487
488#: utils/cpufreq-info.c:495
489#, c-format
490msgid ""
491"If no argument or only the -c, --cpu parameter is given, debug output about\n"
492"cpufreq is printed which is useful e.g. for reporting bugs.\n"
493msgstr ""
494"Není-li zadán žádný parametr nebo je-li zadán pouze pÅ™epínaÄ -c, --cpu, "
495"jsou\n"
496"vypsány ladicí informace, což může být užiteÄné například pÅ™i hlášení chyb.\n"
497
498#: utils/cpufreq-info.c:497
499#, c-format
500msgid ""
501"For the arguments marked with *, omitting the -c or --cpu argument is\n"
502"equivalent to setting it to zero\n"
503msgstr ""
504"Není-li pÅ™i použití pÅ™epínaÄů oznaÄených * zadán parametr -c nebo --cpu,\n"
505"předpokládá se jeho hodnota 0.\n"
506
507#: utils/cpufreq-info.c:580
508#, c-format
509msgid ""
510"The argument passed to this tool can't be combined with passing a --cpu "
511"argument\n"
512msgstr "Zadaný parametr nemůže být použit zároveň s pÅ™epínaÄem -c nebo --cpu\n"
513
514#: utils/cpufreq-info.c:596
515#, c-format
516msgid ""
517"You can't specify more than one --cpu parameter and/or\n"
518"more than one output-specific argument\n"
519msgstr ""
520"Nelze zadat více než jeden parametr -c nebo --cpu\n"
521"anebo více než jeden parametr urÄující výstup\n"
522
523#: utils/cpufreq-info.c:600 utils/cpufreq-set.c:82 utils/cpupower-set.c:42
524#: utils/cpupower-info.c:42 utils/cpuidle-info.c:213
525#, c-format
526msgid "invalid or unknown argument\n"
527msgstr "neplatný nebo neznámý parametr\n"
528
529#: utils/cpufreq-info.c:617
530#, c-format
531msgid "couldn't analyze CPU %d as it doesn't seem to be present\n"
532msgstr "nelze analyzovat CPU %d, vypadá to, že není přítomen\n"
533
534#: utils/cpufreq-info.c:620 utils/cpupower-info.c:142
535#, c-format
536msgid "analyzing CPU %d:\n"
537msgstr "analyzuji CPU %d:\n"
538
539#: utils/cpufreq-set.c:25
540#, fuzzy, c-format
541msgid "Usage: cpupower frequency-set [options]\n"
542msgstr "Užití: cpufreq-set [pÅ™epínaÄe]\n"
543
544#: utils/cpufreq-set.c:27
545#, c-format
546msgid ""
547" -d FREQ, --min FREQ new minimum CPU frequency the governor may "
548"select\n"
549msgstr ""
550" -d FREQ, --min FREQ Nová nejnižší frekvence, kterou může regulátor "
551"vybrat\n"
552
553#: utils/cpufreq-set.c:28
554#, c-format
555msgid ""
556" -u FREQ, --max FREQ new maximum CPU frequency the governor may "
557"select\n"
558msgstr ""
559" -u FREQ, --max FREQ Nová nejvyšší frekvence, kterou může regulátor "
560"zvolit\n"
561
562#: utils/cpufreq-set.c:29
563#, c-format
564msgid " -g GOV, --governor GOV new cpufreq governor\n"
565msgstr " -g GOV, --governors GOV Nový regulátor cpufreq\n"
566
567#: utils/cpufreq-set.c:30
568#, c-format
569msgid ""
570" -f FREQ, --freq FREQ specific frequency to be set. Requires userspace\n"
571" governor to be available and loaded\n"
572msgstr ""
573" -f FREQ, --freq FREQ Frekvence, která má být nastavena. Vyžaduje, aby "
574"byl\n"
575" v jádře nahrán regulátor ‚userspace‘.\n"
576
577#: utils/cpufreq-set.c:32
578#, c-format
579msgid " -r, --related Switches all hardware-related CPUs\n"
580msgstr ""
581
582#: utils/cpufreq-set.c:33 utils/cpupower-set.c:28 utils/cpupower-info.c:27
583#, fuzzy, c-format
584msgid " -h, --help Prints out this screen\n"
585msgstr " -h, --help Vypíše tuto nápovědu\n"
586
587#: utils/cpufreq-set.c:35
588#, fuzzy, c-format
589msgid ""
590"Notes:\n"
591"1. Omitting the -c or --cpu argument is equivalent to setting it to \"all\"\n"
592msgstr ""
593"Není-li pÅ™i použití pÅ™epínaÄů oznaÄených * zadán parametr -c nebo --cpu,\n"
594"předpokládá se jeho hodnota 0.\n"
595
596#: utils/cpufreq-set.c:37
597#, fuzzy, c-format
598msgid ""
599"2. The -f FREQ, --freq FREQ parameter cannot be combined with any other "
600"parameter\n"
601" except the -c CPU, --cpu CPU parameter\n"
602"3. FREQuencies can be passed in Hz, kHz (default), MHz, GHz, or THz\n"
603" by postfixing the value with the wanted unit name, without any space\n"
604" (FREQuency in kHz =^ Hz * 0.001 =^ MHz * 1000 =^ GHz * 1000000).\n"
605msgstr ""
606"Poznámky:\n"
607"1. Vynechání parametru -c nebo --cpu je ekvivalentní jeho nastavení na 0\n"
608"2. PÅ™epínaÄ -f nebo --freq nemůže být použit zároveň s žádným jiným vyjma -"
609"c\n"
610" nebo --cpu\n"
611"3. Frekvence (FREQ) mohou být zadány v Hz, kHz (výchozí), MHz, GHz nebo THz\n"
612" pÅ™ipojením názvu jednotky bez mezery mezi Äíslem a jednotkou\n"
613" (FREQ v kHz =^ Hz * 0,001 = ^ MHz * 1000 =^ GHz * 1000000)\n"
614
615#: utils/cpufreq-set.c:57
616#, c-format
617msgid ""
618"Error setting new values. Common errors:\n"
619"- Do you have proper administration rights? (super-user?)\n"
620"- Is the governor you requested available and modprobed?\n"
621"- Trying to set an invalid policy?\n"
622"- Trying to set a specific frequency, but userspace governor is not "
623"available,\n"
624" for example because of hardware which cannot be set to a specific "
625"frequency\n"
626" or because the userspace governor isn't loaded?\n"
627msgstr ""
628"Chyba při nastavování nových hodnot. Obvyklé problémy:\n"
629"- Máte patÅ™iÄná administrátorská práva? (root?)\n"
630"- Je požadovaný regulátor dostupný v jádře? (modprobe?)\n"
631"- Snažíte se nastavit neplatnou taktiku?\n"
632"- Snažíte se nastavit urÄitou frekvenci, ale není dostupný\n"
633" regulátor ‚userspace‘, například protože není nahrán v jádře,\n"
634" nebo nelze na tomto hardware nastavit urÄitou frekvenci?\n"
635
636#: utils/cpufreq-set.c:170
637#, c-format
638msgid "wrong, unknown or unhandled CPU?\n"
639msgstr "neznámý nebo nepodporovaný CPU?\n"
640
641#: utils/cpufreq-set.c:302
642#, c-format
643msgid ""
644"the -f/--freq parameter cannot be combined with -d/--min, -u/--max or\n"
645"-g/--governor parameters\n"
646msgstr ""
647"pÅ™epínaÄ -f/--freq nemůže být použit zároveň\n"
648"s pÅ™epínaÄem -d/--min, -u/--max nebo -g/--governor\n"
649
650#: utils/cpufreq-set.c:308
651#, c-format
652msgid ""
653"At least one parameter out of -f/--freq, -d/--min, -u/--max, and\n"
654"-g/--governor must be passed\n"
655msgstr ""
656"Musí být zadán alespoň jeden pÅ™epínaÄ\n"
657"-f/--freq, -d/--min, -u/--max nebo -g/--governor\n"
658
659#: utils/cpufreq-set.c:347
660#, c-format
661msgid "Setting cpu: %d\n"
662msgstr ""
663
664#: utils/cpupower-set.c:22
665#, c-format
666msgid "Usage: cpupower set [ -b val ] [ -m val ] [ -s val ]\n"
667msgstr ""
668
669#: utils/cpupower-set.c:24
670#, c-format
671msgid ""
672" -b, --perf-bias [VAL] Sets CPU's power vs performance policy on some\n"
673" Intel models [0-15], see manpage for details\n"
674msgstr ""
675
676#: utils/cpupower-set.c:26
677#, c-format
678msgid ""
679" -m, --sched-mc [VAL] Sets the kernel's multi core scheduler policy.\n"
680msgstr ""
681
682#: utils/cpupower-set.c:27
683#, c-format
684msgid ""
685" -s, --sched-smt [VAL] Sets the kernel's thread sibling scheduler "
686"policy.\n"
687msgstr ""
688
689#: utils/cpupower-set.c:80
690#, c-format
691msgid "--perf-bias param out of range [0-%d]\n"
692msgstr ""
693
694#: utils/cpupower-set.c:91
695#, c-format
696msgid "--sched-mc param out of range [0-%d]\n"
697msgstr ""
698
699#: utils/cpupower-set.c:102
700#, c-format
701msgid "--sched-smt param out of range [0-%d]\n"
702msgstr ""
703
704#: utils/cpupower-set.c:121
705#, c-format
706msgid "Error setting sched-mc %s\n"
707msgstr ""
708
709#: utils/cpupower-set.c:127
710#, c-format
711msgid "Error setting sched-smt %s\n"
712msgstr ""
713
714#: utils/cpupower-set.c:146
715#, c-format
716msgid "Error setting perf-bias value on CPU %d\n"
717msgstr ""
718
719#: utils/cpupower-info.c:21
720#, c-format
721msgid "Usage: cpupower info [ -b ] [ -m ] [ -s ]\n"
722msgstr ""
723
724#: utils/cpupower-info.c:23
725#, c-format
726msgid ""
727" -b, --perf-bias Gets CPU's power vs performance policy on some\n"
728" Intel models [0-15], see manpage for details\n"
729msgstr ""
730
731#: utils/cpupower-info.c:25
732#, fuzzy, c-format
733msgid " -m, --sched-mc Gets the kernel's multi core scheduler policy.\n"
734msgstr " -p, --policy Zjistí aktuální taktiku cpufreq *\n"
735
736#: utils/cpupower-info.c:26
737#, c-format
738msgid ""
739" -s, --sched-smt Gets the kernel's thread sibling scheduler policy.\n"
740msgstr ""
741
742#: utils/cpupower-info.c:28
743#, c-format
744msgid ""
745"\n"
746"Passing no option will show all info, by default only on core 0\n"
747msgstr ""
748
749#: utils/cpupower-info.c:102
750#, c-format
751msgid "System's multi core scheduler setting: "
752msgstr ""
753
754#. if sysfs file is missing it's: errno == ENOENT
755#: utils/cpupower-info.c:105 utils/cpupower-info.c:114
756#, c-format
757msgid "not supported\n"
758msgstr ""
759
760#: utils/cpupower-info.c:111
761#, c-format
762msgid "System's thread sibling scheduler setting: "
763msgstr ""
764
765#: utils/cpupower-info.c:126
766#, c-format
767msgid "Intel's performance bias setting needs root privileges\n"
768msgstr ""
769
770#: utils/cpupower-info.c:128
771#, c-format
772msgid "System does not support Intel's performance bias setting\n"
773msgstr ""
774
775#: utils/cpupower-info.c:147
776#, c-format
777msgid "Could not read perf-bias value\n"
778msgstr ""
779
780#: utils/cpupower-info.c:150
781#, c-format
782msgid "perf-bias: %d\n"
783msgstr ""
784
785#: utils/cpuidle-info.c:28
786#, fuzzy, c-format
787msgid "Analyzing CPU %d:\n"
788msgstr "analyzuji CPU %d:\n"
789
790#: utils/cpuidle-info.c:32
791#, c-format
792msgid "CPU %u: No idle states\n"
793msgstr ""
794
795#: utils/cpuidle-info.c:36
796#, c-format
797msgid "CPU %u: Can't read idle state info\n"
798msgstr ""
799
800#: utils/cpuidle-info.c:41
801#, c-format
802msgid "Could not determine max idle state %u\n"
803msgstr ""
804
805#: utils/cpuidle-info.c:46
806#, c-format
807msgid "Number of idle states: %d\n"
808msgstr ""
809
810#: utils/cpuidle-info.c:48
811#, fuzzy, c-format
812msgid "Available idle states:"
813msgstr " dostupné frekvence: "
814
815#: utils/cpuidle-info.c:71
816#, c-format
817msgid "Flags/Description: %s\n"
818msgstr ""
819
820#: utils/cpuidle-info.c:74
821#, c-format
822msgid "Latency: %lu\n"
823msgstr ""
824
825#: utils/cpuidle-info.c:76
826#, c-format
827msgid "Usage: %lu\n"
828msgstr ""
829
830#: utils/cpuidle-info.c:78
831#, c-format
832msgid "Duration: %llu\n"
833msgstr ""
834
835#: utils/cpuidle-info.c:90
836#, c-format
837msgid "Could not determine cpuidle driver\n"
838msgstr ""
839
840#: utils/cpuidle-info.c:94
841#, fuzzy, c-format
842msgid "CPUidle driver: %s\n"
843msgstr " ovladaÄ: %s\n"
844
845#: utils/cpuidle-info.c:99
846#, c-format
847msgid "Could not determine cpuidle governor\n"
848msgstr ""
849
850#: utils/cpuidle-info.c:103
851#, c-format
852msgid "CPUidle governor: %s\n"
853msgstr ""
854
855#: utils/cpuidle-info.c:122
856#, c-format
857msgid "CPU %u: Can't read C-state info\n"
858msgstr ""
859
860#. printf("Cstates: %d\n", cstates);
861#: utils/cpuidle-info.c:127
862#, c-format
863msgid "active state: C0\n"
864msgstr ""
865
866#: utils/cpuidle-info.c:128
867#, c-format
868msgid "max_cstate: C%u\n"
869msgstr ""
870
871#: utils/cpuidle-info.c:129
872#, c-format
873msgid "maximum allowed latency: %lu usec\n"
874msgstr ""
875
876#: utils/cpuidle-info.c:130
877#, c-format
878msgid "states:\t\n"
879msgstr ""
880
881#: utils/cpuidle-info.c:132
882#, c-format
883msgid " C%d: type[C%d] "
884msgstr ""
885
886#: utils/cpuidle-info.c:134
887#, c-format
888msgid "promotion[--] demotion[--] "
889msgstr ""
890
891#: utils/cpuidle-info.c:135
892#, c-format
893msgid "latency[%03lu] "
894msgstr ""
895
896#: utils/cpuidle-info.c:137
897#, c-format
898msgid "usage[%08lu] "
899msgstr ""
900
901#: utils/cpuidle-info.c:139
902#, c-format
903msgid "duration[%020Lu] \n"
904msgstr ""
905
906#: utils/cpuidle-info.c:147
907#, fuzzy, c-format
908msgid "Usage: cpupower idleinfo [options]\n"
909msgstr "Užití: cpufreq-info [pÅ™epínaÄe]\n"
910
911#: utils/cpuidle-info.c:149
912#, fuzzy, c-format
913msgid " -s, --silent Only show general C-state information\n"
914msgstr " -e, --debug Vypíše ladicí informace\n"
915
916#: utils/cpuidle-info.c:150
917#, fuzzy, c-format
918msgid ""
919" -o, --proc Prints out information like provided by the /proc/"
920"acpi/processor/*/power\n"
921" interface in older kernels\n"
922msgstr ""
923" -o, --proc Vypíše informace ve formátu, jaký používalo rozhraní\n"
924" /proc/cpufreq v kernelech Å™ady 2.4 a Äasné 2.6\n"
925
926#: utils/cpuidle-info.c:209
927#, fuzzy, c-format
928msgid "You can't specify more than one output-specific argument\n"
929msgstr ""
930"Nelze zadat více než jeden parametr -c nebo --cpu\n"
931"anebo více než jeden parametr urÄující výstup\n"
932
933#~ msgid ""
934#~ " -c CPU, --cpu CPU CPU number which information shall be determined "
935#~ "about\n"
936#~ msgstr ""
937#~ " -c CPU, --cpu CPU Číslo CPU, o kterém se mají zjistit informace\n"
938
939#~ msgid ""
940#~ " -c CPU, --cpu CPU number of CPU where cpufreq settings shall be "
941#~ "modified\n"
942#~ msgstr ""
943#~ " -c CPU, --cpu CPU Číslo CPU pro který se má provést nastavení "
944#~ "cpufreq\n"
diff --git a/tools/power/cpupower/po/de.po b/tools/power/cpupower/po/de.po
new file mode 100644
index 00000000000..78c09e51663
--- /dev/null
+++ b/tools/power/cpupower/po/de.po
@@ -0,0 +1,961 @@
1# German translations for cpufrequtils package
2# German messages for cpufrequtils.
3# Copyright (C) 2004-2009 Dominik Brodowski <linux@dominikbrodowski.net>
4# This file is distributed under the same license as the cpufrequtils package.
5#
6msgid ""
7msgstr ""
8"Project-Id-Version: cpufrequtils 006\n"
9"Report-Msgid-Bugs-To: \n"
10"POT-Creation-Date: 2011-03-08 17:03+0100\n"
11"PO-Revision-Date: 2009-08-08 17:18+0100\n"
12"Last-Translator: <linux@dominikbrodowski.net>\n"
13"Language-Team: NONE\n"
14"Language: \n"
15"MIME-Version: 1.0\n"
16"Content-Type: text/plain; charset=ISO-8859-1\n"
17"Content-Transfer-Encoding: 8bit\n"
18"Plural-Forms: nplurals=2; plural=(n != 1);\n"
19
20#: utils/idle_monitor/nhm_idle.c:36
21msgid "Processor Core C3"
22msgstr ""
23
24#: utils/idle_monitor/nhm_idle.c:43
25msgid "Processor Core C6"
26msgstr ""
27
28#: utils/idle_monitor/nhm_idle.c:51
29msgid "Processor Package C3"
30msgstr ""
31
32#: utils/idle_monitor/nhm_idle.c:58 utils/idle_monitor/amd_fam14h_idle.c:70
33msgid "Processor Package C6"
34msgstr ""
35
36#: utils/idle_monitor/snb_idle.c:33
37msgid "Processor Core C7"
38msgstr ""
39
40#: utils/idle_monitor/snb_idle.c:40
41msgid "Processor Package C2"
42msgstr ""
43
44#: utils/idle_monitor/snb_idle.c:47
45msgid "Processor Package C7"
46msgstr ""
47
48#: utils/idle_monitor/amd_fam14h_idle.c:56
49msgid "Package in sleep state (PC1 or deeper)"
50msgstr ""
51
52#: utils/idle_monitor/amd_fam14h_idle.c:63
53msgid "Processor Package C1"
54msgstr ""
55
56#: utils/idle_monitor/amd_fam14h_idle.c:77
57msgid "North Bridge P1 boolean counter (returns 0 or 1)"
58msgstr ""
59
60#: utils/idle_monitor/mperf_monitor.c:35
61msgid "Processor Core not idle"
62msgstr ""
63
64#: utils/idle_monitor/mperf_monitor.c:42
65msgid "Processor Core in an idle state"
66msgstr ""
67
68#: utils/idle_monitor/mperf_monitor.c:50
69msgid "Average Frequency (including boost) in MHz"
70msgstr ""
71
72#: utils/idle_monitor/cpupower-monitor.c:66
73#, c-format
74msgid ""
75"cpupower monitor: [-h] [ [-t] | [-l] | [-m <mon1>,[<mon2>] ] ] [-i "
76"interval_sec | -c command ...]\n"
77msgstr ""
78
79#: utils/idle_monitor/cpupower-monitor.c:69
80#, c-format
81msgid ""
82"cpupower monitor: [-v] [-h] [ [-t] | [-l] | [-m <mon1>,[<mon2>] ] ] [-i "
83"interval_sec | -c command ...]\n"
84msgstr ""
85
86#: utils/idle_monitor/cpupower-monitor.c:71
87#, c-format
88msgid "\t -v: be more verbose\n"
89msgstr ""
90
91#: utils/idle_monitor/cpupower-monitor.c:73
92#, c-format
93msgid "\t -h: print this help\n"
94msgstr ""
95
96#: utils/idle_monitor/cpupower-monitor.c:74
97#, c-format
98msgid "\t -i: time intervall to measure for in seconds (default 1)\n"
99msgstr ""
100
101#: utils/idle_monitor/cpupower-monitor.c:75
102#, c-format
103msgid "\t -t: show CPU topology/hierarchy\n"
104msgstr ""
105
106#: utils/idle_monitor/cpupower-monitor.c:76
107#, c-format
108msgid "\t -l: list available CPU sleep monitors (for use with -m)\n"
109msgstr ""
110
111#: utils/idle_monitor/cpupower-monitor.c:77
112#, c-format
113msgid "\t -m: show specific CPU sleep monitors only (in same order)\n"
114msgstr ""
115
116#: utils/idle_monitor/cpupower-monitor.c:79
117#, c-format
118msgid ""
119"only one of: -t, -l, -m are allowed\n"
120"If none of them is passed,"
121msgstr ""
122
123#: utils/idle_monitor/cpupower-monitor.c:80
124#, c-format
125msgid " all supported monitors are shown\n"
126msgstr ""
127
128#: utils/idle_monitor/cpupower-monitor.c:197
129#, c-format
130msgid "Monitor %s, Counter %s has no count function. Implementation error\n"
131msgstr ""
132
133#: utils/idle_monitor/cpupower-monitor.c:207
134#, c-format
135msgid " *is offline\n"
136msgstr ""
137
138#: utils/idle_monitor/cpupower-monitor.c:236
139#, c-format
140msgid "%s: max monitor name length (%d) exceeded\n"
141msgstr ""
142
143#: utils/idle_monitor/cpupower-monitor.c:250
144#, c-format
145msgid "No matching monitor found in %s, try -l option\n"
146msgstr ""
147
148#: utils/idle_monitor/cpupower-monitor.c:266
149#, c-format
150msgid "Monitor \"%s\" (%d states) - Might overflow after %u s\n"
151msgstr ""
152
153#: utils/idle_monitor/cpupower-monitor.c:319
154#, c-format
155msgid "%s took %.5f seconds and exited with status %d\n"
156msgstr ""
157
158#: utils/idle_monitor/cpupower-monitor.c:406
159#, c-format
160msgid "Cannot read number of available processors\n"
161msgstr ""
162
163#: utils/idle_monitor/cpupower-monitor.c:417
164#, c-format
165msgid "Available monitor %s needs root access\n"
166msgstr ""
167
168#: utils/idle_monitor/cpupower-monitor.c:428
169#, c-format
170msgid "No HW Cstate monitors found\n"
171msgstr ""
172
173#: utils/cpupower.c:78
174#, c-format
175msgid "cpupower [ -c cpulist ] subcommand [ARGS]\n"
176msgstr ""
177
178#: utils/cpupower.c:79
179#, c-format
180msgid "cpupower --version\n"
181msgstr ""
182
183#: utils/cpupower.c:80
184#, c-format
185msgid "Supported subcommands are:\n"
186msgstr ""
187
188#: utils/cpupower.c:83
189#, c-format
190msgid ""
191"\n"
192"Some subcommands can make use of the -c cpulist option.\n"
193msgstr ""
194
195#: utils/cpupower.c:84
196#, c-format
197msgid "Look at the general cpupower manpage how to use it\n"
198msgstr ""
199
200#: utils/cpupower.c:85
201#, c-format
202msgid "and read up the subcommand's manpage whether it is supported.\n"
203msgstr ""
204
205#: utils/cpupower.c:86
206#, c-format
207msgid ""
208"\n"
209"Use cpupower help subcommand for getting help for above subcommands.\n"
210msgstr ""
211
212#: utils/cpupower.c:91
213#, c-format
214msgid "Report errors and bugs to %s, please.\n"
215msgstr "Bitte melden Sie Fehler an %s.\n"
216
217#: utils/cpupower.c:114
218#, c-format
219msgid "Error parsing cpu list\n"
220msgstr ""
221
222#: utils/cpupower.c:172
223#, c-format
224msgid "Subcommand %s needs root privileges\n"
225msgstr ""
226
227#: utils/cpufreq-info.c:31
228#, c-format
229msgid "Couldn't count the number of CPUs (%s: %s), assuming 1\n"
230msgstr ""
231"Konnte nicht die Anzahl der CPUs herausfinden (%s : %s), nehme daher 1 an.\n"
232
233#: utils/cpufreq-info.c:63
234#, c-format
235msgid ""
236" minimum CPU frequency - maximum CPU frequency - governor\n"
237msgstr ""
238" minimale CPU-Taktfreq. - maximale CPU-Taktfreq. - Regler \n"
239
240#: utils/cpufreq-info.c:151
241#, c-format
242msgid "Error while evaluating Boost Capabilities on CPU %d -- are you root?\n"
243msgstr ""
244
245#. P state changes via MSR are identified via cpuid 80000007
246#. on Intel and AMD, but we assume boost capable machines can do that
247#. if (cpuid_eax(0x80000000) >= 0x80000007
248#. && (cpuid_edx(0x80000007) & (1 << 7)))
249#.
250#: utils/cpufreq-info.c:161
251#, c-format
252msgid " boost state support: \n"
253msgstr ""
254
255#: utils/cpufreq-info.c:163
256#, c-format
257msgid " Supported: %s\n"
258msgstr ""
259
260#: utils/cpufreq-info.c:163 utils/cpufreq-info.c:164
261msgid "yes"
262msgstr ""
263
264#: utils/cpufreq-info.c:163 utils/cpufreq-info.c:164
265msgid "no"
266msgstr ""
267
268#: utils/cpufreq-info.c:164
269#, fuzzy, c-format
270msgid " Active: %s\n"
271msgstr " Treiber: %s\n"
272
273#: utils/cpufreq-info.c:177
274#, c-format
275msgid " Boost States: %d\n"
276msgstr ""
277
278#: utils/cpufreq-info.c:178
279#, c-format
280msgid " Total States: %d\n"
281msgstr ""
282
283#: utils/cpufreq-info.c:181
284#, c-format
285msgid " Pstate-Pb%d: %luMHz (boost state)\n"
286msgstr ""
287
288#: utils/cpufreq-info.c:184
289#, c-format
290msgid " Pstate-P%d: %luMHz\n"
291msgstr ""
292
293#: utils/cpufreq-info.c:211
294#, c-format
295msgid " no or unknown cpufreq driver is active on this CPU\n"
296msgstr " kein oder nicht bestimmbarer cpufreq-Treiber aktiv\n"
297
298#: utils/cpufreq-info.c:213
299#, c-format
300msgid " driver: %s\n"
301msgstr " Treiber: %s\n"
302
303#: utils/cpufreq-info.c:219
304#, c-format
305msgid " CPUs which run at the same hardware frequency: "
306msgstr " Folgende CPUs laufen mit der gleichen Hardware-Taktfrequenz: "
307
308#: utils/cpufreq-info.c:230
309#, c-format
310msgid " CPUs which need to have their frequency coordinated by software: "
311msgstr " Die Taktfrequenz folgender CPUs werden per Software koordiniert: "
312
313#: utils/cpufreq-info.c:241
314#, c-format
315msgid " maximum transition latency: "
316msgstr " Maximale Dauer eines Taktfrequenzwechsels: "
317
318#: utils/cpufreq-info.c:247
319#, c-format
320msgid " hardware limits: "
321msgstr " Hardwarebedingte Grenzen der Taktfrequenz: "
322
323#: utils/cpufreq-info.c:256
324#, c-format
325msgid " available frequency steps: "
326msgstr " mögliche Taktfrequenzen: "
327
328#: utils/cpufreq-info.c:269
329#, c-format
330msgid " available cpufreq governors: "
331msgstr " mögliche Regler: "
332
333#: utils/cpufreq-info.c:280
334#, c-format
335msgid " current policy: frequency should be within "
336msgstr " momentane Taktik: die Frequenz soll innerhalb "
337
338#: utils/cpufreq-info.c:282
339#, c-format
340msgid " and "
341msgstr " und "
342
343#: utils/cpufreq-info.c:286
344#, c-format
345msgid ""
346"The governor \"%s\" may decide which speed to use\n"
347" within this range.\n"
348msgstr ""
349" liegen. Der Regler \"%s\" kann frei entscheiden,\n"
350" welche Taktfrequenz innerhalb dieser Grenze verwendet "
351"wird.\n"
352
353#: utils/cpufreq-info.c:293
354#, c-format
355msgid " current CPU frequency is "
356msgstr " momentane Taktfrequenz ist "
357
358#: utils/cpufreq-info.c:296
359#, c-format
360msgid " (asserted by call to hardware)"
361msgstr " (verifiziert durch Nachfrage bei der Hardware)"
362
363#: utils/cpufreq-info.c:304
364#, c-format
365msgid " cpufreq stats: "
366msgstr " Statistik:"
367
368#: utils/cpufreq-info.c:472
369#, fuzzy, c-format
370msgid "Usage: cpupower freqinfo [options]\n"
371msgstr "Aufruf: cpufreq-info [Optionen]\n"
372
373#: utils/cpufreq-info.c:473 utils/cpufreq-set.c:26 utils/cpupower-set.c:23
374#: utils/cpupower-info.c:22 utils/cpuidle-info.c:148
375#, c-format
376msgid "Options:\n"
377msgstr "Optionen:\n"
378
379#: utils/cpufreq-info.c:474
380#, fuzzy, c-format
381msgid " -e, --debug Prints out debug information [default]\n"
382msgstr ""
383" -e, --debug Erzeugt detaillierte Informationen, hilfreich\n"
384" zum Aufspüren von Fehlern\n"
385
386#: utils/cpufreq-info.c:475
387#, c-format
388msgid ""
389" -f, --freq Get frequency the CPU currently runs at, according\n"
390" to the cpufreq core *\n"
391msgstr ""
392" -f, --freq Findet die momentane CPU-Taktfrquenz heraus (nach\n"
393" Meinung des Betriebssystems) *\n"
394
395#: utils/cpufreq-info.c:477
396#, c-format
397msgid ""
398" -w, --hwfreq Get frequency the CPU currently runs at, by reading\n"
399" it from hardware (only available to root) *\n"
400msgstr ""
401" -w, --hwfreq Findet die momentane CPU-Taktfrequenz heraus\n"
402" (verifiziert durch Nachfrage bei der Hardware)\n"
403" [nur der Administrator kann dies tun] *\n"
404
405#: utils/cpufreq-info.c:479
406#, c-format
407msgid ""
408" -l, --hwlimits Determine the minimum and maximum CPU frequency "
409"allowed *\n"
410msgstr ""
411" -l, --hwlimits Findet die minimale und maximale Taktfrequenz heraus "
412"*\n"
413
414#: utils/cpufreq-info.c:480
415#, c-format
416msgid " -d, --driver Determines the used cpufreq kernel driver *\n"
417msgstr " -d, --driver Findet den momentanen Treiber heraus *\n"
418
419#: utils/cpufreq-info.c:481
420#, c-format
421msgid " -p, --policy Gets the currently used cpufreq policy *\n"
422msgstr " -p, --policy Findet die momentane Taktik heraus *\n"
423
424#: utils/cpufreq-info.c:482
425#, c-format
426msgid " -g, --governors Determines available cpufreq governors *\n"
427msgstr " -g, --governors Erzeugt eine Liste mit verfügbaren Reglern *\n"
428
429#: utils/cpufreq-info.c:483
430#, c-format
431msgid ""
432" -r, --related-cpus Determines which CPUs run at the same hardware "
433"frequency *\n"
434msgstr ""
435" -r, --related-cpus Findet heraus, welche CPUs mit derselben "
436"physikalischen\n"
437" Taktfrequenz laufen *\n"
438
439#: utils/cpufreq-info.c:484
440#, c-format
441msgid ""
442" -a, --affected-cpus Determines which CPUs need to have their frequency\n"
443" coordinated by software *\n"
444msgstr ""
445" -a, --affected-cpus Findet heraus, von welchen CPUs die Taktfrequenz "
446"durch\n"
447" Software koordiniert werden muss *\n"
448
449#: utils/cpufreq-info.c:486
450#, c-format
451msgid " -s, --stats Shows cpufreq statistics if available\n"
452msgstr ""
453" -s, --stats Zeigt, sofern möglich, Statistiken über cpufreq an.\n"
454
455#: utils/cpufreq-info.c:487
456#, c-format
457msgid ""
458" -y, --latency Determines the maximum latency on CPU frequency "
459"changes *\n"
460msgstr ""
461" -y, --latency Findet die maximale Dauer eines Taktfrequenzwechsels "
462"heraus *\n"
463
464#: utils/cpufreq-info.c:488
465#, c-format
466msgid " -b, --boost Checks for turbo or boost modes *\n"
467msgstr ""
468
469#: utils/cpufreq-info.c:489
470#, c-format
471msgid ""
472" -o, --proc Prints out information like provided by the /proc/"
473"cpufreq\n"
474" interface in 2.4. and early 2.6. kernels\n"
475msgstr ""
476" -o, --proc Erzeugt Informationen in einem ähnlichem Format zu "
477"dem\n"
478" der /proc/cpufreq-Datei in 2.4. und frühen 2.6.\n"
479" Kernel-Versionen\n"
480
481#: utils/cpufreq-info.c:491
482#, c-format
483msgid ""
484" -m, --human human-readable output for the -f, -w, -s and -y "
485"parameters\n"
486msgstr ""
487" -m, --human Formatiert Taktfrequenz- und Zeitdauerangaben in "
488"besser\n"
489" lesbarer Form (MHz, GHz; us, ms)\n"
490
491#: utils/cpufreq-info.c:492 utils/cpuidle-info.c:152
492#, c-format
493msgid " -h, --help Prints out this screen\n"
494msgstr " -h, --help Gibt diese Kurzübersicht aus\n"
495
496#: utils/cpufreq-info.c:495
497#, c-format
498msgid ""
499"If no argument or only the -c, --cpu parameter is given, debug output about\n"
500"cpufreq is printed which is useful e.g. for reporting bugs.\n"
501msgstr ""
502"Sofern kein anderer Parameter als '-c, --cpu' angegeben wird, liefert "
503"dieses\n"
504"Programm Informationen, die z.B. zum Berichten von Fehlern nützlich sind.\n"
505
506#: utils/cpufreq-info.c:497
507#, c-format
508msgid ""
509"For the arguments marked with *, omitting the -c or --cpu argument is\n"
510"equivalent to setting it to zero\n"
511msgstr ""
512"Bei den mit * markierten Parametern wird '--cpu 0' angenommen, soweit nicht\n"
513"mittels -c oder --cpu etwas anderes angegeben wird\n"
514
515#: utils/cpufreq-info.c:580
516#, c-format
517msgid ""
518"The argument passed to this tool can't be combined with passing a --cpu "
519"argument\n"
520msgstr "Diese Option kann nicht mit der --cpu-Option kombiniert werden\n"
521
522#: utils/cpufreq-info.c:596
523#, c-format
524msgid ""
525"You can't specify more than one --cpu parameter and/or\n"
526"more than one output-specific argument\n"
527msgstr ""
528"Man kann nicht mehr als einen --cpu-Parameter und/oder mehr als einen\n"
529"informationsspezifischen Parameter gleichzeitig angeben\n"
530
531#: utils/cpufreq-info.c:600 utils/cpufreq-set.c:82 utils/cpupower-set.c:42
532#: utils/cpupower-info.c:42 utils/cpuidle-info.c:213
533#, c-format
534msgid "invalid or unknown argument\n"
535msgstr "unbekannter oder falscher Parameter\n"
536
537#: utils/cpufreq-info.c:617
538#, c-format
539msgid "couldn't analyze CPU %d as it doesn't seem to be present\n"
540msgstr ""
541"Konnte nicht die CPU %d analysieren, da sie (scheinbar?) nicht existiert.\n"
542
543#: utils/cpufreq-info.c:620 utils/cpupower-info.c:142
544#, c-format
545msgid "analyzing CPU %d:\n"
546msgstr "analysiere CPU %d:\n"
547
548#: utils/cpufreq-set.c:25
549#, fuzzy, c-format
550msgid "Usage: cpupower frequency-set [options]\n"
551msgstr "Aufruf: cpufreq-set [Optionen]\n"
552
553#: utils/cpufreq-set.c:27
554#, c-format
555msgid ""
556" -d FREQ, --min FREQ new minimum CPU frequency the governor may "
557"select\n"
558msgstr ""
559" -d FREQ, --min FREQ neue minimale Taktfrequenz, die der Regler\n"
560" auswählen darf\n"
561
562#: utils/cpufreq-set.c:28
563#, c-format
564msgid ""
565" -u FREQ, --max FREQ new maximum CPU frequency the governor may "
566"select\n"
567msgstr ""
568" -u FREQ, --max FREQ neue maximale Taktfrequenz, die der Regler\n"
569" auswählen darf\n"
570
571#: utils/cpufreq-set.c:29
572#, c-format
573msgid " -g GOV, --governor GOV new cpufreq governor\n"
574msgstr " -g GOV, --governors GOV wechsle zu Regler GOV\n"
575
576#: utils/cpufreq-set.c:30
577#, c-format
578msgid ""
579" -f FREQ, --freq FREQ specific frequency to be set. Requires userspace\n"
580" governor to be available and loaded\n"
581msgstr ""
582" -f FREQ, --freq FREQ setze exakte Taktfrequenz. Benötigt den Regler\n"
583" 'userspace'.\n"
584
585#: utils/cpufreq-set.c:32
586#, c-format
587msgid " -r, --related Switches all hardware-related CPUs\n"
588msgstr ""
589" -r, --related Setze Werte für alle CPUs, deren Taktfrequenz\n"
590" hardwarebedingt identisch ist.\n"
591
592#: utils/cpufreq-set.c:33 utils/cpupower-set.c:28 utils/cpupower-info.c:27
593#, c-format
594msgid " -h, --help Prints out this screen\n"
595msgstr " -h, --help Gibt diese Kurzübersicht aus\n"
596
597#: utils/cpufreq-set.c:35
598#, fuzzy, c-format
599msgid ""
600"Notes:\n"
601"1. Omitting the -c or --cpu argument is equivalent to setting it to \"all\"\n"
602msgstr ""
603"Bei den mit * markierten Parametern wird '--cpu 0' angenommen, soweit nicht\n"
604"mittels -c oder --cpu etwas anderes angegeben wird\n"
605
606#: utils/cpufreq-set.c:37
607#, fuzzy, c-format
608msgid ""
609"2. The -f FREQ, --freq FREQ parameter cannot be combined with any other "
610"parameter\n"
611" except the -c CPU, --cpu CPU parameter\n"
612"3. FREQuencies can be passed in Hz, kHz (default), MHz, GHz, or THz\n"
613" by postfixing the value with the wanted unit name, without any space\n"
614" (FREQuency in kHz =^ Hz * 0.001 =^ MHz * 1000 =^ GHz * 1000000).\n"
615msgstr ""
616"Hinweise:\n"
617"1. Sofern kein -c oder --cpu-Parameter angegeben ist, wird '--cpu 0'\n"
618" angenommen\n"
619"2. Der Parameter -f bzw. --freq kann mit keinem anderen als dem Parameter\n"
620" -c bzw. --cpu kombiniert werden\n"
621"3. FREQuenzen können in Hz, kHz (Standard), MHz, GHz oder THz eingegeben\n"
622" werden, indem der Wert und unmittelbar anschließend (ohne Leerzeichen!)\n"
623" die Einheit angegeben werden. (Bsp: 1GHz )\n"
624" (FREQuenz in kHz =^ MHz * 1000 =^ GHz * 1000000).\n"
625
626#: utils/cpufreq-set.c:57
627#, c-format
628msgid ""
629"Error setting new values. Common errors:\n"
630"- Do you have proper administration rights? (super-user?)\n"
631"- Is the governor you requested available and modprobed?\n"
632"- Trying to set an invalid policy?\n"
633"- Trying to set a specific frequency, but userspace governor is not "
634"available,\n"
635" for example because of hardware which cannot be set to a specific "
636"frequency\n"
637" or because the userspace governor isn't loaded?\n"
638msgstr ""
639"Beim Einstellen ist ein Fehler aufgetreten. Typische Fehlerquellen sind:\n"
640"- nicht ausreichende Rechte (Administrator)\n"
641"- der Regler ist nicht verfügbar bzw. nicht geladen\n"
642"- die angegebene Taktik ist inkorrekt\n"
643"- eine spezifische Frequenz wurde angegeben, aber der Regler 'userspace'\n"
644" kann entweder hardwarebedingt nicht genutzt werden oder ist nicht geladen\n"
645
646#: utils/cpufreq-set.c:170
647#, c-format
648msgid "wrong, unknown or unhandled CPU?\n"
649msgstr "unbekannte oder nicht regelbare CPU\n"
650
651#: utils/cpufreq-set.c:302
652#, c-format
653msgid ""
654"the -f/--freq parameter cannot be combined with -d/--min, -u/--max or\n"
655"-g/--governor parameters\n"
656msgstr ""
657"Der -f bzw. --freq-Parameter kann nicht mit den Parametern -d/--min, -u/--"
658"max\n"
659"oder -g/--governor kombiniert werden\n"
660
661#: utils/cpufreq-set.c:308
662#, c-format
663msgid ""
664"At least one parameter out of -f/--freq, -d/--min, -u/--max, and\n"
665"-g/--governor must be passed\n"
666msgstr ""
667"Es muss mindestens ein Parameter aus -f/--freq, -d/--min, -u/--max oder\n"
668"-g/--governor angegeben werden.\n"
669
670#: utils/cpufreq-set.c:347
671#, c-format
672msgid "Setting cpu: %d\n"
673msgstr ""
674
675#: utils/cpupower-set.c:22
676#, c-format
677msgid "Usage: cpupower set [ -b val ] [ -m val ] [ -s val ]\n"
678msgstr ""
679
680#: utils/cpupower-set.c:24
681#, c-format
682msgid ""
683" -b, --perf-bias [VAL] Sets CPU's power vs performance policy on some\n"
684" Intel models [0-15], see manpage for details\n"
685msgstr ""
686
687#: utils/cpupower-set.c:26
688#, c-format
689msgid ""
690" -m, --sched-mc [VAL] Sets the kernel's multi core scheduler policy.\n"
691msgstr ""
692
693#: utils/cpupower-set.c:27
694#, c-format
695msgid ""
696" -s, --sched-smt [VAL] Sets the kernel's thread sibling scheduler "
697"policy.\n"
698msgstr ""
699
700#: utils/cpupower-set.c:80
701#, c-format
702msgid "--perf-bias param out of range [0-%d]\n"
703msgstr ""
704
705#: utils/cpupower-set.c:91
706#, c-format
707msgid "--sched-mc param out of range [0-%d]\n"
708msgstr ""
709
710#: utils/cpupower-set.c:102
711#, c-format
712msgid "--sched-smt param out of range [0-%d]\n"
713msgstr ""
714
715#: utils/cpupower-set.c:121
716#, c-format
717msgid "Error setting sched-mc %s\n"
718msgstr ""
719
720#: utils/cpupower-set.c:127
721#, c-format
722msgid "Error setting sched-smt %s\n"
723msgstr ""
724
725#: utils/cpupower-set.c:146
726#, c-format
727msgid "Error setting perf-bias value on CPU %d\n"
728msgstr ""
729
730#: utils/cpupower-info.c:21
731#, c-format
732msgid "Usage: cpupower info [ -b ] [ -m ] [ -s ]\n"
733msgstr ""
734
735#: utils/cpupower-info.c:23
736#, c-format
737msgid ""
738" -b, --perf-bias Gets CPU's power vs performance policy on some\n"
739" Intel models [0-15], see manpage for details\n"
740msgstr ""
741
742#: utils/cpupower-info.c:25
743#, fuzzy, c-format
744msgid " -m, --sched-mc Gets the kernel's multi core scheduler policy.\n"
745msgstr " -p, --policy Findet die momentane Taktik heraus *\n"
746
747#: utils/cpupower-info.c:26
748#, c-format
749msgid ""
750" -s, --sched-smt Gets the kernel's thread sibling scheduler policy.\n"
751msgstr ""
752
753#: utils/cpupower-info.c:28
754#, c-format
755msgid ""
756"\n"
757"Passing no option will show all info, by default only on core 0\n"
758msgstr ""
759
760#: utils/cpupower-info.c:102
761#, c-format
762msgid "System's multi core scheduler setting: "
763msgstr ""
764
765#. if sysfs file is missing it's: errno == ENOENT
766#: utils/cpupower-info.c:105 utils/cpupower-info.c:114
767#, c-format
768msgid "not supported\n"
769msgstr ""
770
771#: utils/cpupower-info.c:111
772#, c-format
773msgid "System's thread sibling scheduler setting: "
774msgstr ""
775
776#: utils/cpupower-info.c:126
777#, c-format
778msgid "Intel's performance bias setting needs root privileges\n"
779msgstr ""
780
781#: utils/cpupower-info.c:128
782#, c-format
783msgid "System does not support Intel's performance bias setting\n"
784msgstr ""
785
786#: utils/cpupower-info.c:147
787#, c-format
788msgid "Could not read perf-bias value\n"
789msgstr ""
790
791#: utils/cpupower-info.c:150
792#, c-format
793msgid "perf-bias: %d\n"
794msgstr ""
795
796#: utils/cpuidle-info.c:28
797#, fuzzy, c-format
798msgid "Analyzing CPU %d:\n"
799msgstr "analysiere CPU %d:\n"
800
801#: utils/cpuidle-info.c:32
802#, c-format
803msgid "CPU %u: No idle states\n"
804msgstr ""
805
806#: utils/cpuidle-info.c:36
807#, c-format
808msgid "CPU %u: Can't read idle state info\n"
809msgstr ""
810
811#: utils/cpuidle-info.c:41
812#, c-format
813msgid "Could not determine max idle state %u\n"
814msgstr ""
815
816#: utils/cpuidle-info.c:46
817#, c-format
818msgid "Number of idle states: %d\n"
819msgstr ""
820
821#: utils/cpuidle-info.c:48
822#, fuzzy, c-format
823msgid "Available idle states:"
824msgstr " mögliche Taktfrequenzen: "
825
826#: utils/cpuidle-info.c:71
827#, c-format
828msgid "Flags/Description: %s\n"
829msgstr ""
830
831#: utils/cpuidle-info.c:74
832#, c-format
833msgid "Latency: %lu\n"
834msgstr ""
835
836#: utils/cpuidle-info.c:76
837#, c-format
838msgid "Usage: %lu\n"
839msgstr ""
840
841#: utils/cpuidle-info.c:78
842#, c-format
843msgid "Duration: %llu\n"
844msgstr ""
845
846#: utils/cpuidle-info.c:90
847#, c-format
848msgid "Could not determine cpuidle driver\n"
849msgstr ""
850
851#: utils/cpuidle-info.c:94
852#, fuzzy, c-format
853msgid "CPUidle driver: %s\n"
854msgstr " Treiber: %s\n"
855
856#: utils/cpuidle-info.c:99
857#, c-format
858msgid "Could not determine cpuidle governor\n"
859msgstr ""
860
861#: utils/cpuidle-info.c:103
862#, c-format
863msgid "CPUidle governor: %s\n"
864msgstr ""
865
866#: utils/cpuidle-info.c:122
867#, c-format
868msgid "CPU %u: Can't read C-state info\n"
869msgstr ""
870
871#. printf("Cstates: %d\n", cstates);
872#: utils/cpuidle-info.c:127
873#, c-format
874msgid "active state: C0\n"
875msgstr ""
876
877#: utils/cpuidle-info.c:128
878#, c-format
879msgid "max_cstate: C%u\n"
880msgstr ""
881
882#: utils/cpuidle-info.c:129
883#, fuzzy, c-format
884msgid "maximum allowed latency: %lu usec\n"
885msgstr " Maximale Dauer eines Taktfrequenzwechsels: "
886
887#: utils/cpuidle-info.c:130
888#, c-format
889msgid "states:\t\n"
890msgstr ""
891
892#: utils/cpuidle-info.c:132
893#, c-format
894msgid " C%d: type[C%d] "
895msgstr ""
896
897#: utils/cpuidle-info.c:134
898#, c-format
899msgid "promotion[--] demotion[--] "
900msgstr ""
901
902#: utils/cpuidle-info.c:135
903#, c-format
904msgid "latency[%03lu] "
905msgstr ""
906
907#: utils/cpuidle-info.c:137
908#, c-format
909msgid "usage[%08lu] "
910msgstr ""
911
912#: utils/cpuidle-info.c:139
913#, c-format
914msgid "duration[%020Lu] \n"
915msgstr ""
916
917#: utils/cpuidle-info.c:147
918#, fuzzy, c-format
919msgid "Usage: cpupower idleinfo [options]\n"
920msgstr "Aufruf: cpufreq-info [Optionen]\n"
921
922#: utils/cpuidle-info.c:149
923#, fuzzy, c-format
924msgid " -s, --silent Only show general C-state information\n"
925msgstr ""
926" -e, --debug Erzeugt detaillierte Informationen, hilfreich\n"
927" zum Aufspüren von Fehlern\n"
928
929#: utils/cpuidle-info.c:150
930#, fuzzy, c-format
931msgid ""
932" -o, --proc Prints out information like provided by the /proc/"
933"acpi/processor/*/power\n"
934" interface in older kernels\n"
935msgstr ""
936" -o, --proc Erzeugt Informationen in einem ähnlichem Format zu "
937"dem\n"
938" der /proc/cpufreq-Datei in 2.4. und frühen 2.6.\n"
939" Kernel-Versionen\n"
940
941#: utils/cpuidle-info.c:209
942#, fuzzy, c-format
943msgid "You can't specify more than one output-specific argument\n"
944msgstr ""
945"Man kann nicht mehr als einen --cpu-Parameter und/oder mehr als einen\n"
946"informationsspezifischen Parameter gleichzeitig angeben\n"
947
948#~ msgid ""
949#~ " -c CPU, --cpu CPU CPU number which information shall be determined "
950#~ "about\n"
951#~ msgstr ""
952#~ " -c CPU, --cpu CPU Nummer der CPU, über die Informationen "
953#~ "herausgefunden werden sollen\n"
954
955#~ msgid ""
956#~ " -c CPU, --cpu CPU number of CPU where cpufreq settings shall be "
957#~ "modified\n"
958#~ msgstr ""
959#~ " -c CPU, --cpu CPU Nummer der CPU, deren Taktfrequenz-"
960#~ "Einstellung\n"
961#~ " werden soll\n"
diff --git a/tools/power/cpupower/po/fr.po b/tools/power/cpupower/po/fr.po
new file mode 100644
index 00000000000..245ad20a9bf
--- /dev/null
+++ b/tools/power/cpupower/po/fr.po
@@ -0,0 +1,947 @@
1# French translations for cpufrequtils package
2# Copyright (C) 2004 THE PACKAGE'S COPYRIGHT HOLDER
3# This file is distributed under the same license as the cpufrequtils package.
4# Ducrot Bruno <ducrot@poupinou.org>, 2004.
5#
6#, fuzzy
7msgid ""
8msgstr ""
9"Project-Id-Version: cpufrequtils 0.1-pre2\n"
10"Report-Msgid-Bugs-To: \n"
11"POT-Creation-Date: 2011-03-08 17:03+0100\n"
12"PO-Revision-Date: 2004-11-17 15:53+1000\n"
13"Last-Translator: Bruno Ducrot <ducrot@poupinou.org>\n"
14"Language-Team: NONE\n"
15"Language: \n"
16"MIME-Version: 1.0\n"
17"Content-Type: text/plain; charset=ISO-8859-1\n"
18"Content-Transfer-Encoding: 8bit\n"
19
20#: utils/idle_monitor/nhm_idle.c:36
21msgid "Processor Core C3"
22msgstr ""
23
24#: utils/idle_monitor/nhm_idle.c:43
25msgid "Processor Core C6"
26msgstr ""
27
28#: utils/idle_monitor/nhm_idle.c:51
29msgid "Processor Package C3"
30msgstr ""
31
32#: utils/idle_monitor/nhm_idle.c:58 utils/idle_monitor/amd_fam14h_idle.c:70
33msgid "Processor Package C6"
34msgstr ""
35
36#: utils/idle_monitor/snb_idle.c:33
37msgid "Processor Core C7"
38msgstr ""
39
40#: utils/idle_monitor/snb_idle.c:40
41msgid "Processor Package C2"
42msgstr ""
43
44#: utils/idle_monitor/snb_idle.c:47
45msgid "Processor Package C7"
46msgstr ""
47
48#: utils/idle_monitor/amd_fam14h_idle.c:56
49msgid "Package in sleep state (PC1 or deeper)"
50msgstr ""
51
52#: utils/idle_monitor/amd_fam14h_idle.c:63
53msgid "Processor Package C1"
54msgstr ""
55
56#: utils/idle_monitor/amd_fam14h_idle.c:77
57msgid "North Bridge P1 boolean counter (returns 0 or 1)"
58msgstr ""
59
60#: utils/idle_monitor/mperf_monitor.c:35
61msgid "Processor Core not idle"
62msgstr ""
63
64#: utils/idle_monitor/mperf_monitor.c:42
65msgid "Processor Core in an idle state"
66msgstr ""
67
68#: utils/idle_monitor/mperf_monitor.c:50
69msgid "Average Frequency (including boost) in MHz"
70msgstr ""
71
72#: utils/idle_monitor/cpupower-monitor.c:66
73#, c-format
74msgid ""
75"cpupower monitor: [-h] [ [-t] | [-l] | [-m <mon1>,[<mon2>] ] ] [-i "
76"interval_sec | -c command ...]\n"
77msgstr ""
78
79#: utils/idle_monitor/cpupower-monitor.c:69
80#, c-format
81msgid ""
82"cpupower monitor: [-v] [-h] [ [-t] | [-l] | [-m <mon1>,[<mon2>] ] ] [-i "
83"interval_sec | -c command ...]\n"
84msgstr ""
85
86#: utils/idle_monitor/cpupower-monitor.c:71
87#, c-format
88msgid "\t -v: be more verbose\n"
89msgstr ""
90
91#: utils/idle_monitor/cpupower-monitor.c:73
92#, c-format
93msgid "\t -h: print this help\n"
94msgstr ""
95
96#: utils/idle_monitor/cpupower-monitor.c:74
97#, c-format
98msgid "\t -i: time intervall to measure for in seconds (default 1)\n"
99msgstr ""
100
101#: utils/idle_monitor/cpupower-monitor.c:75
102#, c-format
103msgid "\t -t: show CPU topology/hierarchy\n"
104msgstr ""
105
106#: utils/idle_monitor/cpupower-monitor.c:76
107#, c-format
108msgid "\t -l: list available CPU sleep monitors (for use with -m)\n"
109msgstr ""
110
111#: utils/idle_monitor/cpupower-monitor.c:77
112#, c-format
113msgid "\t -m: show specific CPU sleep monitors only (in same order)\n"
114msgstr ""
115
116#: utils/idle_monitor/cpupower-monitor.c:79
117#, c-format
118msgid ""
119"only one of: -t, -l, -m are allowed\n"
120"If none of them is passed,"
121msgstr ""
122
123#: utils/idle_monitor/cpupower-monitor.c:80
124#, c-format
125msgid " all supported monitors are shown\n"
126msgstr ""
127
128#: utils/idle_monitor/cpupower-monitor.c:197
129#, c-format
130msgid "Monitor %s, Counter %s has no count function. Implementation error\n"
131msgstr ""
132
133#: utils/idle_monitor/cpupower-monitor.c:207
134#, c-format
135msgid " *is offline\n"
136msgstr ""
137
138#: utils/idle_monitor/cpupower-monitor.c:236
139#, c-format
140msgid "%s: max monitor name length (%d) exceeded\n"
141msgstr ""
142
143#: utils/idle_monitor/cpupower-monitor.c:250
144#, c-format
145msgid "No matching monitor found in %s, try -l option\n"
146msgstr ""
147
148#: utils/idle_monitor/cpupower-monitor.c:266
149#, c-format
150msgid "Monitor \"%s\" (%d states) - Might overflow after %u s\n"
151msgstr ""
152
153#: utils/idle_monitor/cpupower-monitor.c:319
154#, c-format
155msgid "%s took %.5f seconds and exited with status %d\n"
156msgstr ""
157
158#: utils/idle_monitor/cpupower-monitor.c:406
159#, c-format
160msgid "Cannot read number of available processors\n"
161msgstr ""
162
163#: utils/idle_monitor/cpupower-monitor.c:417
164#, c-format
165msgid "Available monitor %s needs root access\n"
166msgstr ""
167
168#: utils/idle_monitor/cpupower-monitor.c:428
169#, c-format
170msgid "No HW Cstate monitors found\n"
171msgstr ""
172
173#: utils/cpupower.c:78
174#, c-format
175msgid "cpupower [ -c cpulist ] subcommand [ARGS]\n"
176msgstr ""
177
178#: utils/cpupower.c:79
179#, c-format
180msgid "cpupower --version\n"
181msgstr ""
182
183#: utils/cpupower.c:80
184#, c-format
185msgid "Supported subcommands are:\n"
186msgstr ""
187
188#: utils/cpupower.c:83
189#, c-format
190msgid ""
191"\n"
192"Some subcommands can make use of the -c cpulist option.\n"
193msgstr ""
194
195#: utils/cpupower.c:84
196#, c-format
197msgid "Look at the general cpupower manpage how to use it\n"
198msgstr ""
199
200#: utils/cpupower.c:85
201#, c-format
202msgid "and read up the subcommand's manpage whether it is supported.\n"
203msgstr ""
204
205#: utils/cpupower.c:86
206#, c-format
207msgid ""
208"\n"
209"Use cpupower help subcommand for getting help for above subcommands.\n"
210msgstr ""
211
212#: utils/cpupower.c:91
213#, c-format
214msgid "Report errors and bugs to %s, please.\n"
215msgstr "Veuillez rapportez les erreurs et les bogues à %s, s'il vous plait.\n"
216
217#: utils/cpupower.c:114
218#, c-format
219msgid "Error parsing cpu list\n"
220msgstr ""
221
222#: utils/cpupower.c:172
223#, c-format
224msgid "Subcommand %s needs root privileges\n"
225msgstr ""
226
227#: utils/cpufreq-info.c:31
228#, c-format
229msgid "Couldn't count the number of CPUs (%s: %s), assuming 1\n"
230msgstr "Détermination du nombre de CPUs (%s : %s) impossible. Assume 1\n"
231
232#: utils/cpufreq-info.c:63
233#, c-format
234msgid ""
235" minimum CPU frequency - maximum CPU frequency - governor\n"
236msgstr ""
237" Fréquence CPU minimale - Fréquence CPU maximale - régulateur\n"
238
239#: utils/cpufreq-info.c:151
240#, c-format
241msgid "Error while evaluating Boost Capabilities on CPU %d -- are you root?\n"
242msgstr ""
243
244#. P state changes via MSR are identified via cpuid 80000007
245#. on Intel and AMD, but we assume boost capable machines can do that
246#. if (cpuid_eax(0x80000000) >= 0x80000007
247#. && (cpuid_edx(0x80000007) & (1 << 7)))
248#.
249#: utils/cpufreq-info.c:161
250#, c-format
251msgid " boost state support: \n"
252msgstr ""
253
254#: utils/cpufreq-info.c:163
255#, c-format
256msgid " Supported: %s\n"
257msgstr ""
258
259#: utils/cpufreq-info.c:163 utils/cpufreq-info.c:164
260msgid "yes"
261msgstr ""
262
263#: utils/cpufreq-info.c:163 utils/cpufreq-info.c:164
264msgid "no"
265msgstr ""
266
267#: utils/cpufreq-info.c:164
268#, fuzzy, c-format
269msgid " Active: %s\n"
270msgstr " pilote : %s\n"
271
272#: utils/cpufreq-info.c:177
273#, c-format
274msgid " Boost States: %d\n"
275msgstr ""
276
277#: utils/cpufreq-info.c:178
278#, c-format
279msgid " Total States: %d\n"
280msgstr ""
281
282#: utils/cpufreq-info.c:181
283#, c-format
284msgid " Pstate-Pb%d: %luMHz (boost state)\n"
285msgstr ""
286
287#: utils/cpufreq-info.c:184
288#, c-format
289msgid " Pstate-P%d: %luMHz\n"
290msgstr ""
291
292#: utils/cpufreq-info.c:211
293#, c-format
294msgid " no or unknown cpufreq driver is active on this CPU\n"
295msgstr " pas de pilotes cpufreq reconnu pour ce CPU\n"
296
297#: utils/cpufreq-info.c:213
298#, c-format
299msgid " driver: %s\n"
300msgstr " pilote : %s\n"
301
302#: utils/cpufreq-info.c:219
303#, fuzzy, c-format
304msgid " CPUs which run at the same hardware frequency: "
305msgstr " CPUs qui doivent changer de fréquences en même temps : "
306
307#: utils/cpufreq-info.c:230
308#, fuzzy, c-format
309msgid " CPUs which need to have their frequency coordinated by software: "
310msgstr " CPUs qui doivent changer de fréquences en même temps : "
311
312#: utils/cpufreq-info.c:241
313#, c-format
314msgid " maximum transition latency: "
315msgstr ""
316
317#: utils/cpufreq-info.c:247
318#, c-format
319msgid " hardware limits: "
320msgstr " limitation matérielle : "
321
322#: utils/cpufreq-info.c:256
323#, c-format
324msgid " available frequency steps: "
325msgstr " plage de fréquence : "
326
327#: utils/cpufreq-info.c:269
328#, c-format
329msgid " available cpufreq governors: "
330msgstr " régulateurs disponibles : "
331
332#: utils/cpufreq-info.c:280
333#, c-format
334msgid " current policy: frequency should be within "
335msgstr " tactique actuelle : la fréquence doit être comprise entre "
336
337#: utils/cpufreq-info.c:282
338#, c-format
339msgid " and "
340msgstr " et "
341
342#: utils/cpufreq-info.c:286
343#, c-format
344msgid ""
345"The governor \"%s\" may decide which speed to use\n"
346" within this range.\n"
347msgstr ""
348"Le régulateur \"%s\" est libre de choisir la vitesse\n"
349" dans cette plage de fréquences.\n"
350
351#: utils/cpufreq-info.c:293
352#, c-format
353msgid " current CPU frequency is "
354msgstr " la fréquence actuelle de ce CPU est "
355
356#: utils/cpufreq-info.c:296
357#, c-format
358msgid " (asserted by call to hardware)"
359msgstr " (vérifié par un appel direct du matériel)"
360
361#: utils/cpufreq-info.c:304
362#, c-format
363msgid " cpufreq stats: "
364msgstr " des statistique concernant cpufreq:"
365
366#: utils/cpufreq-info.c:472
367#, fuzzy, c-format
368msgid "Usage: cpupower freqinfo [options]\n"
369msgstr "Usage : cpufreq-info [options]\n"
370
371#: utils/cpufreq-info.c:473 utils/cpufreq-set.c:26 utils/cpupower-set.c:23
372#: utils/cpupower-info.c:22 utils/cpuidle-info.c:148
373#, c-format
374msgid "Options:\n"
375msgstr "Options :\n"
376
377#: utils/cpufreq-info.c:474
378#, fuzzy, c-format
379msgid " -e, --debug Prints out debug information [default]\n"
380msgstr " -e, --debug Afficher les informations de déboguage\n"
381
382#: utils/cpufreq-info.c:475
383#, c-format
384msgid ""
385" -f, --freq Get frequency the CPU currently runs at, according\n"
386" to the cpufreq core *\n"
387msgstr ""
388" -f, --freq Obtenir la fréquence actuelle du CPU selon le point\n"
389" de vue du coeur du système de cpufreq *\n"
390
391#: utils/cpufreq-info.c:477
392#, c-format
393msgid ""
394" -w, --hwfreq Get frequency the CPU currently runs at, by reading\n"
395" it from hardware (only available to root) *\n"
396msgstr ""
397" -w, --hwfreq Obtenir la fréquence actuelle du CPU directement par\n"
398" le matériel (doit être root) *\n"
399
400#: utils/cpufreq-info.c:479
401#, c-format
402msgid ""
403" -l, --hwlimits Determine the minimum and maximum CPU frequency "
404"allowed *\n"
405msgstr ""
406" -l, --hwlimits Affiche les fréquences minimales et maximales du CPU "
407"*\n"
408
409#: utils/cpufreq-info.c:480
410#, c-format
411msgid " -d, --driver Determines the used cpufreq kernel driver *\n"
412msgstr " -d, --driver Affiche le pilote cpufreq utilisé *\n"
413
414#: utils/cpufreq-info.c:481
415#, c-format
416msgid " -p, --policy Gets the currently used cpufreq policy *\n"
417msgstr " -p, --policy Affiche la tactique actuelle de cpufreq *\n"
418
419#: utils/cpufreq-info.c:482
420#, c-format
421msgid " -g, --governors Determines available cpufreq governors *\n"
422msgstr ""
423" -g, --governors Affiche les régulateurs disponibles de cpufreq *\n"
424
425#: utils/cpufreq-info.c:483
426#, fuzzy, c-format
427msgid ""
428" -r, --related-cpus Determines which CPUs run at the same hardware "
429"frequency *\n"
430msgstr ""
431" -a, --affected-cpus Affiche quels sont les CPUs qui doivent changer de\n"
432" fréquences en même temps *\n"
433
434#: utils/cpufreq-info.c:484
435#, fuzzy, c-format
436msgid ""
437" -a, --affected-cpus Determines which CPUs need to have their frequency\n"
438" coordinated by software *\n"
439msgstr ""
440" -a, --affected-cpus Affiche quels sont les CPUs qui doivent changer de\n"
441" fréquences en même temps *\n"
442
443#: utils/cpufreq-info.c:486
444#, c-format
445msgid " -s, --stats Shows cpufreq statistics if available\n"
446msgstr ""
447" -s, --stats Indique des statistiques concernant cpufreq, si\n"
448" disponibles\n"
449
450#: utils/cpufreq-info.c:487
451#, fuzzy, c-format
452msgid ""
453" -y, --latency Determines the maximum latency on CPU frequency "
454"changes *\n"
455msgstr ""
456" -l, --hwlimits Affiche les fréquences minimales et maximales du CPU "
457"*\n"
458
459#: utils/cpufreq-info.c:488
460#, c-format
461msgid " -b, --boost Checks for turbo or boost modes *\n"
462msgstr ""
463
464#: utils/cpufreq-info.c:489
465#, c-format
466msgid ""
467" -o, --proc Prints out information like provided by the /proc/"
468"cpufreq\n"
469" interface in 2.4. and early 2.6. kernels\n"
470msgstr ""
471" -o, --proc Affiche les informations en utilisant l'interface\n"
472" fournie par /proc/cpufreq, présente dans les "
473"versions\n"
474" 2.4 et les anciennes versions 2.6 du noyau\n"
475
476#: utils/cpufreq-info.c:491
477#, fuzzy, c-format
478msgid ""
479" -m, --human human-readable output for the -f, -w, -s and -y "
480"parameters\n"
481msgstr ""
482" -m, --human affiche dans un format lisible pour un humain\n"
483" pour les options -f, -w et -s (MHz, GHz)\n"
484
485#: utils/cpufreq-info.c:492 utils/cpuidle-info.c:152
486#, c-format
487msgid " -h, --help Prints out this screen\n"
488msgstr " -h, --help affiche l'aide-mémoire\n"
489
490#: utils/cpufreq-info.c:495
491#, c-format
492msgid ""
493"If no argument or only the -c, --cpu parameter is given, debug output about\n"
494"cpufreq is printed which is useful e.g. for reporting bugs.\n"
495msgstr ""
496"Par défaut, les informations de déboguage seront affichées si aucun\n"
497"argument, ou bien si seulement l'argument -c (--cpu) est donné, afin de\n"
498"faciliter les rapports de bogues par exemple\n"
499
500#: utils/cpufreq-info.c:497
501#, c-format
502msgid ""
503"For the arguments marked with *, omitting the -c or --cpu argument is\n"
504"equivalent to setting it to zero\n"
505msgstr "Les arguments avec un * utiliseront le CPU 0 si -c (--cpu) est omis\n"
506
507#: utils/cpufreq-info.c:580
508#, c-format
509msgid ""
510"The argument passed to this tool can't be combined with passing a --cpu "
511"argument\n"
512msgstr "Cette option est incompatible avec --cpu\n"
513
514#: utils/cpufreq-info.c:596
515#, c-format
516msgid ""
517"You can't specify more than one --cpu parameter and/or\n"
518"more than one output-specific argument\n"
519msgstr ""
520"On ne peut indiquer plus d'un paramètre --cpu, tout comme l'on ne peut\n"
521"spécifier plus d'un argument de formatage\n"
522
523#: utils/cpufreq-info.c:600 utils/cpufreq-set.c:82 utils/cpupower-set.c:42
524#: utils/cpupower-info.c:42 utils/cpuidle-info.c:213
525#, c-format
526msgid "invalid or unknown argument\n"
527msgstr "option invalide\n"
528
529#: utils/cpufreq-info.c:617
530#, c-format
531msgid "couldn't analyze CPU %d as it doesn't seem to be present\n"
532msgstr "analyse du CPU %d impossible puisqu'il ne semble pas être présent\n"
533
534#: utils/cpufreq-info.c:620 utils/cpupower-info.c:142
535#, c-format
536msgid "analyzing CPU %d:\n"
537msgstr "analyse du CPU %d :\n"
538
539#: utils/cpufreq-set.c:25
540#, fuzzy, c-format
541msgid "Usage: cpupower frequency-set [options]\n"
542msgstr "Usage : cpufreq-set [options]\n"
543
544#: utils/cpufreq-set.c:27
545#, c-format
546msgid ""
547" -d FREQ, --min FREQ new minimum CPU frequency the governor may "
548"select\n"
549msgstr ""
550" -d FREQ, --min FREQ nouvelle fréquence minimale du CPU à utiliser\n"
551" par le régulateur\n"
552
553#: utils/cpufreq-set.c:28
554#, c-format
555msgid ""
556" -u FREQ, --max FREQ new maximum CPU frequency the governor may "
557"select\n"
558msgstr ""
559" -u FREQ, --max FREQ nouvelle fréquence maximale du CPU à utiliser\n"
560" par le régulateur\n"
561
562#: utils/cpufreq-set.c:29
563#, c-format
564msgid " -g GOV, --governor GOV new cpufreq governor\n"
565msgstr " -g GOV, --governor GOV active le régulateur GOV\n"
566
567#: utils/cpufreq-set.c:30
568#, c-format
569msgid ""
570" -f FREQ, --freq FREQ specific frequency to be set. Requires userspace\n"
571" governor to be available and loaded\n"
572msgstr ""
573" -f FREQ, --freq FREQ fixe la fréquence du processeur à FREQ. Il faut\n"
574" que le régulateur « userspace » soit disponible \n"
575" et activé.\n"
576
577#: utils/cpufreq-set.c:32
578#, c-format
579msgid " -r, --related Switches all hardware-related CPUs\n"
580msgstr ""
581
582#: utils/cpufreq-set.c:33 utils/cpupower-set.c:28 utils/cpupower-info.c:27
583#, fuzzy, c-format
584msgid " -h, --help Prints out this screen\n"
585msgstr " -h, --help affiche l'aide-mémoire\n"
586
587#: utils/cpufreq-set.c:35
588#, fuzzy, c-format
589msgid ""
590"Notes:\n"
591"1. Omitting the -c or --cpu argument is equivalent to setting it to \"all\"\n"
592msgstr "Les arguments avec un * utiliseront le CPU 0 si -c (--cpu) est omis\n"
593
594#: utils/cpufreq-set.c:37
595#, fuzzy, c-format
596msgid ""
597"2. The -f FREQ, --freq FREQ parameter cannot be combined with any other "
598"parameter\n"
599" except the -c CPU, --cpu CPU parameter\n"
600"3. FREQuencies can be passed in Hz, kHz (default), MHz, GHz, or THz\n"
601" by postfixing the value with the wanted unit name, without any space\n"
602" (FREQuency in kHz =^ Hz * 0.001 =^ MHz * 1000 =^ GHz * 1000000).\n"
603msgstr ""
604"Remarque :\n"
605"1. Le CPU numéro 0 sera utilisé par défaut si -c (ou --cpu) est omis ;\n"
606"2. l'argument -f FREQ (ou --freq FREQ) ne peut être utilisé qu'avec --cpu ;\n"
607"3. on pourra préciser l'unité des fréquences en postfixant sans aucune "
608"espace\n"
609" les valeurs par hz, kHz (par défaut), MHz, GHz ou THz\n"
610" (kHz =^ Hz * 0.001 =^ MHz * 1000 =^ GHz * 1000000).\n"
611
612#: utils/cpufreq-set.c:57
613#, c-format
614msgid ""
615"Error setting new values. Common errors:\n"
616"- Do you have proper administration rights? (super-user?)\n"
617"- Is the governor you requested available and modprobed?\n"
618"- Trying to set an invalid policy?\n"
619"- Trying to set a specific frequency, but userspace governor is not "
620"available,\n"
621" for example because of hardware which cannot be set to a specific "
622"frequency\n"
623" or because the userspace governor isn't loaded?\n"
624msgstr ""
625"En ajustant les nouveaux paramètres, une erreur est apparue. Les sources\n"
626"d'erreur typique sont :\n"
627"- droit d'administration insuffisant (êtes-vous root ?) ;\n"
628"- le régulateur choisi n'est pas disponible, ou bien n'est pas disponible "
629"en\n"
630" tant que module noyau ;\n"
631"- la tactique n'est pas disponible ;\n"
632"- vous voulez utiliser l'option -f/--freq, mais le régulateur « userspace »\n"
633" n'est pas disponible, par exemple parce que le matériel ne le supporte\n"
634" pas, ou bien n'est tout simplement pas chargé.\n"
635
636#: utils/cpufreq-set.c:170
637#, c-format
638msgid "wrong, unknown or unhandled CPU?\n"
639msgstr "CPU inconnu ou non supporté ?\n"
640
641#: utils/cpufreq-set.c:302
642#, c-format
643msgid ""
644"the -f/--freq parameter cannot be combined with -d/--min, -u/--max or\n"
645"-g/--governor parameters\n"
646msgstr ""
647"l'option -f/--freq est incompatible avec les options -d/--min, -u/--max et\n"
648"-g/--governor\n"
649
650#: utils/cpufreq-set.c:308
651#, c-format
652msgid ""
653"At least one parameter out of -f/--freq, -d/--min, -u/--max, and\n"
654"-g/--governor must be passed\n"
655msgstr ""
656"L'un de ces paramètres est obligatoire : -f/--freq, -d/--min, -u/--max et\n"
657"-g/--governor\n"
658
659#: utils/cpufreq-set.c:347
660#, c-format
661msgid "Setting cpu: %d\n"
662msgstr ""
663
664#: utils/cpupower-set.c:22
665#, c-format
666msgid "Usage: cpupower set [ -b val ] [ -m val ] [ -s val ]\n"
667msgstr ""
668
669#: utils/cpupower-set.c:24
670#, c-format
671msgid ""
672" -b, --perf-bias [VAL] Sets CPU's power vs performance policy on some\n"
673" Intel models [0-15], see manpage for details\n"
674msgstr ""
675
676#: utils/cpupower-set.c:26
677#, c-format
678msgid ""
679" -m, --sched-mc [VAL] Sets the kernel's multi core scheduler policy.\n"
680msgstr ""
681
682#: utils/cpupower-set.c:27
683#, c-format
684msgid ""
685" -s, --sched-smt [VAL] Sets the kernel's thread sibling scheduler "
686"policy.\n"
687msgstr ""
688
689#: utils/cpupower-set.c:80
690#, c-format
691msgid "--perf-bias param out of range [0-%d]\n"
692msgstr ""
693
694#: utils/cpupower-set.c:91
695#, c-format
696msgid "--sched-mc param out of range [0-%d]\n"
697msgstr ""
698
699#: utils/cpupower-set.c:102
700#, c-format
701msgid "--sched-smt param out of range [0-%d]\n"
702msgstr ""
703
704#: utils/cpupower-set.c:121
705#, c-format
706msgid "Error setting sched-mc %s\n"
707msgstr ""
708
709#: utils/cpupower-set.c:127
710#, c-format
711msgid "Error setting sched-smt %s\n"
712msgstr ""
713
714#: utils/cpupower-set.c:146
715#, c-format
716msgid "Error setting perf-bias value on CPU %d\n"
717msgstr ""
718
719#: utils/cpupower-info.c:21
720#, c-format
721msgid "Usage: cpupower info [ -b ] [ -m ] [ -s ]\n"
722msgstr ""
723
724#: utils/cpupower-info.c:23
725#, c-format
726msgid ""
727" -b, --perf-bias Gets CPU's power vs performance policy on some\n"
728" Intel models [0-15], see manpage for details\n"
729msgstr ""
730
731#: utils/cpupower-info.c:25
732#, fuzzy, c-format
733msgid " -m, --sched-mc Gets the kernel's multi core scheduler policy.\n"
734msgstr " -p, --policy Affiche la tactique actuelle de cpufreq *\n"
735
736#: utils/cpupower-info.c:26
737#, c-format
738msgid ""
739" -s, --sched-smt Gets the kernel's thread sibling scheduler policy.\n"
740msgstr ""
741
742#: utils/cpupower-info.c:28
743#, c-format
744msgid ""
745"\n"
746"Passing no option will show all info, by default only on core 0\n"
747msgstr ""
748
749#: utils/cpupower-info.c:102
750#, c-format
751msgid "System's multi core scheduler setting: "
752msgstr ""
753
754#. if sysfs file is missing it's: errno == ENOENT
755#: utils/cpupower-info.c:105 utils/cpupower-info.c:114
756#, c-format
757msgid "not supported\n"
758msgstr ""
759
760#: utils/cpupower-info.c:111
761#, c-format
762msgid "System's thread sibling scheduler setting: "
763msgstr ""
764
765#: utils/cpupower-info.c:126
766#, c-format
767msgid "Intel's performance bias setting needs root privileges\n"
768msgstr ""
769
770#: utils/cpupower-info.c:128
771#, c-format
772msgid "System does not support Intel's performance bias setting\n"
773msgstr ""
774
775#: utils/cpupower-info.c:147
776#, c-format
777msgid "Could not read perf-bias value\n"
778msgstr ""
779
780#: utils/cpupower-info.c:150
781#, c-format
782msgid "perf-bias: %d\n"
783msgstr ""
784
785#: utils/cpuidle-info.c:28
786#, fuzzy, c-format
787msgid "Analyzing CPU %d:\n"
788msgstr "analyse du CPU %d :\n"
789
790#: utils/cpuidle-info.c:32
791#, c-format
792msgid "CPU %u: No idle states\n"
793msgstr ""
794
795#: utils/cpuidle-info.c:36
796#, c-format
797msgid "CPU %u: Can't read idle state info\n"
798msgstr ""
799
800#: utils/cpuidle-info.c:41
801#, c-format
802msgid "Could not determine max idle state %u\n"
803msgstr ""
804
805#: utils/cpuidle-info.c:46
806#, c-format
807msgid "Number of idle states: %d\n"
808msgstr ""
809
810#: utils/cpuidle-info.c:48
811#, fuzzy, c-format
812msgid "Available idle states:"
813msgstr " plage de fréquence : "
814
815#: utils/cpuidle-info.c:71
816#, c-format
817msgid "Flags/Description: %s\n"
818msgstr ""
819
820#: utils/cpuidle-info.c:74
821#, c-format
822msgid "Latency: %lu\n"
823msgstr ""
824
825#: utils/cpuidle-info.c:76
826#, c-format
827msgid "Usage: %lu\n"
828msgstr ""
829
830#: utils/cpuidle-info.c:78
831#, c-format
832msgid "Duration: %llu\n"
833msgstr ""
834
835#: utils/cpuidle-info.c:90
836#, c-format
837msgid "Could not determine cpuidle driver\n"
838msgstr ""
839
840#: utils/cpuidle-info.c:94
841#, fuzzy, c-format
842msgid "CPUidle driver: %s\n"
843msgstr " pilote : %s\n"
844
845#: utils/cpuidle-info.c:99
846#, c-format
847msgid "Could not determine cpuidle governor\n"
848msgstr ""
849
850#: utils/cpuidle-info.c:103
851#, c-format
852msgid "CPUidle governor: %s\n"
853msgstr ""
854
855#: utils/cpuidle-info.c:122
856#, c-format
857msgid "CPU %u: Can't read C-state info\n"
858msgstr ""
859
860#. printf("Cstates: %d\n", cstates);
861#: utils/cpuidle-info.c:127
862#, c-format
863msgid "active state: C0\n"
864msgstr ""
865
866#: utils/cpuidle-info.c:128
867#, c-format
868msgid "max_cstate: C%u\n"
869msgstr ""
870
871#: utils/cpuidle-info.c:129
872#, c-format
873msgid "maximum allowed latency: %lu usec\n"
874msgstr ""
875
876#: utils/cpuidle-info.c:130
877#, c-format
878msgid "states:\t\n"
879msgstr ""
880
881#: utils/cpuidle-info.c:132
882#, c-format
883msgid " C%d: type[C%d] "
884msgstr ""
885
886#: utils/cpuidle-info.c:134
887#, c-format
888msgid "promotion[--] demotion[--] "
889msgstr ""
890
891#: utils/cpuidle-info.c:135
892#, c-format
893msgid "latency[%03lu] "
894msgstr ""
895
896#: utils/cpuidle-info.c:137
897#, c-format
898msgid "usage[%08lu] "
899msgstr ""
900
901#: utils/cpuidle-info.c:139
902#, c-format
903msgid "duration[%020Lu] \n"
904msgstr ""
905
906#: utils/cpuidle-info.c:147
907#, fuzzy, c-format
908msgid "Usage: cpupower idleinfo [options]\n"
909msgstr "Usage : cpufreq-info [options]\n"
910
911#: utils/cpuidle-info.c:149
912#, fuzzy, c-format
913msgid " -s, --silent Only show general C-state information\n"
914msgstr " -e, --debug Afficher les informations de déboguage\n"
915
916#: utils/cpuidle-info.c:150
917#, fuzzy, c-format
918msgid ""
919" -o, --proc Prints out information like provided by the /proc/"
920"acpi/processor/*/power\n"
921" interface in older kernels\n"
922msgstr ""
923" -o, --proc Affiche les informations en utilisant l'interface\n"
924" fournie par /proc/cpufreq, présente dans les "
925"versions\n"
926" 2.4 et les anciennes versions 2.6 du noyau\n"
927
928#: utils/cpuidle-info.c:209
929#, fuzzy, c-format
930msgid "You can't specify more than one output-specific argument\n"
931msgstr ""
932"On ne peut indiquer plus d'un paramètre --cpu, tout comme l'on ne peut\n"
933"spécifier plus d'un argument de formatage\n"
934
935#~ msgid ""
936#~ " -c CPU, --cpu CPU CPU number which information shall be determined "
937#~ "about\n"
938#~ msgstr ""
939#~ " -c CPU, --cpu CPU Numéro du CPU pour lequel l'information sera "
940#~ "affichée\n"
941
942#~ msgid ""
943#~ " -c CPU, --cpu CPU number of CPU where cpufreq settings shall be "
944#~ "modified\n"
945#~ msgstr ""
946#~ " -c CPU, --cpu CPU numéro du CPU à prendre en compte pour les\n"
947#~ " changements\n"
diff --git a/tools/power/cpupower/po/it.po b/tools/power/cpupower/po/it.po
new file mode 100644
index 00000000000..f80c4ddb9bd
--- /dev/null
+++ b/tools/power/cpupower/po/it.po
@@ -0,0 +1,961 @@
1# Italian translations for cpufrequtils package
2# Copyright (C) 2004-2009
3# This file is distributed under the same license as the cpufrequtils package.
4# Mattia Dongili <malattia@gmail.com>.
5#
6#
7msgid ""
8msgstr ""
9"Project-Id-Version: cpufrequtils 0.3\n"
10"Report-Msgid-Bugs-To: \n"
11"POT-Creation-Date: 2011-03-08 17:03+0100\n"
12"PO-Revision-Date: 2009-08-15 12:00+0900\n"
13"Last-Translator: Mattia Dongili <malattia@gmail.com>\n"
14"Language-Team: NONE\n"
15"Language: \n"
16"MIME-Version: 1.0\n"
17"Content-Type: text/plain; charset=UTF-8\n"
18"Content-Transfer-Encoding: 8bit\n"
19
20#: utils/idle_monitor/nhm_idle.c:36
21msgid "Processor Core C3"
22msgstr ""
23
24#: utils/idle_monitor/nhm_idle.c:43
25msgid "Processor Core C6"
26msgstr ""
27
28#: utils/idle_monitor/nhm_idle.c:51
29msgid "Processor Package C3"
30msgstr ""
31
32#: utils/idle_monitor/nhm_idle.c:58 utils/idle_monitor/amd_fam14h_idle.c:70
33msgid "Processor Package C6"
34msgstr ""
35
36#: utils/idle_monitor/snb_idle.c:33
37msgid "Processor Core C7"
38msgstr ""
39
40#: utils/idle_monitor/snb_idle.c:40
41msgid "Processor Package C2"
42msgstr ""
43
44#: utils/idle_monitor/snb_idle.c:47
45msgid "Processor Package C7"
46msgstr ""
47
48#: utils/idle_monitor/amd_fam14h_idle.c:56
49msgid "Package in sleep state (PC1 or deeper)"
50msgstr ""
51
52#: utils/idle_monitor/amd_fam14h_idle.c:63
53msgid "Processor Package C1"
54msgstr ""
55
56#: utils/idle_monitor/amd_fam14h_idle.c:77
57msgid "North Bridge P1 boolean counter (returns 0 or 1)"
58msgstr ""
59
60#: utils/idle_monitor/mperf_monitor.c:35
61msgid "Processor Core not idle"
62msgstr ""
63
64#: utils/idle_monitor/mperf_monitor.c:42
65msgid "Processor Core in an idle state"
66msgstr ""
67
68#: utils/idle_monitor/mperf_monitor.c:50
69msgid "Average Frequency (including boost) in MHz"
70msgstr ""
71
72#: utils/idle_monitor/cpupower-monitor.c:66
73#, c-format
74msgid ""
75"cpupower monitor: [-h] [ [-t] | [-l] | [-m <mon1>,[<mon2>] ] ] [-i "
76"interval_sec | -c command ...]\n"
77msgstr ""
78
79#: utils/idle_monitor/cpupower-monitor.c:69
80#, c-format
81msgid ""
82"cpupower monitor: [-v] [-h] [ [-t] | [-l] | [-m <mon1>,[<mon2>] ] ] [-i "
83"interval_sec | -c command ...]\n"
84msgstr ""
85
86#: utils/idle_monitor/cpupower-monitor.c:71
87#, c-format
88msgid "\t -v: be more verbose\n"
89msgstr ""
90
91#: utils/idle_monitor/cpupower-monitor.c:73
92#, c-format
93msgid "\t -h: print this help\n"
94msgstr ""
95
96#: utils/idle_monitor/cpupower-monitor.c:74
97#, c-format
98msgid "\t -i: time intervall to measure for in seconds (default 1)\n"
99msgstr ""
100
101#: utils/idle_monitor/cpupower-monitor.c:75
102#, c-format
103msgid "\t -t: show CPU topology/hierarchy\n"
104msgstr ""
105
106#: utils/idle_monitor/cpupower-monitor.c:76
107#, c-format
108msgid "\t -l: list available CPU sleep monitors (for use with -m)\n"
109msgstr ""
110
111#: utils/idle_monitor/cpupower-monitor.c:77
112#, c-format
113msgid "\t -m: show specific CPU sleep monitors only (in same order)\n"
114msgstr ""
115
116#: utils/idle_monitor/cpupower-monitor.c:79
117#, c-format
118msgid ""
119"only one of: -t, -l, -m are allowed\n"
120"If none of them is passed,"
121msgstr ""
122
123#: utils/idle_monitor/cpupower-monitor.c:80
124#, c-format
125msgid " all supported monitors are shown\n"
126msgstr ""
127
128#: utils/idle_monitor/cpupower-monitor.c:197
129#, c-format
130msgid "Monitor %s, Counter %s has no count function. Implementation error\n"
131msgstr ""
132
133#: utils/idle_monitor/cpupower-monitor.c:207
134#, c-format
135msgid " *is offline\n"
136msgstr ""
137
138#: utils/idle_monitor/cpupower-monitor.c:236
139#, c-format
140msgid "%s: max monitor name length (%d) exceeded\n"
141msgstr ""
142
143#: utils/idle_monitor/cpupower-monitor.c:250
144#, c-format
145msgid "No matching monitor found in %s, try -l option\n"
146msgstr ""
147
148#: utils/idle_monitor/cpupower-monitor.c:266
149#, c-format
150msgid "Monitor \"%s\" (%d states) - Might overflow after %u s\n"
151msgstr ""
152
153#: utils/idle_monitor/cpupower-monitor.c:319
154#, c-format
155msgid "%s took %.5f seconds and exited with status %d\n"
156msgstr ""
157
158#: utils/idle_monitor/cpupower-monitor.c:406
159#, c-format
160msgid "Cannot read number of available processors\n"
161msgstr ""
162
163#: utils/idle_monitor/cpupower-monitor.c:417
164#, c-format
165msgid "Available monitor %s needs root access\n"
166msgstr ""
167
168#: utils/idle_monitor/cpupower-monitor.c:428
169#, c-format
170msgid "No HW Cstate monitors found\n"
171msgstr ""
172
173#: utils/cpupower.c:78
174#, c-format
175msgid "cpupower [ -c cpulist ] subcommand [ARGS]\n"
176msgstr ""
177
178#: utils/cpupower.c:79
179#, c-format
180msgid "cpupower --version\n"
181msgstr ""
182
183#: utils/cpupower.c:80
184#, c-format
185msgid "Supported subcommands are:\n"
186msgstr ""
187
188#: utils/cpupower.c:83
189#, c-format
190msgid ""
191"\n"
192"Some subcommands can make use of the -c cpulist option.\n"
193msgstr ""
194
195#: utils/cpupower.c:84
196#, c-format
197msgid "Look at the general cpupower manpage how to use it\n"
198msgstr ""
199
200#: utils/cpupower.c:85
201#, c-format
202msgid "and read up the subcommand's manpage whether it is supported.\n"
203msgstr ""
204
205#: utils/cpupower.c:86
206#, c-format
207msgid ""
208"\n"
209"Use cpupower help subcommand for getting help for above subcommands.\n"
210msgstr ""
211
212#: utils/cpupower.c:91
213#, c-format
214msgid "Report errors and bugs to %s, please.\n"
215msgstr "Per favore, comunicare errori e malfunzionamenti a %s.\n"
216
217#: utils/cpupower.c:114
218#, c-format
219msgid "Error parsing cpu list\n"
220msgstr ""
221
222#: utils/cpupower.c:172
223#, c-format
224msgid "Subcommand %s needs root privileges\n"
225msgstr ""
226
227#: utils/cpufreq-info.c:31
228#, c-format
229msgid "Couldn't count the number of CPUs (%s: %s), assuming 1\n"
230msgstr "Impossibile determinare il numero di CPU (%s: %s), assumo sia 1\n"
231
232#: utils/cpufreq-info.c:63
233#, c-format
234msgid ""
235" minimum CPU frequency - maximum CPU frequency - governor\n"
236msgstr ""
237" frequenza minima CPU - frequenza massima CPU - gestore\n"
238
239#: utils/cpufreq-info.c:151
240#, c-format
241msgid "Error while evaluating Boost Capabilities on CPU %d -- are you root?\n"
242msgstr ""
243
244#. P state changes via MSR are identified via cpuid 80000007
245#. on Intel and AMD, but we assume boost capable machines can do that
246#. if (cpuid_eax(0x80000000) >= 0x80000007
247#. && (cpuid_edx(0x80000007) & (1 << 7)))
248#.
249#: utils/cpufreq-info.c:161
250#, c-format
251msgid " boost state support: \n"
252msgstr ""
253
254#: utils/cpufreq-info.c:163
255#, c-format
256msgid " Supported: %s\n"
257msgstr ""
258
259#: utils/cpufreq-info.c:163 utils/cpufreq-info.c:164
260msgid "yes"
261msgstr ""
262
263#: utils/cpufreq-info.c:163 utils/cpufreq-info.c:164
264msgid "no"
265msgstr ""
266
267#: utils/cpufreq-info.c:164
268#, fuzzy, c-format
269msgid " Active: %s\n"
270msgstr " modulo %s\n"
271
272#: utils/cpufreq-info.c:177
273#, c-format
274msgid " Boost States: %d\n"
275msgstr ""
276
277#: utils/cpufreq-info.c:178
278#, c-format
279msgid " Total States: %d\n"
280msgstr ""
281
282#: utils/cpufreq-info.c:181
283#, c-format
284msgid " Pstate-Pb%d: %luMHz (boost state)\n"
285msgstr ""
286
287#: utils/cpufreq-info.c:184
288#, c-format
289msgid " Pstate-P%d: %luMHz\n"
290msgstr ""
291
292#: utils/cpufreq-info.c:211
293#, c-format
294msgid " no or unknown cpufreq driver is active on this CPU\n"
295msgstr " nessun modulo o modulo cpufreq sconosciuto per questa CPU\n"
296
297#: utils/cpufreq-info.c:213
298#, c-format
299msgid " driver: %s\n"
300msgstr " modulo %s\n"
301
302#: utils/cpufreq-info.c:219
303#, c-format
304msgid " CPUs which run at the same hardware frequency: "
305msgstr " CPU che operano alla stessa frequenza hardware: "
306
307#: utils/cpufreq-info.c:230
308#, c-format
309msgid " CPUs which need to have their frequency coordinated by software: "
310msgstr " CPU che è necessario siano coordinate dal software: "
311
312#: utils/cpufreq-info.c:241
313#, c-format
314msgid " maximum transition latency: "
315msgstr " latenza massima durante la transizione: "
316
317#: utils/cpufreq-info.c:247
318#, c-format
319msgid " hardware limits: "
320msgstr " limiti hardware: "
321
322#: utils/cpufreq-info.c:256
323#, c-format
324msgid " available frequency steps: "
325msgstr " frequenze disponibili: "
326
327#: utils/cpufreq-info.c:269
328#, c-format
329msgid " available cpufreq governors: "
330msgstr " gestori disponibili: "
331
332#: utils/cpufreq-info.c:280
333#, c-format
334msgid " current policy: frequency should be within "
335msgstr " gestore attuale: la frequenza deve mantenersi tra "
336
337#: utils/cpufreq-info.c:282
338#, c-format
339msgid " and "
340msgstr " e "
341
342#: utils/cpufreq-info.c:286
343#, c-format
344msgid ""
345"The governor \"%s\" may decide which speed to use\n"
346" within this range.\n"
347msgstr ""
348" Il gestore \"%s\" può decidere quale velocità usare\n"
349" in questo intervallo.\n"
350
351#: utils/cpufreq-info.c:293
352#, c-format
353msgid " current CPU frequency is "
354msgstr " la frequenza attuale della CPU è "
355
356#: utils/cpufreq-info.c:296
357#, c-format
358msgid " (asserted by call to hardware)"
359msgstr " (ottenuta da una chiamata diretta all'hardware)"
360
361#: utils/cpufreq-info.c:304
362#, c-format
363msgid " cpufreq stats: "
364msgstr " statistiche cpufreq:"
365
366#: utils/cpufreq-info.c:472
367#, fuzzy, c-format
368msgid "Usage: cpupower freqinfo [options]\n"
369msgstr "Uso: cpufreq-info [opzioni]\n"
370
371#: utils/cpufreq-info.c:473 utils/cpufreq-set.c:26 utils/cpupower-set.c:23
372#: utils/cpupower-info.c:22 utils/cpuidle-info.c:148
373#, c-format
374msgid "Options:\n"
375msgstr "Opzioni:\n"
376
377#: utils/cpufreq-info.c:474
378#, fuzzy, c-format
379msgid " -e, --debug Prints out debug information [default]\n"
380msgstr " -e, --debug Mostra informazioni di debug\n"
381
382#: utils/cpufreq-info.c:475
383#, c-format
384msgid ""
385" -f, --freq Get frequency the CPU currently runs at, according\n"
386" to the cpufreq core *\n"
387msgstr ""
388" -f, --freq Mostra la frequenza attuale della CPU secondo\n"
389" il modulo cpufreq *\n"
390
391#: utils/cpufreq-info.c:477
392#, c-format
393msgid ""
394" -w, --hwfreq Get frequency the CPU currently runs at, by reading\n"
395" it from hardware (only available to root) *\n"
396msgstr ""
397" -w, --hwfreq Mostra la frequenza attuale della CPU leggendola\n"
398" dall'hardware (disponibile solo per l'utente root) *\n"
399
400#: utils/cpufreq-info.c:479
401#, c-format
402msgid ""
403" -l, --hwlimits Determine the minimum and maximum CPU frequency "
404"allowed *\n"
405msgstr ""
406" -l, --hwlimits Determina le frequenze minima e massima possibili per "
407"la CPU *\n"
408
409#: utils/cpufreq-info.c:480
410#, c-format
411msgid " -d, --driver Determines the used cpufreq kernel driver *\n"
412msgstr ""
413" -d, --driver Determina il modulo cpufreq del kernel in uso *\n"
414
415#: utils/cpufreq-info.c:481
416#, c-format
417msgid " -p, --policy Gets the currently used cpufreq policy *\n"
418msgstr ""
419" -p, --policy Mostra il gestore cpufreq attualmente in uso *\n"
420
421#: utils/cpufreq-info.c:482
422#, c-format
423msgid " -g, --governors Determines available cpufreq governors *\n"
424msgstr " -g, --governors Determina i gestori cpufreq disponibili *\n"
425
426#: utils/cpufreq-info.c:483
427#, c-format
428msgid ""
429" -r, --related-cpus Determines which CPUs run at the same hardware "
430"frequency *\n"
431msgstr ""
432" -r, --related-cpus Determina quali CPU operano alla stessa frequenza *\n"
433
434#: utils/cpufreq-info.c:484
435#, c-format
436msgid ""
437" -a, --affected-cpus Determines which CPUs need to have their frequency\n"
438" coordinated by software *\n"
439msgstr ""
440" -a, --affected-cpus Determina quali CPU devono avere la frequenza\n"
441" coordinata dal software *\n"
442
443#: utils/cpufreq-info.c:486
444#, c-format
445msgid " -s, --stats Shows cpufreq statistics if available\n"
446msgstr " -s, --stats Mostra le statistiche se disponibili\n"
447
448#: utils/cpufreq-info.c:487
449#, c-format
450msgid ""
451" -y, --latency Determines the maximum latency on CPU frequency "
452"changes *\n"
453msgstr ""
454" -y, --latency Determina la latenza massima durante i cambi di "
455"frequenza *\n"
456
457#: utils/cpufreq-info.c:488
458#, c-format
459msgid " -b, --boost Checks for turbo or boost modes *\n"
460msgstr ""
461
462#: utils/cpufreq-info.c:489
463#, c-format
464msgid ""
465" -o, --proc Prints out information like provided by the /proc/"
466"cpufreq\n"
467" interface in 2.4. and early 2.6. kernels\n"
468msgstr ""
469" -o, --proc Stampa le informazioni come se provenissero dalla\n"
470" interfaccia cpufreq /proc/ presente nei kernel\n"
471" 2.4 ed i primi 2.6\n"
472
473#: utils/cpufreq-info.c:491
474#, c-format
475msgid ""
476" -m, --human human-readable output for the -f, -w, -s and -y "
477"parameters\n"
478msgstr ""
479" -m, --human formatta l'output delle opzioni -f, -w, -s e -y in "
480"maniera\n"
481" leggibile da un essere umano\n"
482
483#: utils/cpufreq-info.c:492 utils/cpuidle-info.c:152
484#, c-format
485msgid " -h, --help Prints out this screen\n"
486msgstr " -h, --help Stampa questa schermata\n"
487
488#: utils/cpufreq-info.c:495
489#, c-format
490msgid ""
491"If no argument or only the -c, --cpu parameter is given, debug output about\n"
492"cpufreq is printed which is useful e.g. for reporting bugs.\n"
493msgstr ""
494"Se non viene specificata nessuna opzione o viene specificata solo l'opzione -"
495"c, --cpu,\n"
496"le informazioni di debug per cpufreq saranno utili ad esempio a riportare i "
497"bug.\n"
498
499#: utils/cpufreq-info.c:497
500#, c-format
501msgid ""
502"For the arguments marked with *, omitting the -c or --cpu argument is\n"
503"equivalent to setting it to zero\n"
504msgstr ""
505"Per le opzioni segnalate con *, omettere l'opzione -c o --cpu è come "
506"specificarla\n"
507"con il valore 0\n"
508
509#: utils/cpufreq-info.c:580
510#, c-format
511msgid ""
512"The argument passed to this tool can't be combined with passing a --cpu "
513"argument\n"
514msgstr ""
515"L'opzione specificata a questo programma non può essere combinata con --cpu\n"
516
517#: utils/cpufreq-info.c:596
518#, c-format
519msgid ""
520"You can't specify more than one --cpu parameter and/or\n"
521"more than one output-specific argument\n"
522msgstr ""
523"Non è possibile specificare più di una volta l'opzione --cpu e/o\n"
524"specificare più di un parametro di output specifico\n"
525
526#: utils/cpufreq-info.c:600 utils/cpufreq-set.c:82 utils/cpupower-set.c:42
527#: utils/cpupower-info.c:42 utils/cpuidle-info.c:213
528#, c-format
529msgid "invalid or unknown argument\n"
530msgstr "opzione sconosciuta o non valida\n"
531
532#: utils/cpufreq-info.c:617
533#, c-format
534msgid "couldn't analyze CPU %d as it doesn't seem to be present\n"
535msgstr "impossibile analizzare la CPU %d poiché non sembra essere presente\n"
536
537#: utils/cpufreq-info.c:620 utils/cpupower-info.c:142
538#, c-format
539msgid "analyzing CPU %d:\n"
540msgstr "analisi della CPU %d:\n"
541
542#: utils/cpufreq-set.c:25
543#, fuzzy, c-format
544msgid "Usage: cpupower frequency-set [options]\n"
545msgstr "Uso: cpufreq-set [opzioni]\n"
546
547#: utils/cpufreq-set.c:27
548#, c-format
549msgid ""
550" -d FREQ, --min FREQ new minimum CPU frequency the governor may "
551"select\n"
552msgstr ""
553" -d FREQ, --min FREQ la nuova frequenza minima che il gestore cpufreq "
554"può scegliere\n"
555
556#: utils/cpufreq-set.c:28
557#, c-format
558msgid ""
559" -u FREQ, --max FREQ new maximum CPU frequency the governor may "
560"select\n"
561msgstr ""
562" -u FREQ, --max FREQ la nuova frequenza massima che il gestore cpufreq "
563"può scegliere\n"
564
565#: utils/cpufreq-set.c:29
566#, c-format
567msgid " -g GOV, --governor GOV new cpufreq governor\n"
568msgstr " -g GOV, --governor GOV nuovo gestore cpufreq\n"
569
570#: utils/cpufreq-set.c:30
571#, c-format
572msgid ""
573" -f FREQ, --freq FREQ specific frequency to be set. Requires userspace\n"
574" governor to be available and loaded\n"
575msgstr ""
576" -f FREQ, --freq FREQ specifica la frequenza a cui impostare la CPU.\n"
577" È necessario che il gestore userspace sia "
578"disponibile e caricato\n"
579
580#: utils/cpufreq-set.c:32
581#, c-format
582msgid " -r, --related Switches all hardware-related CPUs\n"
583msgstr ""
584" -r, --related Modifica tutte le CPU coordinate dall'hardware\n"
585
586#: utils/cpufreq-set.c:33 utils/cpupower-set.c:28 utils/cpupower-info.c:27
587#, c-format
588msgid " -h, --help Prints out this screen\n"
589msgstr " -h, --help Stampa questa schermata\n"
590
591#: utils/cpufreq-set.c:35
592#, fuzzy, c-format
593msgid ""
594"Notes:\n"
595"1. Omitting the -c or --cpu argument is equivalent to setting it to \"all\"\n"
596msgstr ""
597"Per le opzioni segnalate con *, omettere l'opzione -c o --cpu è come "
598"specificarla\n"
599"con il valore 0\n"
600
601#: utils/cpufreq-set.c:37
602#, fuzzy, c-format
603msgid ""
604"2. The -f FREQ, --freq FREQ parameter cannot be combined with any other "
605"parameter\n"
606" except the -c CPU, --cpu CPU parameter\n"
607"3. FREQuencies can be passed in Hz, kHz (default), MHz, GHz, or THz\n"
608" by postfixing the value with the wanted unit name, without any space\n"
609" (FREQuency in kHz =^ Hz * 0.001 =^ MHz * 1000 =^ GHz * 1000000).\n"
610msgstr ""
611"Note:\n"
612"1. Omettere l'opzione -c o --cpu è equivalente a impostarlo a 0\n"
613"2. l'opzione -f FREQ, --freq FREQ non può essere specificata con altre "
614"opzioni\n"
615" ad eccezione dell'opzione -c CPU o --cpu CPU\n"
616"3. le FREQuenze possono essere specuficate in Hz, kHz (default), MHz, GHz, "
617"or THz\n"
618" postponendo l'unità di misura al valore senza nessuno spazio fra loro\n"
619" (FREQuenza in kHz =^ Hz * 0.001 =^ MHz * 1000 =^ GHz * 1000000).\n"
620
621#: utils/cpufreq-set.c:57
622#, c-format
623msgid ""
624"Error setting new values. Common errors:\n"
625"- Do you have proper administration rights? (super-user?)\n"
626"- Is the governor you requested available and modprobed?\n"
627"- Trying to set an invalid policy?\n"
628"- Trying to set a specific frequency, but userspace governor is not "
629"available,\n"
630" for example because of hardware which cannot be set to a specific "
631"frequency\n"
632" or because the userspace governor isn't loaded?\n"
633msgstr ""
634"Si sono verificati degli errori impostando i nuovi valori.\n"
635"Alcuni errori comuni possono essere:\n"
636"- Hai i necessari diritti di amministrazione? (super-user?)\n"
637"- Il gestore che hai richiesto è disponibile e caricato?\n"
638"- Stai provando ad impostare una politica di gestione non valida?\n"
639"- Stai provando a impostare una specifica frequenza ma il gestore\n"
640" userspace non è disponibile, per esempio a causa dell'hardware\n"
641" che non supporta frequenze fisse o a causa del fatto che\n"
642" il gestore userspace non è caricato?\n"
643
644#: utils/cpufreq-set.c:170
645#, c-format
646msgid "wrong, unknown or unhandled CPU?\n"
647msgstr "CPU errata, sconosciuta o non gestita?\n"
648
649#: utils/cpufreq-set.c:302
650#, c-format
651msgid ""
652"the -f/--freq parameter cannot be combined with -d/--min, -u/--max or\n"
653"-g/--governor parameters\n"
654msgstr ""
655"l'opzione -f/--freq non può venire combinata con i parametri\n"
656" -d/--min, -u/--max o -g/--governor\n"
657
658#: utils/cpufreq-set.c:308
659#, c-format
660msgid ""
661"At least one parameter out of -f/--freq, -d/--min, -u/--max, and\n"
662"-g/--governor must be passed\n"
663msgstr ""
664"Almeno una delle opzioni -f/--freq, -d/--min, -u/--max, e -g/--governor\n"
665"deve essere specificata\n"
666
667#: utils/cpufreq-set.c:347
668#, c-format
669msgid "Setting cpu: %d\n"
670msgstr ""
671
672#: utils/cpupower-set.c:22
673#, c-format
674msgid "Usage: cpupower set [ -b val ] [ -m val ] [ -s val ]\n"
675msgstr ""
676
677#: utils/cpupower-set.c:24
678#, c-format
679msgid ""
680" -b, --perf-bias [VAL] Sets CPU's power vs performance policy on some\n"
681" Intel models [0-15], see manpage for details\n"
682msgstr ""
683
684#: utils/cpupower-set.c:26
685#, c-format
686msgid ""
687" -m, --sched-mc [VAL] Sets the kernel's multi core scheduler policy.\n"
688msgstr ""
689
690#: utils/cpupower-set.c:27
691#, c-format
692msgid ""
693" -s, --sched-smt [VAL] Sets the kernel's thread sibling scheduler "
694"policy.\n"
695msgstr ""
696
697#: utils/cpupower-set.c:80
698#, c-format
699msgid "--perf-bias param out of range [0-%d]\n"
700msgstr ""
701
702#: utils/cpupower-set.c:91
703#, c-format
704msgid "--sched-mc param out of range [0-%d]\n"
705msgstr ""
706
707#: utils/cpupower-set.c:102
708#, c-format
709msgid "--sched-smt param out of range [0-%d]\n"
710msgstr ""
711
712#: utils/cpupower-set.c:121
713#, c-format
714msgid "Error setting sched-mc %s\n"
715msgstr ""
716
717#: utils/cpupower-set.c:127
718#, c-format
719msgid "Error setting sched-smt %s\n"
720msgstr ""
721
722#: utils/cpupower-set.c:146
723#, c-format
724msgid "Error setting perf-bias value on CPU %d\n"
725msgstr ""
726
727#: utils/cpupower-info.c:21
728#, c-format
729msgid "Usage: cpupower info [ -b ] [ -m ] [ -s ]\n"
730msgstr ""
731
732#: utils/cpupower-info.c:23
733#, c-format
734msgid ""
735" -b, --perf-bias Gets CPU's power vs performance policy on some\n"
736" Intel models [0-15], see manpage for details\n"
737msgstr ""
738
739#: utils/cpupower-info.c:25
740#, fuzzy, c-format
741msgid " -m, --sched-mc Gets the kernel's multi core scheduler policy.\n"
742msgstr ""
743" -p, --policy Mostra il gestore cpufreq attualmente in uso *\n"
744
745#: utils/cpupower-info.c:26
746#, c-format
747msgid ""
748" -s, --sched-smt Gets the kernel's thread sibling scheduler policy.\n"
749msgstr ""
750
751#: utils/cpupower-info.c:28
752#, c-format
753msgid ""
754"\n"
755"Passing no option will show all info, by default only on core 0\n"
756msgstr ""
757
758#: utils/cpupower-info.c:102
759#, c-format
760msgid "System's multi core scheduler setting: "
761msgstr ""
762
763#. if sysfs file is missing it's: errno == ENOENT
764#: utils/cpupower-info.c:105 utils/cpupower-info.c:114
765#, c-format
766msgid "not supported\n"
767msgstr ""
768
769#: utils/cpupower-info.c:111
770#, c-format
771msgid "System's thread sibling scheduler setting: "
772msgstr ""
773
774#: utils/cpupower-info.c:126
775#, c-format
776msgid "Intel's performance bias setting needs root privileges\n"
777msgstr ""
778
779#: utils/cpupower-info.c:128
780#, c-format
781msgid "System does not support Intel's performance bias setting\n"
782msgstr ""
783
784#: utils/cpupower-info.c:147
785#, c-format
786msgid "Could not read perf-bias value\n"
787msgstr ""
788
789#: utils/cpupower-info.c:150
790#, c-format
791msgid "perf-bias: %d\n"
792msgstr ""
793
794#: utils/cpuidle-info.c:28
795#, fuzzy, c-format
796msgid "Analyzing CPU %d:\n"
797msgstr "analisi della CPU %d:\n"
798
799#: utils/cpuidle-info.c:32
800#, c-format
801msgid "CPU %u: No idle states\n"
802msgstr ""
803
804#: utils/cpuidle-info.c:36
805#, c-format
806msgid "CPU %u: Can't read idle state info\n"
807msgstr ""
808
809#: utils/cpuidle-info.c:41
810#, c-format
811msgid "Could not determine max idle state %u\n"
812msgstr ""
813
814#: utils/cpuidle-info.c:46
815#, c-format
816msgid "Number of idle states: %d\n"
817msgstr ""
818
819#: utils/cpuidle-info.c:48
820#, fuzzy, c-format
821msgid "Available idle states:"
822msgstr " frequenze disponibili: "
823
824#: utils/cpuidle-info.c:71
825#, c-format
826msgid "Flags/Description: %s\n"
827msgstr ""
828
829#: utils/cpuidle-info.c:74
830#, c-format
831msgid "Latency: %lu\n"
832msgstr ""
833
834#: utils/cpuidle-info.c:76
835#, c-format
836msgid "Usage: %lu\n"
837msgstr ""
838
839#: utils/cpuidle-info.c:78
840#, c-format
841msgid "Duration: %llu\n"
842msgstr ""
843
844#: utils/cpuidle-info.c:90
845#, c-format
846msgid "Could not determine cpuidle driver\n"
847msgstr ""
848
849#: utils/cpuidle-info.c:94
850#, fuzzy, c-format
851msgid "CPUidle driver: %s\n"
852msgstr " modulo %s\n"
853
854#: utils/cpuidle-info.c:99
855#, c-format
856msgid "Could not determine cpuidle governor\n"
857msgstr ""
858
859#: utils/cpuidle-info.c:103
860#, c-format
861msgid "CPUidle governor: %s\n"
862msgstr ""
863
864#: utils/cpuidle-info.c:122
865#, c-format
866msgid "CPU %u: Can't read C-state info\n"
867msgstr ""
868
869#. printf("Cstates: %d\n", cstates);
870#: utils/cpuidle-info.c:127
871#, c-format
872msgid "active state: C0\n"
873msgstr ""
874
875#: utils/cpuidle-info.c:128
876#, c-format
877msgid "max_cstate: C%u\n"
878msgstr ""
879
880#: utils/cpuidle-info.c:129
881#, fuzzy, c-format
882msgid "maximum allowed latency: %lu usec\n"
883msgstr " latenza massima durante la transizione: "
884
885#: utils/cpuidle-info.c:130
886#, c-format
887msgid "states:\t\n"
888msgstr ""
889
890#: utils/cpuidle-info.c:132
891#, c-format
892msgid " C%d: type[C%d] "
893msgstr ""
894
895#: utils/cpuidle-info.c:134
896#, c-format
897msgid "promotion[--] demotion[--] "
898msgstr ""
899
900#: utils/cpuidle-info.c:135
901#, c-format
902msgid "latency[%03lu] "
903msgstr ""
904
905#: utils/cpuidle-info.c:137
906#, c-format
907msgid "usage[%08lu] "
908msgstr ""
909
910#: utils/cpuidle-info.c:139
911#, c-format
912msgid "duration[%020Lu] \n"
913msgstr ""
914
915#: utils/cpuidle-info.c:147
916#, fuzzy, c-format
917msgid "Usage: cpupower idleinfo [options]\n"
918msgstr "Uso: cpufreq-info [opzioni]\n"
919
920#: utils/cpuidle-info.c:149
921#, fuzzy, c-format
922msgid " -s, --silent Only show general C-state information\n"
923msgstr " -e, --debug Mostra informazioni di debug\n"
924
925#: utils/cpuidle-info.c:150
926#, fuzzy, c-format
927msgid ""
928" -o, --proc Prints out information like provided by the /proc/"
929"acpi/processor/*/power\n"
930" interface in older kernels\n"
931msgstr ""
932" -o, --proc Stampa le informazioni come se provenissero dalla\n"
933" interfaccia cpufreq /proc/ presente nei kernel\n"
934" 2.4 ed i primi 2.6\n"
935
936#: utils/cpuidle-info.c:209
937#, fuzzy, c-format
938msgid "You can't specify more than one output-specific argument\n"
939msgstr ""
940"Non è possibile specificare più di una volta l'opzione --cpu e/o\n"
941"specificare più di un parametro di output specifico\n"
942
943#~ msgid ""
944#~ " -c CPU, --cpu CPU CPU number which information shall be determined "
945#~ "about\n"
946#~ msgstr ""
947#~ " -c CPU, --cpu CPU Numero di CPU per la quale ottenere le "
948#~ "informazioni\n"
949
950#~ msgid ""
951#~ " -c CPU, --cpu CPU number of CPU where cpufreq settings shall be "
952#~ "modified\n"
953#~ msgstr ""
954#~ " -c CPU, --cpu CPU numero di CPU per la quale modificare le "
955#~ "impostazioni\n"
956
957#, fuzzy
958#~ msgid " CPUs which coordinate software frequency requirements: "
959#~ msgstr ""
960#~ " CPU per le quali e` necessario cambiare la frequenza "
961#~ "contemporaneamente: "
diff --git a/tools/power/cpupower/po/pt.po b/tools/power/cpupower/po/pt.po
new file mode 100644
index 00000000000..990f5267ffe
--- /dev/null
+++ b/tools/power/cpupower/po/pt.po
@@ -0,0 +1,957 @@
1# Brazilian Portuguese translations for cpufrequtils package
2# Copyright (C) 2008 THE cpufrequtils'S COPYRIGHT HOLDER
3# This file is distributed under the same license as the cpufrequtils package.
4# Claudio Eduardo <claudioeddy@gmail.com>, 2009.
5#
6#
7msgid ""
8msgstr ""
9"Project-Id-Version: cpufrequtils 004\n"
10"Report-Msgid-Bugs-To: \n"
11"POT-Creation-Date: 2011-03-08 17:03+0100\n"
12"PO-Revision-Date: 2008-06-14 22:16-0400\n"
13"Last-Translator: Claudio Eduardo <claudioeddy@gmail.com>\n"
14"MIME-Version: 1.0\n"
15"Content-Type: text/plain; charset=UTF-8\n"
16"Content-Transfer-Encoding: 8bit\n"
17
18#: utils/idle_monitor/nhm_idle.c:36
19msgid "Processor Core C3"
20msgstr ""
21
22#: utils/idle_monitor/nhm_idle.c:43
23msgid "Processor Core C6"
24msgstr ""
25
26#: utils/idle_monitor/nhm_idle.c:51
27msgid "Processor Package C3"
28msgstr ""
29
30#: utils/idle_monitor/nhm_idle.c:58 utils/idle_monitor/amd_fam14h_idle.c:70
31msgid "Processor Package C6"
32msgstr ""
33
34#: utils/idle_monitor/snb_idle.c:33
35msgid "Processor Core C7"
36msgstr ""
37
38#: utils/idle_monitor/snb_idle.c:40
39msgid "Processor Package C2"
40msgstr ""
41
42#: utils/idle_monitor/snb_idle.c:47
43msgid "Processor Package C7"
44msgstr ""
45
46#: utils/idle_monitor/amd_fam14h_idle.c:56
47msgid "Package in sleep state (PC1 or deeper)"
48msgstr ""
49
50#: utils/idle_monitor/amd_fam14h_idle.c:63
51msgid "Processor Package C1"
52msgstr ""
53
54#: utils/idle_monitor/amd_fam14h_idle.c:77
55msgid "North Bridge P1 boolean counter (returns 0 or 1)"
56msgstr ""
57
58#: utils/idle_monitor/mperf_monitor.c:35
59msgid "Processor Core not idle"
60msgstr ""
61
62#: utils/idle_monitor/mperf_monitor.c:42
63msgid "Processor Core in an idle state"
64msgstr ""
65
66#: utils/idle_monitor/mperf_monitor.c:50
67msgid "Average Frequency (including boost) in MHz"
68msgstr ""
69
70#: utils/idle_monitor/cpupower-monitor.c:66
71#, c-format
72msgid ""
73"cpupower monitor: [-h] [ [-t] | [-l] | [-m <mon1>,[<mon2>] ] ] [-i "
74"interval_sec | -c command ...]\n"
75msgstr ""
76
77#: utils/idle_monitor/cpupower-monitor.c:69
78#, c-format
79msgid ""
80"cpupower monitor: [-v] [-h] [ [-t] | [-l] | [-m <mon1>,[<mon2>] ] ] [-i "
81"interval_sec | -c command ...]\n"
82msgstr ""
83
84#: utils/idle_monitor/cpupower-monitor.c:71
85#, c-format
86msgid "\t -v: be more verbose\n"
87msgstr ""
88
89#: utils/idle_monitor/cpupower-monitor.c:73
90#, c-format
91msgid "\t -h: print this help\n"
92msgstr ""
93
94#: utils/idle_monitor/cpupower-monitor.c:74
95#, c-format
96msgid "\t -i: time intervall to measure for in seconds (default 1)\n"
97msgstr ""
98
99#: utils/idle_monitor/cpupower-monitor.c:75
100#, c-format
101msgid "\t -t: show CPU topology/hierarchy\n"
102msgstr ""
103
104#: utils/idle_monitor/cpupower-monitor.c:76
105#, c-format
106msgid "\t -l: list available CPU sleep monitors (for use with -m)\n"
107msgstr ""
108
109#: utils/idle_monitor/cpupower-monitor.c:77
110#, c-format
111msgid "\t -m: show specific CPU sleep monitors only (in same order)\n"
112msgstr ""
113
114#: utils/idle_monitor/cpupower-monitor.c:79
115#, c-format
116msgid ""
117"only one of: -t, -l, -m are allowed\n"
118"If none of them is passed,"
119msgstr ""
120
121#: utils/idle_monitor/cpupower-monitor.c:80
122#, c-format
123msgid " all supported monitors are shown\n"
124msgstr ""
125
126#: utils/idle_monitor/cpupower-monitor.c:197
127#, c-format
128msgid "Monitor %s, Counter %s has no count function. Implementation error\n"
129msgstr ""
130
131#: utils/idle_monitor/cpupower-monitor.c:207
132#, c-format
133msgid " *is offline\n"
134msgstr ""
135
136#: utils/idle_monitor/cpupower-monitor.c:236
137#, c-format
138msgid "%s: max monitor name length (%d) exceeded\n"
139msgstr ""
140
141#: utils/idle_monitor/cpupower-monitor.c:250
142#, c-format
143msgid "No matching monitor found in %s, try -l option\n"
144msgstr ""
145
146#: utils/idle_monitor/cpupower-monitor.c:266
147#, c-format
148msgid "Monitor \"%s\" (%d states) - Might overflow after %u s\n"
149msgstr ""
150
151#: utils/idle_monitor/cpupower-monitor.c:319
152#, c-format
153msgid "%s took %.5f seconds and exited with status %d\n"
154msgstr ""
155
156#: utils/idle_monitor/cpupower-monitor.c:406
157#, c-format
158msgid "Cannot read number of available processors\n"
159msgstr ""
160
161#: utils/idle_monitor/cpupower-monitor.c:417
162#, c-format
163msgid "Available monitor %s needs root access\n"
164msgstr ""
165
166#: utils/idle_monitor/cpupower-monitor.c:428
167#, c-format
168msgid "No HW Cstate monitors found\n"
169msgstr ""
170
171#: utils/cpupower.c:78
172#, c-format
173msgid "cpupower [ -c cpulist ] subcommand [ARGS]\n"
174msgstr ""
175
176#: utils/cpupower.c:79
177#, c-format
178msgid "cpupower --version\n"
179msgstr ""
180
181#: utils/cpupower.c:80
182#, c-format
183msgid "Supported subcommands are:\n"
184msgstr ""
185
186#: utils/cpupower.c:83
187#, c-format
188msgid ""
189"\n"
190"Some subcommands can make use of the -c cpulist option.\n"
191msgstr ""
192
193#: utils/cpupower.c:84
194#, c-format
195msgid "Look at the general cpupower manpage how to use it\n"
196msgstr ""
197
198#: utils/cpupower.c:85
199#, c-format
200msgid "and read up the subcommand's manpage whether it is supported.\n"
201msgstr ""
202
203#: utils/cpupower.c:86
204#, c-format
205msgid ""
206"\n"
207"Use cpupower help subcommand for getting help for above subcommands.\n"
208msgstr ""
209
210#: utils/cpupower.c:91
211#, c-format
212msgid "Report errors and bugs to %s, please.\n"
213msgstr "Reporte erros e bugs para %s, por favor.\n"
214
215#: utils/cpupower.c:114
216#, c-format
217msgid "Error parsing cpu list\n"
218msgstr ""
219
220#: utils/cpupower.c:172
221#, c-format
222msgid "Subcommand %s needs root privileges\n"
223msgstr ""
224
225#: utils/cpufreq-info.c:31
226#, c-format
227msgid "Couldn't count the number of CPUs (%s: %s), assuming 1\n"
228msgstr "Não foi possível contar o número de CPUs (%s: %s), assumindo 1\n"
229
230#: utils/cpufreq-info.c:63
231#, c-format
232msgid ""
233" minimum CPU frequency - maximum CPU frequency - governor\n"
234msgstr ""
235" frequência mínina do CPU - frequência máxima do CPU - "
236"regulador\n"
237
238#: utils/cpufreq-info.c:151
239#, c-format
240msgid "Error while evaluating Boost Capabilities on CPU %d -- are you root?\n"
241msgstr ""
242
243#. P state changes via MSR are identified via cpuid 80000007
244#. on Intel and AMD, but we assume boost capable machines can do that
245#. if (cpuid_eax(0x80000000) >= 0x80000007
246#. && (cpuid_edx(0x80000007) & (1 << 7)))
247#.
248#: utils/cpufreq-info.c:161
249#, c-format
250msgid " boost state support: \n"
251msgstr ""
252
253#: utils/cpufreq-info.c:163
254#, c-format
255msgid " Supported: %s\n"
256msgstr ""
257
258#: utils/cpufreq-info.c:163 utils/cpufreq-info.c:164
259msgid "yes"
260msgstr ""
261
262#: utils/cpufreq-info.c:163 utils/cpufreq-info.c:164
263msgid "no"
264msgstr ""
265
266#: utils/cpufreq-info.c:164
267#, fuzzy, c-format
268msgid " Active: %s\n"
269msgstr " driver: %s\n"
270
271#: utils/cpufreq-info.c:177
272#, c-format
273msgid " Boost States: %d\n"
274msgstr ""
275
276#: utils/cpufreq-info.c:178
277#, c-format
278msgid " Total States: %d\n"
279msgstr ""
280
281#: utils/cpufreq-info.c:181
282#, c-format
283msgid " Pstate-Pb%d: %luMHz (boost state)\n"
284msgstr ""
285
286#: utils/cpufreq-info.c:184
287#, c-format
288msgid " Pstate-P%d: %luMHz\n"
289msgstr ""
290
291#: utils/cpufreq-info.c:211
292#, c-format
293msgid " no or unknown cpufreq driver is active on this CPU\n"
294msgstr " nenhum ou driver do cpufreq deconhecido está ativo nesse CPU\n"
295
296#: utils/cpufreq-info.c:213
297#, c-format
298msgid " driver: %s\n"
299msgstr " driver: %s\n"
300
301#: utils/cpufreq-info.c:219
302#, c-format
303msgid " CPUs which run at the same hardware frequency: "
304msgstr " CPUs que rodam na mesma frequência de hardware: "
305
306#: utils/cpufreq-info.c:230
307#, c-format
308msgid " CPUs which need to have their frequency coordinated by software: "
309msgstr " CPUs que precisam ter suas frequências coordenadas por software: "
310
311#: utils/cpufreq-info.c:241
312#, c-format
313msgid " maximum transition latency: "
314msgstr " maior latência de transição: "
315
316#: utils/cpufreq-info.c:247
317#, c-format
318msgid " hardware limits: "
319msgstr " limites do hardware: "
320
321#: utils/cpufreq-info.c:256
322#, c-format
323msgid " available frequency steps: "
324msgstr " níveis de frequência disponíveis: "
325
326#: utils/cpufreq-info.c:269
327#, c-format
328msgid " available cpufreq governors: "
329msgstr " reguladores do cpufreq disponíveis: "
330
331#: utils/cpufreq-info.c:280
332#, c-format
333msgid " current policy: frequency should be within "
334msgstr " política de frequência atual deve estar entre "
335
336#: utils/cpufreq-info.c:282
337#, c-format
338msgid " and "
339msgstr " e "
340
341#: utils/cpufreq-info.c:286
342#, c-format
343msgid ""
344"The governor \"%s\" may decide which speed to use\n"
345" within this range.\n"
346msgstr ""
347"O regulador \"%s\" deve decidir qual velocidade usar\n"
348" dentro desse limite.\n"
349
350#: utils/cpufreq-info.c:293
351#, c-format
352msgid " current CPU frequency is "
353msgstr " frequência atual do CPU é "
354
355#: utils/cpufreq-info.c:296
356#, c-format
357msgid " (asserted by call to hardware)"
358msgstr " (declarado por chamada ao hardware)"
359
360#: utils/cpufreq-info.c:304
361#, c-format
362msgid " cpufreq stats: "
363msgstr " status do cpufreq: "
364
365#: utils/cpufreq-info.c:472
366#, fuzzy, c-format
367msgid "Usage: cpupower freqinfo [options]\n"
368msgstr "Uso: cpufreq-info [opções]\n"
369
370#: utils/cpufreq-info.c:473 utils/cpufreq-set.c:26 utils/cpupower-set.c:23
371#: utils/cpupower-info.c:22 utils/cpuidle-info.c:148
372#, c-format
373msgid "Options:\n"
374msgstr "Opções:\n"
375
376#: utils/cpufreq-info.c:474
377#, fuzzy, c-format
378msgid " -e, --debug Prints out debug information [default]\n"
379msgstr " -e, --debug Mostra informação de debug\n"
380
381#: utils/cpufreq-info.c:475
382#, c-format
383msgid ""
384" -f, --freq Get frequency the CPU currently runs at, according\n"
385" to the cpufreq core *\n"
386msgstr ""
387" -f, --freq Obtem a frequência na qual o CPU roda no momento, de "
388"acordo\n"
389" com o núcleo do cpufreq *\n"
390
391#: utils/cpufreq-info.c:477
392#, c-format
393msgid ""
394" -w, --hwfreq Get frequency the CPU currently runs at, by reading\n"
395" it from hardware (only available to root) *\n"
396msgstr ""
397" -w, --hwfreq Obtem a frequência na qual o CPU está operando no "
398"momento,\n"
399" através de leitura no hardware (disponível somente "
400"para root) *\n"
401
402#: utils/cpufreq-info.c:479
403#, c-format
404msgid ""
405" -l, --hwlimits Determine the minimum and maximum CPU frequency "
406"allowed *\n"
407msgstr ""
408" -l, --hwlimits Determina a frequência mínima e máxima do CPU "
409"permitida *\n"
410
411#: utils/cpufreq-info.c:480
412#, c-format
413msgid " -d, --driver Determines the used cpufreq kernel driver *\n"
414msgstr ""
415" -d, --driver Determina o driver do kernel do cpufreq usado *\n"
416
417#: utils/cpufreq-info.c:481
418#, c-format
419msgid " -p, --policy Gets the currently used cpufreq policy *\n"
420msgstr ""
421"--p, --policy Obtem a política do cpufreq em uso no momento *\n"
422
423#: utils/cpufreq-info.c:482
424#, c-format
425msgid " -g, --governors Determines available cpufreq governors *\n"
426msgstr ""
427" -g, --governors Determina reguladores do cpufreq disponíveis *\n"
428
429#: utils/cpufreq-info.c:483
430#, c-format
431msgid ""
432" -r, --related-cpus Determines which CPUs run at the same hardware "
433"frequency *\n"
434msgstr ""
435" -r, --related-cpus Determina quais CPUs rodam na mesma frequência de "
436"hardware *\n"
437
438#: utils/cpufreq-info.c:484
439#, c-format
440msgid ""
441" -a, --affected-cpus Determines which CPUs need to have their frequency\n"
442" coordinated by software *\n"
443msgstr ""
444" -a, --affected-cpus Determina quais CPUs precisam ter suas frequências\n"
445" coordenadas por software *\n"
446
447#: utils/cpufreq-info.c:486
448#, c-format
449msgid " -s, --stats Shows cpufreq statistics if available\n"
450msgstr " -s, --stats Mostra estatísticas do cpufreq se disponíveis\n"
451
452#: utils/cpufreq-info.c:487
453#, c-format
454msgid ""
455" -y, --latency Determines the maximum latency on CPU frequency "
456"changes *\n"
457msgstr ""
458" -y, --latency Determina a latência máxima nas trocas de frequência "
459"do CPU *\n"
460
461#: utils/cpufreq-info.c:488
462#, c-format
463msgid " -b, --boost Checks for turbo or boost modes *\n"
464msgstr ""
465
466#: utils/cpufreq-info.c:489
467#, c-format
468msgid ""
469" -o, --proc Prints out information like provided by the /proc/"
470"cpufreq\n"
471" interface in 2.4. and early 2.6. kernels\n"
472msgstr ""
473" -o, --proc Mostra informação do tipo provida pela interface /"
474"proc/cpufreq\n"
475" em kernels 2.4. e mais recentes 2.6\n"
476
477#: utils/cpufreq-info.c:491
478#, c-format
479msgid ""
480" -m, --human human-readable output for the -f, -w, -s and -y "
481"parameters\n"
482msgstr ""
483" -m, --human saída legível para humanos para os parâmetros -f, -w, "
484"-s e -y\n"
485
486#: utils/cpufreq-info.c:492 utils/cpuidle-info.c:152
487#, c-format
488msgid " -h, --help Prints out this screen\n"
489msgstr " -h, --help Imprime essa tela\n"
490
491#: utils/cpufreq-info.c:495
492#, c-format
493msgid ""
494"If no argument or only the -c, --cpu parameter is given, debug output about\n"
495"cpufreq is printed which is useful e.g. for reporting bugs.\n"
496msgstr ""
497"Se nenhum argumento ou somente o parâmetro -c, --cpu é dado, informação de "
498"debug sobre\n"
499"o cpufreq é mostrada, o que é útil por exemplo para reportar bugs.\n"
500
501#: utils/cpufreq-info.c:497
502#, c-format
503msgid ""
504"For the arguments marked with *, omitting the -c or --cpu argument is\n"
505"equivalent to setting it to zero\n"
506msgstr ""
507"Para os argumentos marcados com *, omitir o argumento -c ou --cpu é\n"
508"equivalente a setá-lo como zero\n"
509
510#: utils/cpufreq-info.c:580
511#, c-format
512msgid ""
513"The argument passed to this tool can't be combined with passing a --cpu "
514"argument\n"
515msgstr ""
516"O argumento usado pra essa ferramenta não pode ser combinado com um "
517"argumento --cpu\n"
518
519#: utils/cpufreq-info.c:596
520#, c-format
521msgid ""
522"You can't specify more than one --cpu parameter and/or\n"
523"more than one output-specific argument\n"
524msgstr ""
525"Você não pode especificar mais do que um parâmetro --cpu e/ou\n"
526"mais do que um argumento de saída específico\n"
527
528#: utils/cpufreq-info.c:600 utils/cpufreq-set.c:82 utils/cpupower-set.c:42
529#: utils/cpupower-info.c:42 utils/cpuidle-info.c:213
530#, c-format
531msgid "invalid or unknown argument\n"
532msgstr "argumento inválido ou desconhecido\n"
533
534#: utils/cpufreq-info.c:617
535#, c-format
536msgid "couldn't analyze CPU %d as it doesn't seem to be present\n"
537msgstr ""
538"não foi possível analisar o CPU % já que o mesmo parece não estar presente\n"
539
540#: utils/cpufreq-info.c:620 utils/cpupower-info.c:142
541#, c-format
542msgid "analyzing CPU %d:\n"
543msgstr "analisando o CPU %d:\n"
544
545#: utils/cpufreq-set.c:25
546#, fuzzy, c-format
547msgid "Usage: cpupower frequency-set [options]\n"
548msgstr "Uso: cpufreq-set [opções]\n"
549
550#: utils/cpufreq-set.c:27
551#, c-format
552msgid ""
553" -d FREQ, --min FREQ new minimum CPU frequency the governor may "
554"select\n"
555msgstr ""
556" -d FREQ, --min FREQ nova frequência mínima do CPU que o regulador "
557"deve selecionar\n"
558
559#: utils/cpufreq-set.c:28
560#, c-format
561msgid ""
562" -u FREQ, --max FREQ new maximum CPU frequency the governor may "
563"select\n"
564msgstr ""
565" -u FREQ, --max FREQ nova frequência máxima do CPU que o regulador "
566"deve escolher\n"
567
568#: utils/cpufreq-set.c:29
569#, c-format
570msgid " -g GOV, --governor GOV new cpufreq governor\n"
571msgstr " -g GOV, --governor GOV novo regulador do cpufreq\n"
572
573#: utils/cpufreq-set.c:30
574#, c-format
575msgid ""
576" -f FREQ, --freq FREQ specific frequency to be set. Requires userspace\n"
577" governor to be available and loaded\n"
578msgstr ""
579" -f FREQ, --freq FREQ frequência específica para ser setada. Necessita "
580"que o regulador em\n"
581" nível de usuário esteja disponível e carregado\n"
582
583#: utils/cpufreq-set.c:32
584#, c-format
585msgid " -r, --related Switches all hardware-related CPUs\n"
586msgstr ""
587" -r, --related Modifica todos os CPUs relacionados ao hardware\n"
588
589#: utils/cpufreq-set.c:33 utils/cpupower-set.c:28 utils/cpupower-info.c:27
590#, c-format
591msgid " -h, --help Prints out this screen\n"
592msgstr " -h, --help Mostra essa tela\n"
593
594#: utils/cpufreq-set.c:35
595#, fuzzy, c-format
596msgid ""
597"Notes:\n"
598"1. Omitting the -c or --cpu argument is equivalent to setting it to \"all\"\n"
599msgstr ""
600"Para os argumentos marcados com *, omitir o argumento -c ou --cpu é\n"
601"equivalente a setá-lo como zero\n"
602
603#: utils/cpufreq-set.c:37
604#, fuzzy, c-format
605msgid ""
606"2. The -f FREQ, --freq FREQ parameter cannot be combined with any other "
607"parameter\n"
608" except the -c CPU, --cpu CPU parameter\n"
609"3. FREQuencies can be passed in Hz, kHz (default), MHz, GHz, or THz\n"
610" by postfixing the value with the wanted unit name, without any space\n"
611" (FREQuency in kHz =^ Hz * 0.001 =^ MHz * 1000 =^ GHz * 1000000).\n"
612msgstr ""
613"Notas:\n"
614"1. Omitir o argumento -c or --cpu é equivalente a setá-lo como zero\n"
615"2. O parâmetro -f FREQ, --freq FREQ não pode ser combinado com qualquer "
616"outro parâmetro\n"
617" exceto com o parâmetro -c CPU, --cpu CPU\n"
618"3. FREQuências podem ser usadas em Hz, kHz (padrão), MHz, GHz, o THz\n"
619" colocando o nome desejado da unidade após o valor, sem qualquer espaço\n"
620" (FREQuência em kHz =^ Hz * 0.001 =^ MHz * 1000 =^ GHz * 1000000).\n"
621
622#: utils/cpufreq-set.c:57
623#, c-format
624msgid ""
625"Error setting new values. Common errors:\n"
626"- Do you have proper administration rights? (super-user?)\n"
627"- Is the governor you requested available and modprobed?\n"
628"- Trying to set an invalid policy?\n"
629"- Trying to set a specific frequency, but userspace governor is not "
630"available,\n"
631" for example because of hardware which cannot be set to a specific "
632"frequency\n"
633" or because the userspace governor isn't loaded?\n"
634msgstr ""
635"Erro ao setar novos valores. Erros comuns:\n"
636"- Você tem direitos administrativos necessários? (super-usuário?)\n"
637"- O regulador que você requesitou está disponível e foi \"modprobed\"?\n"
638"- Tentando setar uma política inválida?\n"
639"- Tentando setar uma frequência específica, mas o regulador em nível de "
640"usuário não está disponível,\n"
641" por exemplo devido ao hardware que não pode ser setado pra uma frequência "
642"específica\n"
643" ou porque o regulador em nível de usuário não foi carregado?\n"
644
645#: utils/cpufreq-set.c:170
646#, c-format
647msgid "wrong, unknown or unhandled CPU?\n"
648msgstr "CPU errado, desconhecido ou inesperado?\n"
649
650#: utils/cpufreq-set.c:302
651#, c-format
652msgid ""
653"the -f/--freq parameter cannot be combined with -d/--min, -u/--max or\n"
654"-g/--governor parameters\n"
655msgstr ""
656"o parâmetro -f/--freq não pode ser combinado com os parâmetros -d/--min, -"
657"u/--max ou\n"
658"-g/--governor\n"
659
660#: utils/cpufreq-set.c:308
661#, c-format
662msgid ""
663"At least one parameter out of -f/--freq, -d/--min, -u/--max, and\n"
664"-g/--governor must be passed\n"
665msgstr ""
666"Pelo menos um parâmetro entre -f/--freq, -d/--min, -u/--max, e\n"
667"-g/--governor deve ser usado\n"
668
669#: utils/cpufreq-set.c:347
670#, c-format
671msgid "Setting cpu: %d\n"
672msgstr ""
673
674#: utils/cpupower-set.c:22
675#, c-format
676msgid "Usage: cpupower set [ -b val ] [ -m val ] [ -s val ]\n"
677msgstr ""
678
679#: utils/cpupower-set.c:24
680#, c-format
681msgid ""
682" -b, --perf-bias [VAL] Sets CPU's power vs performance policy on some\n"
683" Intel models [0-15], see manpage for details\n"
684msgstr ""
685
686#: utils/cpupower-set.c:26
687#, c-format
688msgid ""
689" -m, --sched-mc [VAL] Sets the kernel's multi core scheduler policy.\n"
690msgstr ""
691
692#: utils/cpupower-set.c:27
693#, c-format
694msgid ""
695" -s, --sched-smt [VAL] Sets the kernel's thread sibling scheduler "
696"policy.\n"
697msgstr ""
698
699#: utils/cpupower-set.c:80
700#, c-format
701msgid "--perf-bias param out of range [0-%d]\n"
702msgstr ""
703
704#: utils/cpupower-set.c:91
705#, c-format
706msgid "--sched-mc param out of range [0-%d]\n"
707msgstr ""
708
709#: utils/cpupower-set.c:102
710#, c-format
711msgid "--sched-smt param out of range [0-%d]\n"
712msgstr ""
713
714#: utils/cpupower-set.c:121
715#, c-format
716msgid "Error setting sched-mc %s\n"
717msgstr ""
718
719#: utils/cpupower-set.c:127
720#, c-format
721msgid "Error setting sched-smt %s\n"
722msgstr ""
723
724#: utils/cpupower-set.c:146
725#, c-format
726msgid "Error setting perf-bias value on CPU %d\n"
727msgstr ""
728
729#: utils/cpupower-info.c:21
730#, c-format
731msgid "Usage: cpupower info [ -b ] [ -m ] [ -s ]\n"
732msgstr ""
733
734#: utils/cpupower-info.c:23
735#, c-format
736msgid ""
737" -b, --perf-bias Gets CPU's power vs performance policy on some\n"
738" Intel models [0-15], see manpage for details\n"
739msgstr ""
740
741#: utils/cpupower-info.c:25
742#, fuzzy, c-format
743msgid " -m, --sched-mc Gets the kernel's multi core scheduler policy.\n"
744msgstr ""
745"--p, --policy Obtem a política do cpufreq em uso no momento *\n"
746
747#: utils/cpupower-info.c:26
748#, c-format
749msgid ""
750" -s, --sched-smt Gets the kernel's thread sibling scheduler policy.\n"
751msgstr ""
752
753#: utils/cpupower-info.c:28
754#, c-format
755msgid ""
756"\n"
757"Passing no option will show all info, by default only on core 0\n"
758msgstr ""
759
760#: utils/cpupower-info.c:102
761#, c-format
762msgid "System's multi core scheduler setting: "
763msgstr ""
764
765#. if sysfs file is missing it's: errno == ENOENT
766#: utils/cpupower-info.c:105 utils/cpupower-info.c:114
767#, c-format
768msgid "not supported\n"
769msgstr ""
770
771#: utils/cpupower-info.c:111
772#, c-format
773msgid "System's thread sibling scheduler setting: "
774msgstr ""
775
776#: utils/cpupower-info.c:126
777#, c-format
778msgid "Intel's performance bias setting needs root privileges\n"
779msgstr ""
780
781#: utils/cpupower-info.c:128
782#, c-format
783msgid "System does not support Intel's performance bias setting\n"
784msgstr ""
785
786#: utils/cpupower-info.c:147
787#, c-format
788msgid "Could not read perf-bias value\n"
789msgstr ""
790
791#: utils/cpupower-info.c:150
792#, c-format
793msgid "perf-bias: %d\n"
794msgstr ""
795
796#: utils/cpuidle-info.c:28
797#, fuzzy, c-format
798msgid "Analyzing CPU %d:\n"
799msgstr "analisando o CPU %d:\n"
800
801#: utils/cpuidle-info.c:32
802#, c-format
803msgid "CPU %u: No idle states\n"
804msgstr ""
805
806#: utils/cpuidle-info.c:36
807#, c-format
808msgid "CPU %u: Can't read idle state info\n"
809msgstr ""
810
811#: utils/cpuidle-info.c:41
812#, c-format
813msgid "Could not determine max idle state %u\n"
814msgstr ""
815
816#: utils/cpuidle-info.c:46
817#, c-format
818msgid "Number of idle states: %d\n"
819msgstr ""
820
821#: utils/cpuidle-info.c:48
822#, fuzzy, c-format
823msgid "Available idle states:"
824msgstr " níveis de frequência disponíveis: "
825
826#: utils/cpuidle-info.c:71
827#, c-format
828msgid "Flags/Description: %s\n"
829msgstr ""
830
831#: utils/cpuidle-info.c:74
832#, c-format
833msgid "Latency: %lu\n"
834msgstr ""
835
836#: utils/cpuidle-info.c:76
837#, c-format
838msgid "Usage: %lu\n"
839msgstr ""
840
841#: utils/cpuidle-info.c:78
842#, c-format
843msgid "Duration: %llu\n"
844msgstr ""
845
846#: utils/cpuidle-info.c:90
847#, c-format
848msgid "Could not determine cpuidle driver\n"
849msgstr ""
850
851#: utils/cpuidle-info.c:94
852#, fuzzy, c-format
853msgid "CPUidle driver: %s\n"
854msgstr " driver: %s\n"
855
856#: utils/cpuidle-info.c:99
857#, c-format
858msgid "Could not determine cpuidle governor\n"
859msgstr ""
860
861#: utils/cpuidle-info.c:103
862#, c-format
863msgid "CPUidle governor: %s\n"
864msgstr ""
865
866#: utils/cpuidle-info.c:122
867#, c-format
868msgid "CPU %u: Can't read C-state info\n"
869msgstr ""
870
871#. printf("Cstates: %d\n", cstates);
872#: utils/cpuidle-info.c:127
873#, c-format
874msgid "active state: C0\n"
875msgstr ""
876
877#: utils/cpuidle-info.c:128
878#, c-format
879msgid "max_cstate: C%u\n"
880msgstr ""
881
882#: utils/cpuidle-info.c:129
883#, fuzzy, c-format
884msgid "maximum allowed latency: %lu usec\n"
885msgstr " maior latência de transição: "
886
887#: utils/cpuidle-info.c:130
888#, c-format
889msgid "states:\t\n"
890msgstr ""
891
892#: utils/cpuidle-info.c:132
893#, c-format
894msgid " C%d: type[C%d] "
895msgstr ""
896
897#: utils/cpuidle-info.c:134
898#, c-format
899msgid "promotion[--] demotion[--] "
900msgstr ""
901
902#: utils/cpuidle-info.c:135
903#, c-format
904msgid "latency[%03lu] "
905msgstr ""
906
907#: utils/cpuidle-info.c:137
908#, c-format
909msgid "usage[%08lu] "
910msgstr ""
911
912#: utils/cpuidle-info.c:139
913#, c-format
914msgid "duration[%020Lu] \n"
915msgstr ""
916
917#: utils/cpuidle-info.c:147
918#, fuzzy, c-format
919msgid "Usage: cpupower idleinfo [options]\n"
920msgstr "Uso: cpufreq-info [opções]\n"
921
922#: utils/cpuidle-info.c:149
923#, fuzzy, c-format
924msgid " -s, --silent Only show general C-state information\n"
925msgstr " -e, --debug Mostra informação de debug\n"
926
927#: utils/cpuidle-info.c:150
928#, fuzzy, c-format
929msgid ""
930" -o, --proc Prints out information like provided by the /proc/"
931"acpi/processor/*/power\n"
932" interface in older kernels\n"
933msgstr ""
934" -o, --proc Mostra informação do tipo provida pela interface /"
935"proc/cpufreq\n"
936" em kernels 2.4. e mais recentes 2.6\n"
937
938#: utils/cpuidle-info.c:209
939#, fuzzy, c-format
940msgid "You can't specify more than one output-specific argument\n"
941msgstr ""
942"Você não pode especificar mais do que um parâmetro --cpu e/ou\n"
943"mais do que um argumento de saída específico\n"
944
945#~ msgid ""
946#~ " -c CPU, --cpu CPU CPU number which information shall be determined "
947#~ "about\n"
948#~ msgstr ""
949#~ " -c CPU, --cpu CPU número do CPU sobre o qual as inforções devem ser "
950#~ "determinadas\n"
951
952#~ msgid ""
953#~ " -c CPU, --cpu CPU number of CPU where cpufreq settings shall be "
954#~ "modified\n"
955#~ msgstr ""
956#~ " -c CPU, --cpu CPU número do CPU onde as configurações do cpufreq "
957#~ "vão ser modificadas\n"
diff --git a/tools/power/cpupower/utils/builtin.h b/tools/power/cpupower/utils/builtin.h
new file mode 100644
index 00000000000..c10496fbe3c
--- /dev/null
+++ b/tools/power/cpupower/utils/builtin.h
@@ -0,0 +1,11 @@
1#ifndef BUILTIN_H
2#define BUILTIN_H
3
4extern int cmd_set(int argc, const char **argv);
5extern int cmd_info(int argc, const char **argv);
6extern int cmd_freq_set(int argc, const char **argv);
7extern int cmd_freq_info(int argc, const char **argv);
8extern int cmd_idle_info(int argc, const char **argv);
9extern int cmd_monitor(int argc, const char **argv);
10
11#endif
diff --git a/tools/power/cpupower/utils/cpufreq-info.c b/tools/power/cpupower/utils/cpufreq-info.c
new file mode 100644
index 00000000000..28953c9a7bd
--- /dev/null
+++ b/tools/power/cpupower/utils/cpufreq-info.c
@@ -0,0 +1,668 @@
1/*
2 * (C) 2004-2009 Dominik Brodowski <linux@dominikbrodowski.de>
3 *
4 * Licensed under the terms of the GNU GPL License version 2.
5 */
6
7
8#include <unistd.h>
9#include <stdio.h>
10#include <errno.h>
11#include <stdlib.h>
12#include <string.h>
13
14#include <getopt.h>
15
16#include "cpufreq.h"
17#include "helpers/helpers.h"
18#include "helpers/bitmask.h"
19
20#define LINE_LEN 10
21
22static unsigned int count_cpus(void)
23{
24 FILE *fp;
25 char value[LINE_LEN];
26 unsigned int ret = 0;
27 unsigned int cpunr = 0;
28
29 fp = fopen("/proc/stat", "r");
30 if (!fp) {
31 printf(_("Couldn't count the number of CPUs (%s: %s), assuming 1\n"), "/proc/stat", strerror(errno));
32 return 1;
33 }
34
35 while (!feof(fp)) {
36 if (!fgets(value, LINE_LEN, fp))
37 continue;
38 value[LINE_LEN - 1] = '\0';
39 if (strlen(value) < (LINE_LEN - 2))
40 continue;
41 if (strstr(value, "cpu "))
42 continue;
43 if (sscanf(value, "cpu%d ", &cpunr) != 1)
44 continue;
45 if (cpunr > ret)
46 ret = cpunr;
47 }
48 fclose(fp);
49
50 /* cpu count starts from 0, on error return 1 (UP) */
51 return ret + 1;
52}
53
54
55static void proc_cpufreq_output(void)
56{
57 unsigned int cpu, nr_cpus;
58 struct cpufreq_policy *policy;
59 unsigned int min_pctg = 0;
60 unsigned int max_pctg = 0;
61 unsigned long min, max;
62
63 printf(_(" minimum CPU frequency - maximum CPU frequency - governor\n"));
64
65 nr_cpus = count_cpus();
66 for (cpu = 0; cpu < nr_cpus; cpu++) {
67 policy = cpufreq_get_policy(cpu);
68 if (!policy)
69 continue;
70
71 if (cpufreq_get_hardware_limits(cpu, &min, &max)) {
72 max = 0;
73 } else {
74 min_pctg = (policy->min * 100) / max;
75 max_pctg = (policy->max * 100) / max;
76 }
77 printf("CPU%3d %9lu kHz (%3d %%) - %9lu kHz (%3d %%) - %s\n",
78 cpu , policy->min, max ? min_pctg : 0, policy->max,
79 max ? max_pctg : 0, policy->governor);
80
81 cpufreq_put_policy(policy);
82 }
83}
84
85static void print_speed(unsigned long speed)
86{
87 unsigned long tmp;
88
89 if (speed > 1000000) {
90 tmp = speed % 10000;
91 if (tmp >= 5000)
92 speed += 10000;
93 printf("%u.%02u GHz", ((unsigned int) speed/1000000),
94 ((unsigned int) (speed%1000000)/10000));
95 } else if (speed > 100000) {
96 tmp = speed % 1000;
97 if (tmp >= 500)
98 speed += 1000;
99 printf("%u MHz", ((unsigned int) speed / 1000));
100 } else if (speed > 1000) {
101 tmp = speed % 100;
102 if (tmp >= 50)
103 speed += 100;
104 printf("%u.%01u MHz", ((unsigned int) speed/1000),
105 ((unsigned int) (speed%1000)/100));
106 } else
107 printf("%lu kHz", speed);
108
109 return;
110}
111
112static void print_duration(unsigned long duration)
113{
114 unsigned long tmp;
115
116 if (duration > 1000000) {
117 tmp = duration % 10000;
118 if (tmp >= 5000)
119 duration += 10000;
120 printf("%u.%02u ms", ((unsigned int) duration/1000000),
121 ((unsigned int) (duration%1000000)/10000));
122 } else if (duration > 100000) {
123 tmp = duration % 1000;
124 if (tmp >= 500)
125 duration += 1000;
126 printf("%u us", ((unsigned int) duration / 1000));
127 } else if (duration > 1000) {
128 tmp = duration % 100;
129 if (tmp >= 50)
130 duration += 100;
131 printf("%u.%01u us", ((unsigned int) duration/1000),
132 ((unsigned int) (duration%1000)/100));
133 } else
134 printf("%lu ns", duration);
135
136 return;
137}
138
139/* --boost / -b */
140
141static int get_boost_mode(unsigned int cpu)
142{
143 int support, active, b_states = 0, ret, pstate_no, i;
144 /* ToDo: Make this more global */
145 unsigned long pstates[MAX_HW_PSTATES] = {0,};
146
147 if (cpupower_cpu_info.vendor != X86_VENDOR_AMD &&
148 cpupower_cpu_info.vendor != X86_VENDOR_INTEL)
149 return 0;
150
151 ret = cpufreq_has_boost_support(cpu, &support, &active, &b_states);
152 if (ret) {
153 printf(_("Error while evaluating Boost Capabilities"
154 " on CPU %d -- are you root?\n"), cpu);
155 return ret;
156 }
157 /* P state changes via MSR are identified via cpuid 80000007
158 on Intel and AMD, but we assume boost capable machines can do that
159 if (cpuid_eax(0x80000000) >= 0x80000007
160 && (cpuid_edx(0x80000007) & (1 << 7)))
161 */
162
163 printf(_(" boost state support:\n"));
164
165 printf(_(" Supported: %s\n"), support ? _("yes") : _("no"));
166 printf(_(" Active: %s\n"), active ? _("yes") : _("no"));
167
168 if (cpupower_cpu_info.vendor == X86_VENDOR_AMD &&
169 cpupower_cpu_info.family >= 0x10) {
170 ret = decode_pstates(cpu, cpupower_cpu_info.family, b_states,
171 pstates, &pstate_no);
172 if (ret)
173 return ret;
174
175 printf(_(" Boost States: %d\n"), b_states);
176 printf(_(" Total States: %d\n"), pstate_no);
177 for (i = 0; i < pstate_no; i++) {
178 if (i < b_states)
179 printf(_(" Pstate-Pb%d: %luMHz (boost state)"
180 "\n"), i, pstates[i]);
181 else
182 printf(_(" Pstate-P%d: %luMHz\n"),
183 i - b_states, pstates[i]);
184 }
185 } else if (cpupower_cpu_info.caps & CPUPOWER_CAP_HAS_TURBO_RATIO) {
186 double bclk;
187 unsigned long long intel_turbo_ratio = 0;
188 unsigned int ratio;
189
190 /* Any way to autodetect this ? */
191 if (cpupower_cpu_info.caps & CPUPOWER_CAP_IS_SNB)
192 bclk = 100.00;
193 else
194 bclk = 133.33;
195 intel_turbo_ratio = msr_intel_get_turbo_ratio(cpu);
196 dprint (" Ratio: 0x%llx - bclk: %f\n",
197 intel_turbo_ratio, bclk);
198
199 ratio = (intel_turbo_ratio >> 24) & 0xFF;
200 if (ratio)
201 printf(_(" %.0f MHz max turbo 4 active cores\n"),
202 ratio * bclk);
203
204 ratio = (intel_turbo_ratio >> 16) & 0xFF;
205 if (ratio)
206 printf(_(" %.0f MHz max turbo 3 active cores\n"),
207 ratio * bclk);
208
209 ratio = (intel_turbo_ratio >> 8) & 0xFF;
210 if (ratio)
211 printf(_(" %.0f MHz max turbo 2 active cores\n"),
212 ratio * bclk);
213
214 ratio = (intel_turbo_ratio >> 0) & 0xFF;
215 if (ratio)
216 printf(_(" %.0f MHz max turbo 1 active cores\n"),
217 ratio * bclk);
218 }
219 return 0;
220}
221
222static void debug_output_one(unsigned int cpu)
223{
224 char *driver;
225 struct cpufreq_affected_cpus *cpus;
226 struct cpufreq_available_frequencies *freqs;
227 unsigned long min, max, freq_kernel, freq_hardware;
228 unsigned long total_trans, latency;
229 unsigned long long total_time;
230 struct cpufreq_policy *policy;
231 struct cpufreq_available_governors *governors;
232 struct cpufreq_stats *stats;
233
234 if (cpufreq_cpu_exists(cpu))
235 return;
236
237 freq_kernel = cpufreq_get_freq_kernel(cpu);
238 freq_hardware = cpufreq_get_freq_hardware(cpu);
239
240 driver = cpufreq_get_driver(cpu);
241 if (!driver) {
242 printf(_(" no or unknown cpufreq driver is active on this CPU\n"));
243 } else {
244 printf(_(" driver: %s\n"), driver);
245 cpufreq_put_driver(driver);
246 }
247
248 cpus = cpufreq_get_related_cpus(cpu);
249 if (cpus) {
250 printf(_(" CPUs which run at the same hardware frequency: "));
251 while (cpus->next) {
252 printf("%d ", cpus->cpu);
253 cpus = cpus->next;
254 }
255 printf("%d\n", cpus->cpu);
256 cpufreq_put_related_cpus(cpus);
257 }
258
259 cpus = cpufreq_get_affected_cpus(cpu);
260 if (cpus) {
261 printf(_(" CPUs which need to have their frequency coordinated by software: "));
262 while (cpus->next) {
263 printf("%d ", cpus->cpu);
264 cpus = cpus->next;
265 }
266 printf("%d\n", cpus->cpu);
267 cpufreq_put_affected_cpus(cpus);
268 }
269
270 latency = cpufreq_get_transition_latency(cpu);
271 if (latency) {
272 printf(_(" maximum transition latency: "));
273 print_duration(latency);
274 printf(".\n");
275 }
276
277 if (!(cpufreq_get_hardware_limits(cpu, &min, &max))) {
278 printf(_(" hardware limits: "));
279 print_speed(min);
280 printf(" - ");
281 print_speed(max);
282 printf("\n");
283 }
284
285 freqs = cpufreq_get_available_frequencies(cpu);
286 if (freqs) {
287 printf(_(" available frequency steps: "));
288 while (freqs->next) {
289 print_speed(freqs->frequency);
290 printf(", ");
291 freqs = freqs->next;
292 }
293 print_speed(freqs->frequency);
294 printf("\n");
295 cpufreq_put_available_frequencies(freqs);
296 }
297
298 governors = cpufreq_get_available_governors(cpu);
299 if (governors) {
300 printf(_(" available cpufreq governors: "));
301 while (governors->next) {
302 printf("%s, ", governors->governor);
303 governors = governors->next;
304 }
305 printf("%s\n", governors->governor);
306 cpufreq_put_available_governors(governors);
307 }
308
309 policy = cpufreq_get_policy(cpu);
310 if (policy) {
311 printf(_(" current policy: frequency should be within "));
312 print_speed(policy->min);
313 printf(_(" and "));
314 print_speed(policy->max);
315
316 printf(".\n ");
317 printf(_("The governor \"%s\" may"
318 " decide which speed to use\n within this range.\n"),
319 policy->governor);
320 cpufreq_put_policy(policy);
321 }
322
323 if (freq_kernel || freq_hardware) {
324 printf(_(" current CPU frequency is "));
325 if (freq_hardware) {
326 print_speed(freq_hardware);
327 printf(_(" (asserted by call to hardware)"));
328 } else
329 print_speed(freq_kernel);
330 printf(".\n");
331 }
332 stats = cpufreq_get_stats(cpu, &total_time);
333 if (stats) {
334 printf(_(" cpufreq stats: "));
335 while (stats) {
336 print_speed(stats->frequency);
337 printf(":%.2f%%", (100.0 * stats->time_in_state) / total_time);
338 stats = stats->next;
339 if (stats)
340 printf(", ");
341 }
342 cpufreq_put_stats(stats);
343 total_trans = cpufreq_get_transitions(cpu);
344 if (total_trans)
345 printf(" (%lu)\n", total_trans);
346 else
347 printf("\n");
348 }
349 get_boost_mode(cpu);
350
351}
352
353/* --freq / -f */
354
355static int get_freq_kernel(unsigned int cpu, unsigned int human)
356{
357 unsigned long freq = cpufreq_get_freq_kernel(cpu);
358 if (!freq)
359 return -EINVAL;
360 if (human) {
361 print_speed(freq);
362 printf("\n");
363 } else
364 printf("%lu\n", freq);
365 return 0;
366}
367
368
369/* --hwfreq / -w */
370
371static int get_freq_hardware(unsigned int cpu, unsigned int human)
372{
373 unsigned long freq = cpufreq_get_freq_hardware(cpu);
374 if (!freq)
375 return -EINVAL;
376 if (human) {
377 print_speed(freq);
378 printf("\n");
379 } else
380 printf("%lu\n", freq);
381 return 0;
382}
383
384/* --hwlimits / -l */
385
386static int get_hardware_limits(unsigned int cpu)
387{
388 unsigned long min, max;
389 if (cpufreq_get_hardware_limits(cpu, &min, &max))
390 return -EINVAL;
391 printf("%lu %lu\n", min, max);
392 return 0;
393}
394
395/* --driver / -d */
396
397static int get_driver(unsigned int cpu)
398{
399 char *driver = cpufreq_get_driver(cpu);
400 if (!driver)
401 return -EINVAL;
402 printf("%s\n", driver);
403 cpufreq_put_driver(driver);
404 return 0;
405}
406
407/* --policy / -p */
408
409static int get_policy(unsigned int cpu)
410{
411 struct cpufreq_policy *policy = cpufreq_get_policy(cpu);
412 if (!policy)
413 return -EINVAL;
414 printf("%lu %lu %s\n", policy->min, policy->max, policy->governor);
415 cpufreq_put_policy(policy);
416 return 0;
417}
418
419/* --governors / -g */
420
421static int get_available_governors(unsigned int cpu)
422{
423 struct cpufreq_available_governors *governors =
424 cpufreq_get_available_governors(cpu);
425 if (!governors)
426 return -EINVAL;
427
428 while (governors->next) {
429 printf("%s ", governors->governor);
430 governors = governors->next;
431 }
432 printf("%s\n", governors->governor);
433 cpufreq_put_available_governors(governors);
434 return 0;
435}
436
437
438/* --affected-cpus / -a */
439
440static int get_affected_cpus(unsigned int cpu)
441{
442 struct cpufreq_affected_cpus *cpus = cpufreq_get_affected_cpus(cpu);
443 if (!cpus)
444 return -EINVAL;
445
446 while (cpus->next) {
447 printf("%d ", cpus->cpu);
448 cpus = cpus->next;
449 }
450 printf("%d\n", cpus->cpu);
451 cpufreq_put_affected_cpus(cpus);
452 return 0;
453}
454
455/* --related-cpus / -r */
456
457static int get_related_cpus(unsigned int cpu)
458{
459 struct cpufreq_affected_cpus *cpus = cpufreq_get_related_cpus(cpu);
460 if (!cpus)
461 return -EINVAL;
462
463 while (cpus->next) {
464 printf("%d ", cpus->cpu);
465 cpus = cpus->next;
466 }
467 printf("%d\n", cpus->cpu);
468 cpufreq_put_related_cpus(cpus);
469 return 0;
470}
471
472/* --stats / -s */
473
474static int get_freq_stats(unsigned int cpu, unsigned int human)
475{
476 unsigned long total_trans = cpufreq_get_transitions(cpu);
477 unsigned long long total_time;
478 struct cpufreq_stats *stats = cpufreq_get_stats(cpu, &total_time);
479 while (stats) {
480 if (human) {
481 print_speed(stats->frequency);
482 printf(":%.2f%%",
483 (100.0 * stats->time_in_state) / total_time);
484 } else
485 printf("%lu:%llu",
486 stats->frequency, stats->time_in_state);
487 stats = stats->next;
488 if (stats)
489 printf(", ");
490 }
491 cpufreq_put_stats(stats);
492 if (total_trans)
493 printf(" (%lu)\n", total_trans);
494 return 0;
495}
496
497/* --latency / -y */
498
499static int get_latency(unsigned int cpu, unsigned int human)
500{
501 unsigned long latency = cpufreq_get_transition_latency(cpu);
502 if (!latency)
503 return -EINVAL;
504
505 if (human) {
506 print_duration(latency);
507 printf("\n");
508 } else
509 printf("%lu\n", latency);
510 return 0;
511}
512
513static struct option info_opts[] = {
514 { .name = "debug", .has_arg = no_argument, .flag = NULL, .val = 'e'},
515 { .name = "boost", .has_arg = no_argument, .flag = NULL, .val = 'b'},
516 { .name = "freq", .has_arg = no_argument, .flag = NULL, .val = 'f'},
517 { .name = "hwfreq", .has_arg = no_argument, .flag = NULL, .val = 'w'},
518 { .name = "hwlimits", .has_arg = no_argument, .flag = NULL, .val = 'l'},
519 { .name = "driver", .has_arg = no_argument, .flag = NULL, .val = 'd'},
520 { .name = "policy", .has_arg = no_argument, .flag = NULL, .val = 'p'},
521 { .name = "governors", .has_arg = no_argument, .flag = NULL, .val = 'g'},
522 { .name = "related-cpus", .has_arg = no_argument, .flag = NULL, .val = 'r'},
523 { .name = "affected-cpus",.has_arg = no_argument, .flag = NULL, .val = 'a'},
524 { .name = "stats", .has_arg = no_argument, .flag = NULL, .val = 's'},
525 { .name = "latency", .has_arg = no_argument, .flag = NULL, .val = 'y'},
526 { .name = "proc", .has_arg = no_argument, .flag = NULL, .val = 'o'},
527 { .name = "human", .has_arg = no_argument, .flag = NULL, .val = 'm'},
528 { },
529};
530
531int cmd_freq_info(int argc, char **argv)
532{
533 extern char *optarg;
534 extern int optind, opterr, optopt;
535 int ret = 0, cont = 1;
536 unsigned int cpu = 0;
537 unsigned int human = 0;
538 int output_param = 0;
539
540 do {
541 ret = getopt_long(argc, argv, "oefwldpgrasmyb", info_opts, NULL);
542 switch (ret) {
543 case '?':
544 output_param = '?';
545 cont = 0;
546 break;
547 case -1:
548 cont = 0;
549 break;
550 case 'b':
551 case 'o':
552 case 'a':
553 case 'r':
554 case 'g':
555 case 'p':
556 case 'd':
557 case 'l':
558 case 'w':
559 case 'f':
560 case 'e':
561 case 's':
562 case 'y':
563 if (output_param) {
564 output_param = -1;
565 cont = 0;
566 break;
567 }
568 output_param = ret;
569 break;
570 case 'm':
571 if (human) {
572 output_param = -1;
573 cont = 0;
574 break;
575 }
576 human = 1;
577 break;
578 default:
579 fprintf(stderr, "invalid or unknown argument\n");
580 return EXIT_FAILURE;
581 }
582 } while (cont);
583
584 switch (output_param) {
585 case 'o':
586 if (!bitmask_isallclear(cpus_chosen)) {
587 printf(_("The argument passed to this tool can't be "
588 "combined with passing a --cpu argument\n"));
589 return -EINVAL;
590 }
591 break;
592 case 0:
593 output_param = 'e';
594 }
595
596 ret = 0;
597
598 /* Default is: show output of CPU 0 only */
599 if (bitmask_isallclear(cpus_chosen))
600 bitmask_setbit(cpus_chosen, 0);
601
602 switch (output_param) {
603 case -1:
604 printf(_("You can't specify more than one --cpu parameter and/or\n"
605 "more than one output-specific argument\n"));
606 return -EINVAL;
607 case '?':
608 printf(_("invalid or unknown argument\n"));
609 return -EINVAL;
610 case 'o':
611 proc_cpufreq_output();
612 return EXIT_SUCCESS;
613 }
614
615 for (cpu = bitmask_first(cpus_chosen);
616 cpu <= bitmask_last(cpus_chosen); cpu++) {
617
618 if (!bitmask_isbitset(cpus_chosen, cpu))
619 continue;
620 if (cpufreq_cpu_exists(cpu)) {
621 printf(_("couldn't analyze CPU %d as it doesn't seem to be present\n"), cpu);
622 continue;
623 }
624 printf(_("analyzing CPU %d:\n"), cpu);
625
626 switch (output_param) {
627 case 'b':
628 get_boost_mode(cpu);
629 break;
630 case 'e':
631 debug_output_one(cpu);
632 break;
633 case 'a':
634 ret = get_affected_cpus(cpu);
635 break;
636 case 'r':
637 ret = get_related_cpus(cpu);
638 break;
639 case 'g':
640 ret = get_available_governors(cpu);
641 break;
642 case 'p':
643 ret = get_policy(cpu);
644 break;
645 case 'd':
646 ret = get_driver(cpu);
647 break;
648 case 'l':
649 ret = get_hardware_limits(cpu);
650 break;
651 case 'w':
652 ret = get_freq_hardware(cpu, human);
653 break;
654 case 'f':
655 ret = get_freq_kernel(cpu, human);
656 break;
657 case 's':
658 ret = get_freq_stats(cpu, human);
659 break;
660 case 'y':
661 ret = get_latency(cpu, human);
662 break;
663 }
664 if (ret)
665 return ret;
666 }
667 return ret;
668}
diff --git a/tools/power/cpupower/utils/cpufreq-set.c b/tools/power/cpupower/utils/cpufreq-set.c
new file mode 100644
index 00000000000..dd1539eb8c6
--- /dev/null
+++ b/tools/power/cpupower/utils/cpufreq-set.c
@@ -0,0 +1,331 @@
1/*
2 * (C) 2004-2009 Dominik Brodowski <linux@dominikbrodowski.de>
3 *
4 * Licensed under the terms of the GNU GPL License version 2.
5 */
6
7
8#include <unistd.h>
9#include <stdio.h>
10#include <errno.h>
11#include <stdlib.h>
12#include <limits.h>
13#include <string.h>
14#include <ctype.h>
15
16#include <getopt.h>
17
18#include "cpufreq.h"
19#include "helpers/helpers.h"
20
21#define NORM_FREQ_LEN 32
22
23static struct option set_opts[] = {
24 { .name = "min", .has_arg = required_argument, .flag = NULL, .val = 'd'},
25 { .name = "max", .has_arg = required_argument, .flag = NULL, .val = 'u'},
26 { .name = "governor", .has_arg = required_argument, .flag = NULL, .val = 'g'},
27 { .name = "freq", .has_arg = required_argument, .flag = NULL, .val = 'f'},
28 { .name = "related", .has_arg = no_argument, .flag = NULL, .val='r'},
29 { },
30};
31
32static void print_error(void)
33{
34 printf(_("Error setting new values. Common errors:\n"
35 "- Do you have proper administration rights? (super-user?)\n"
36 "- Is the governor you requested available and modprobed?\n"
37 "- Trying to set an invalid policy?\n"
38 "- Trying to set a specific frequency, but userspace governor is not available,\n"
39 " for example because of hardware which cannot be set to a specific frequency\n"
40 " or because the userspace governor isn't loaded?\n"));
41};
42
43struct freq_units {
44 char *str_unit;
45 int power_of_ten;
46};
47
48const struct freq_units def_units[] = {
49 {"hz", -3},
50 {"khz", 0}, /* default */
51 {"mhz", 3},
52 {"ghz", 6},
53 {"thz", 9},
54 {NULL, 0}
55};
56
57static void print_unknown_arg(void)
58{
59 printf(_("invalid or unknown argument\n"));
60}
61
62static unsigned long string_to_frequency(const char *str)
63{
64 char normalized[NORM_FREQ_LEN];
65 const struct freq_units *unit;
66 const char *scan;
67 char *end;
68 unsigned long freq;
69 int power = 0, match_count = 0, i, cp, pad;
70
71 while (*str == '0')
72 str++;
73
74 for (scan = str; isdigit(*scan) || *scan == '.'; scan++) {
75 if (*scan == '.' && match_count == 0)
76 match_count = 1;
77 else if (*scan == '.' && match_count == 1)
78 return 0;
79 }
80
81 if (*scan) {
82 match_count = 0;
83 for (unit = def_units; unit->str_unit; unit++) {
84 for (i = 0;
85 scan[i] && tolower(scan[i]) == unit->str_unit[i];
86 ++i)
87 continue;
88 if (scan[i])
89 continue;
90 match_count++;
91 power = unit->power_of_ten;
92 }
93 if (match_count != 1)
94 return 0;
95 }
96
97 /* count the number of digits to be copied */
98 for (cp = 0; isdigit(str[cp]); cp++)
99 continue;
100
101 if (str[cp] == '.') {
102 while (power > -1 && isdigit(str[cp+1]))
103 cp++, power--;
104 }
105 if (power >= -1) /* not enough => pad */
106 pad = power + 1;
107 else /* to much => strip */
108 pad = 0, cp += power + 1;
109 /* check bounds */
110 if (cp <= 0 || cp + pad > NORM_FREQ_LEN - 1)
111 return 0;
112
113 /* copy digits */
114 for (i = 0; i < cp; i++, str++) {
115 if (*str == '.')
116 str++;
117 normalized[i] = *str;
118 }
119 /* and pad */
120 for (; i < cp + pad; i++)
121 normalized[i] = '0';
122
123 /* round up, down ? */
124 match_count = (normalized[i-1] >= '5');
125 /* and drop the decimal part */
126 normalized[i-1] = 0; /* cp > 0 && pad >= 0 ==> i > 0 */
127
128 /* final conversion (and applying rounding) */
129 errno = 0;
130 freq = strtoul(normalized, &end, 10);
131 if (errno)
132 return 0;
133 else {
134 if (match_count && freq != ULONG_MAX)
135 freq++;
136 return freq;
137 }
138}
139
140static int do_new_policy(unsigned int cpu, struct cpufreq_policy *new_pol)
141{
142 struct cpufreq_policy *cur_pol = cpufreq_get_policy(cpu);
143 int ret;
144
145 if (!cur_pol) {
146 printf(_("wrong, unknown or unhandled CPU?\n"));
147 return -EINVAL;
148 }
149
150 if (!new_pol->min)
151 new_pol->min = cur_pol->min;
152
153 if (!new_pol->max)
154 new_pol->max = cur_pol->max;
155
156 if (!new_pol->governor)
157 new_pol->governor = cur_pol->governor;
158
159 ret = cpufreq_set_policy(cpu, new_pol);
160
161 cpufreq_put_policy(cur_pol);
162
163 return ret;
164}
165
166
167static int do_one_cpu(unsigned int cpu, struct cpufreq_policy *new_pol,
168 unsigned long freq, unsigned int pc)
169{
170 switch (pc) {
171 case 0:
172 return cpufreq_set_frequency(cpu, freq);
173
174 case 1:
175 /* if only one value of a policy is to be changed, we can
176 * use a "fast path".
177 */
178 if (new_pol->min)
179 return cpufreq_modify_policy_min(cpu, new_pol->min);
180 else if (new_pol->max)
181 return cpufreq_modify_policy_max(cpu, new_pol->max);
182 else if (new_pol->governor)
183 return cpufreq_modify_policy_governor(cpu,
184 new_pol->governor);
185
186 default:
187 /* slow path */
188 return do_new_policy(cpu, new_pol);
189 }
190}
191
192int cmd_freq_set(int argc, char **argv)
193{
194 extern char *optarg;
195 extern int optind, opterr, optopt;
196 int ret = 0, cont = 1;
197 int double_parm = 0, related = 0, policychange = 0;
198 unsigned long freq = 0;
199 char gov[20];
200 unsigned int cpu;
201
202 struct cpufreq_policy new_pol = {
203 .min = 0,
204 .max = 0,
205 .governor = NULL,
206 };
207
208 /* parameter parsing */
209 do {
210 ret = getopt_long(argc, argv, "d:u:g:f:r", set_opts, NULL);
211 switch (ret) {
212 case '?':
213 print_unknown_arg();
214 return -EINVAL;
215 case -1:
216 cont = 0;
217 break;
218 case 'r':
219 if (related)
220 double_parm++;
221 related++;
222 break;
223 case 'd':
224 if (new_pol.min)
225 double_parm++;
226 policychange++;
227 new_pol.min = string_to_frequency(optarg);
228 if (new_pol.min == 0) {
229 print_unknown_arg();
230 return -EINVAL;
231 }
232 break;
233 case 'u':
234 if (new_pol.max)
235 double_parm++;
236 policychange++;
237 new_pol.max = string_to_frequency(optarg);
238 if (new_pol.max == 0) {
239 print_unknown_arg();
240 return -EINVAL;
241 }
242 break;
243 case 'f':
244 if (freq)
245 double_parm++;
246 freq = string_to_frequency(optarg);
247 if (freq == 0) {
248 print_unknown_arg();
249 return -EINVAL;
250 }
251 break;
252 case 'g':
253 if (new_pol.governor)
254 double_parm++;
255 policychange++;
256 if ((strlen(optarg) < 3) || (strlen(optarg) > 18)) {
257 print_unknown_arg();
258 return -EINVAL;
259 }
260 if ((sscanf(optarg, "%s", gov)) != 1) {
261 print_unknown_arg();
262 return -EINVAL;
263 }
264 new_pol.governor = gov;
265 break;
266 }
267 } while (cont);
268
269 /* parameter checking */
270 if (double_parm) {
271 printf("the same parameter was passed more than once\n");
272 return -EINVAL;
273 }
274
275 if (freq && policychange) {
276 printf(_("the -f/--freq parameter cannot be combined with -d/--min, -u/--max or\n"
277 "-g/--governor parameters\n"));
278 return -EINVAL;
279 }
280
281 if (!freq && !policychange) {
282 printf(_("At least one parameter out of -f/--freq, -d/--min, -u/--max, and\n"
283 "-g/--governor must be passed\n"));
284 return -EINVAL;
285 }
286
287 /* Default is: set all CPUs */
288 if (bitmask_isallclear(cpus_chosen))
289 bitmask_setall(cpus_chosen);
290
291 /* Also set frequency settings for related CPUs if -r is passed */
292 if (related) {
293 for (cpu = bitmask_first(cpus_chosen);
294 cpu <= bitmask_last(cpus_chosen); cpu++) {
295 struct cpufreq_affected_cpus *cpus;
296
297 if (!bitmask_isbitset(cpus_chosen, cpu) ||
298 cpufreq_cpu_exists(cpu))
299 continue;
300
301 cpus = cpufreq_get_related_cpus(cpu);
302 if (!cpus)
303 break;
304 while (cpus->next) {
305 bitmask_setbit(cpus_chosen, cpus->cpu);
306 cpus = cpus->next;
307 }
308 cpufreq_put_related_cpus(cpus);
309 }
310 }
311
312
313 /* loop over CPUs */
314 for (cpu = bitmask_first(cpus_chosen);
315 cpu <= bitmask_last(cpus_chosen); cpu++) {
316
317 if (!bitmask_isbitset(cpus_chosen, cpu) ||
318 cpufreq_cpu_exists(cpu))
319 continue;
320
321 printf(_("Setting cpu: %d\n"), cpu);
322 ret = do_one_cpu(cpu, &new_pol, freq, policychange);
323 if (ret)
324 break;
325 }
326
327 if (ret)
328 print_error();
329
330 return ret;
331}
diff --git a/tools/power/cpupower/utils/cpuidle-info.c b/tools/power/cpupower/utils/cpuidle-info.c
new file mode 100644
index 00000000000..b028267c137
--- /dev/null
+++ b/tools/power/cpupower/utils/cpuidle-info.c
@@ -0,0 +1,222 @@
1/*
2 * (C) 2004-2009 Dominik Brodowski <linux@dominikbrodowski.de>
3 * (C) 2010 Thomas Renninger <trenn@suse.de>
4 *
5 * Licensed under the terms of the GNU GPL License version 2.
6 */
7
8
9#include <unistd.h>
10#include <stdio.h>
11#include <errno.h>
12#include <stdlib.h>
13#include <string.h>
14#include <getopt.h>
15#include <cpufreq.h>
16
17#include "helpers/helpers.h"
18#include "helpers/sysfs.h"
19#include "helpers/bitmask.h"
20
21#define LINE_LEN 10
22
23static void cpuidle_cpu_output(unsigned int cpu, int verbose)
24{
25 int idlestates, idlestate;
26 char *tmp;
27
28 printf(_ ("Analyzing CPU %d:\n"), cpu);
29
30 idlestates = sysfs_get_idlestate_count(cpu);
31 if (idlestates == 0) {
32 printf(_("CPU %u: No idle states\n"), cpu);
33 return;
34 } else if (idlestates <= 0) {
35 printf(_("CPU %u: Can't read idle state info\n"), cpu);
36 return;
37 }
38 tmp = sysfs_get_idlestate_name(cpu, idlestates - 1);
39 if (!tmp) {
40 printf(_("Could not determine max idle state %u\n"),
41 idlestates - 1);
42 return;
43 }
44
45 printf(_("Number of idle states: %d\n"), idlestates);
46
47 printf(_("Available idle states:"));
48 for (idlestate = 1; idlestate < idlestates; idlestate++) {
49 tmp = sysfs_get_idlestate_name(cpu, idlestate);
50 if (!tmp)
51 continue;
52 printf(" %s", tmp);
53 free(tmp);
54 }
55 printf("\n");
56
57 if (!verbose)
58 return;
59
60 for (idlestate = 1; idlestate < idlestates; idlestate++) {
61 tmp = sysfs_get_idlestate_name(cpu, idlestate);
62 if (!tmp)
63 continue;
64 printf("%s:\n", tmp);
65 free(tmp);
66
67 tmp = sysfs_get_idlestate_desc(cpu, idlestate);
68 if (!tmp)
69 continue;
70 printf(_("Flags/Description: %s\n"), tmp);
71 free(tmp);
72
73 printf(_("Latency: %lu\n"),
74 sysfs_get_idlestate_latency(cpu, idlestate));
75 printf(_("Usage: %lu\n"),
76 sysfs_get_idlestate_usage(cpu, idlestate));
77 printf(_("Duration: %llu\n"),
78 sysfs_get_idlestate_time(cpu, idlestate));
79 }
80 printf("\n");
81}
82
83static void cpuidle_general_output(void)
84{
85 char *tmp;
86
87 tmp = sysfs_get_cpuidle_driver();
88 if (!tmp) {
89 printf(_("Could not determine cpuidle driver\n"));
90 return;
91 }
92
93 printf(_("CPUidle driver: %s\n"), tmp);
94 free(tmp);
95
96 tmp = sysfs_get_cpuidle_governor();
97 if (!tmp) {
98 printf(_("Could not determine cpuidle governor\n"));
99 return;
100 }
101
102 printf(_("CPUidle governor: %s\n"), tmp);
103 free(tmp);
104}
105
106static void proc_cpuidle_cpu_output(unsigned int cpu)
107{
108 long max_allowed_cstate = 2000000000;
109 int cstates, cstate;
110
111 cstates = sysfs_get_idlestate_count(cpu);
112 if (cstates == 0) {
113 /*
114 * Go on and print same useless info as you'd see with
115 * cat /proc/acpi/processor/../power
116 * printf(_("CPU %u: No C-states available\n"), cpu);
117 * return;
118 */
119 } else if (cstates <= 0) {
120 printf(_("CPU %u: Can't read C-state info\n"), cpu);
121 return;
122 }
123 /* printf("Cstates: %d\n", cstates); */
124
125 printf(_("active state: C0\n"));
126 printf(_("max_cstate: C%u\n"), cstates-1);
127 printf(_("maximum allowed latency: %lu usec\n"), max_allowed_cstate);
128 printf(_("states:\t\n"));
129 for (cstate = 1; cstate < cstates; cstate++) {
130 printf(_(" C%d: "
131 "type[C%d] "), cstate, cstate);
132 printf(_("promotion[--] demotion[--] "));
133 printf(_("latency[%03lu] "),
134 sysfs_get_idlestate_latency(cpu, cstate));
135 printf(_("usage[%08lu] "),
136 sysfs_get_idlestate_usage(cpu, cstate));
137 printf(_("duration[%020Lu] \n"),
138 sysfs_get_idlestate_time(cpu, cstate));
139 }
140}
141
142static struct option info_opts[] = {
143 { .name = "silent", .has_arg = no_argument, .flag = NULL, .val = 's'},
144 { .name = "proc", .has_arg = no_argument, .flag = NULL, .val = 'o'},
145 { },
146};
147
148static inline void cpuidle_exit(int fail)
149{
150 exit(EXIT_FAILURE);
151}
152
153int cmd_idle_info(int argc, char **argv)
154{
155 extern char *optarg;
156 extern int optind, opterr, optopt;
157 int ret = 0, cont = 1, output_param = 0, verbose = 1;
158 unsigned int cpu = 0;
159
160 do {
161 ret = getopt_long(argc, argv, "os", info_opts, NULL);
162 if (ret == -1)
163 break;
164 switch (ret) {
165 case '?':
166 output_param = '?';
167 cont = 0;
168 break;
169 case 's':
170 verbose = 0;
171 break;
172 case -1:
173 cont = 0;
174 break;
175 case 'o':
176 if (output_param) {
177 output_param = -1;
178 cont = 0;
179 break;
180 }
181 output_param = ret;
182 break;
183 }
184 } while (cont);
185
186 switch (output_param) {
187 case -1:
188 printf(_("You can't specify more than one "
189 "output-specific argument\n"));
190 cpuidle_exit(EXIT_FAILURE);
191 case '?':
192 printf(_("invalid or unknown argument\n"));
193 cpuidle_exit(EXIT_FAILURE);
194 }
195
196 /* Default is: show output of CPU 0 only */
197 if (bitmask_isallclear(cpus_chosen))
198 bitmask_setbit(cpus_chosen, 0);
199
200 if (output_param == 0)
201 cpuidle_general_output();
202
203 for (cpu = bitmask_first(cpus_chosen);
204 cpu <= bitmask_last(cpus_chosen); cpu++) {
205
206 if (!bitmask_isbitset(cpus_chosen, cpu) ||
207 cpufreq_cpu_exists(cpu))
208 continue;
209
210 switch (output_param) {
211
212 case 'o':
213 proc_cpuidle_cpu_output(cpu);
214 break;
215 case 0:
216 printf("\n");
217 cpuidle_cpu_output(cpu, verbose);
218 break;
219 }
220 }
221 return EXIT_SUCCESS;
222}
diff --git a/tools/power/cpupower/utils/cpupower-info.c b/tools/power/cpupower/utils/cpupower-info.c
new file mode 100644
index 00000000000..3f68632c28c
--- /dev/null
+++ b/tools/power/cpupower/utils/cpupower-info.c
@@ -0,0 +1,135 @@
1/*
2 * (C) 2011 Thomas Renninger <trenn@suse.de>, Novell Inc.
3 *
4 * Licensed under the terms of the GNU GPL License version 2.
5 */
6
7
8#include <unistd.h>
9#include <stdio.h>
10#include <stdlib.h>
11#include <errno.h>
12#include <string.h>
13#include <getopt.h>
14
15#include <cpufreq.h>
16#include "helpers/helpers.h"
17#include "helpers/sysfs.h"
18
19static struct option set_opts[] = {
20 { .name = "perf-bias", .has_arg = optional_argument, .flag = NULL, .val = 'b'},
21 { .name = "sched-mc", .has_arg = optional_argument, .flag = NULL, .val = 'm'},
22 { .name = "sched-smt", .has_arg = optional_argument, .flag = NULL, .val = 's'},
23 { },
24};
25
26static void print_wrong_arg_exit(void)
27{
28 printf(_("invalid or unknown argument\n"));
29 exit(EXIT_FAILURE);
30}
31
32int cmd_info(int argc, char **argv)
33{
34 extern char *optarg;
35 extern int optind, opterr, optopt;
36 unsigned int cpu;
37
38 union {
39 struct {
40 int sched_mc:1;
41 int sched_smt:1;
42 int perf_bias:1;
43 };
44 int params;
45 } params = {};
46 int ret = 0;
47
48 setlocale(LC_ALL, "");
49 textdomain(PACKAGE);
50
51 /* parameter parsing */
52 while ((ret = getopt_long(argc, argv, "msb", set_opts, NULL)) != -1) {
53 switch (ret) {
54 case 'b':
55 if (params.perf_bias)
56 print_wrong_arg_exit();
57 params.perf_bias = 1;
58 break;
59 case 'm':
60 if (params.sched_mc)
61 print_wrong_arg_exit();
62 params.sched_mc = 1;
63 break;
64 case 's':
65 if (params.sched_smt)
66 print_wrong_arg_exit();
67 params.sched_smt = 1;
68 break;
69 default:
70 print_wrong_arg_exit();
71 }
72 };
73
74 if (!params.params)
75 params.params = 0x7;
76
77 /* Default is: show output of CPU 0 only */
78 if (bitmask_isallclear(cpus_chosen))
79 bitmask_setbit(cpus_chosen, 0);
80
81 if (params.sched_mc) {
82 ret = sysfs_get_sched("mc");
83 printf(_("System's multi core scheduler setting: "));
84 if (ret < 0)
85 /* if sysfs file is missing it's: errno == ENOENT */
86 printf(_("not supported\n"));
87 else
88 printf("%d\n", ret);
89 }
90 if (params.sched_smt) {
91 ret = sysfs_get_sched("smt");
92 printf(_("System's thread sibling scheduler setting: "));
93 if (ret < 0)
94 /* if sysfs file is missing it's: errno == ENOENT */
95 printf(_("not supported\n"));
96 else
97 printf("%d\n", ret);
98 }
99
100 /* Add more per cpu options here */
101 if (!params.perf_bias)
102 return ret;
103
104 if (params.perf_bias) {
105 if (!run_as_root) {
106 params.perf_bias = 0;
107 printf(_("Intel's performance bias setting needs root privileges\n"));
108 } else if (!(cpupower_cpu_info.caps & CPUPOWER_CAP_PERF_BIAS)) {
109 printf(_("System does not support Intel's performance"
110 " bias setting\n"));
111 params.perf_bias = 0;
112 }
113 }
114
115 /* loop over CPUs */
116 for (cpu = bitmask_first(cpus_chosen);
117 cpu <= bitmask_last(cpus_chosen); cpu++) {
118
119 if (!bitmask_isbitset(cpus_chosen, cpu) ||
120 cpufreq_cpu_exists(cpu))
121 continue;
122
123 printf(_("analyzing CPU %d:\n"), cpu);
124
125 if (params.perf_bias) {
126 ret = msr_intel_get_perf_bias(cpu);
127 if (ret < 0) {
128 printf(_("Could not read perf-bias value\n"));
129 break;
130 } else
131 printf(_("perf-bias: %d\n"), ret);
132 }
133 }
134 return ret;
135}
diff --git a/tools/power/cpupower/utils/cpupower-set.c b/tools/power/cpupower/utils/cpupower-set.c
new file mode 100644
index 00000000000..dc4de376211
--- /dev/null
+++ b/tools/power/cpupower/utils/cpupower-set.c
@@ -0,0 +1,134 @@
1/*
2 * (C) 2011 Thomas Renninger <trenn@suse.de>, Novell Inc.
3 *
4 * Licensed under the terms of the GNU GPL License version 2.
5 */
6
7
8#include <unistd.h>
9#include <stdio.h>
10#include <stdlib.h>
11#include <errno.h>
12#include <string.h>
13#include <getopt.h>
14
15#include <cpufreq.h>
16#include "helpers/helpers.h"
17#include "helpers/sysfs.h"
18#include "helpers/bitmask.h"
19
20static struct option set_opts[] = {
21 { .name = "perf-bias", .has_arg = optional_argument, .flag = NULL, .val = 'b'},
22 { .name = "sched-mc", .has_arg = optional_argument, .flag = NULL, .val = 'm'},
23 { .name = "sched-smt", .has_arg = optional_argument, .flag = NULL, .val = 's'},
24 { },
25};
26
27static void print_wrong_arg_exit(void)
28{
29 printf(_("invalid or unknown argument\n"));
30 exit(EXIT_FAILURE);
31}
32
33int cmd_set(int argc, char **argv)
34{
35 extern char *optarg;
36 extern int optind, opterr, optopt;
37 unsigned int cpu;
38
39 union {
40 struct {
41 int sched_mc:1;
42 int sched_smt:1;
43 int perf_bias:1;
44 };
45 int params;
46 } params;
47 int sched_mc = 0, sched_smt = 0, perf_bias = 0;
48 int ret = 0;
49
50 setlocale(LC_ALL, "");
51 textdomain(PACKAGE);
52
53 params.params = 0;
54 /* parameter parsing */
55 while ((ret = getopt_long(argc, argv, "m:s:b:",
56 set_opts, NULL)) != -1) {
57 switch (ret) {
58 case 'b':
59 if (params.perf_bias)
60 print_wrong_arg_exit();
61 perf_bias = atoi(optarg);
62 if (perf_bias < 0 || perf_bias > 15) {
63 printf(_("--perf-bias param out "
64 "of range [0-%d]\n"), 15);
65 print_wrong_arg_exit();
66 }
67 params.perf_bias = 1;
68 break;
69 case 'm':
70 if (params.sched_mc)
71 print_wrong_arg_exit();
72 sched_mc = atoi(optarg);
73 if (sched_mc < 0 || sched_mc > 2) {
74 printf(_("--sched-mc param out "
75 "of range [0-%d]\n"), 2);
76 print_wrong_arg_exit();
77 }
78 params.sched_mc = 1;
79 break;
80 case 's':
81 if (params.sched_smt)
82 print_wrong_arg_exit();
83 sched_smt = atoi(optarg);
84 if (sched_smt < 0 || sched_smt > 2) {
85 printf(_("--sched-smt param out "
86 "of range [0-%d]\n"), 2);
87 print_wrong_arg_exit();
88 }
89 params.sched_smt = 1;
90 break;
91 default:
92 print_wrong_arg_exit();
93 }
94 };
95
96 if (!params.params)
97 print_wrong_arg_exit();
98
99 if (params.sched_mc) {
100 ret = sysfs_set_sched("mc", sched_mc);
101 if (ret)
102 fprintf(stderr, _("Error setting sched-mc %s\n"),
103 (ret == -ENODEV) ? "not supported" : "");
104 }
105 if (params.sched_smt) {
106 ret = sysfs_set_sched("smt", sched_smt);
107 if (ret)
108 fprintf(stderr, _("Error setting sched-smt %s\n"),
109 (ret == -ENODEV) ? "not supported" : "");
110 }
111
112 /* Default is: set all CPUs */
113 if (bitmask_isallclear(cpus_chosen))
114 bitmask_setall(cpus_chosen);
115
116 /* loop over CPUs */
117 for (cpu = bitmask_first(cpus_chosen);
118 cpu <= bitmask_last(cpus_chosen); cpu++) {
119
120 if (!bitmask_isbitset(cpus_chosen, cpu) ||
121 cpufreq_cpu_exists(cpu))
122 continue;
123
124 if (params.perf_bias) {
125 ret = msr_intel_set_perf_bias(cpu, perf_bias);
126 if (ret) {
127 fprintf(stderr, _("Error setting perf-bias "
128 "value on CPU %d\n"), cpu);
129 break;
130 }
131 }
132 }
133 return ret;
134}
diff --git a/tools/power/cpupower/utils/cpupower.c b/tools/power/cpupower/utils/cpupower.c
new file mode 100644
index 00000000000..52bee591c1c
--- /dev/null
+++ b/tools/power/cpupower/utils/cpupower.c
@@ -0,0 +1,214 @@
1/*
2 * (C) 2010,2011 Thomas Renninger <trenn@suse.de>, Novell Inc.
3 *
4 * Licensed under the terms of the GNU GPL License version 2.
5 *
6 * Ideas taken over from the perf userspace tool (included in the Linus
7 * kernel git repo): subcommand builtins and param parsing.
8 */
9
10#include <stdio.h>
11#include <stdlib.h>
12#include <string.h>
13#include <unistd.h>
14#include <errno.h>
15
16#include "builtin.h"
17#include "helpers/helpers.h"
18#include "helpers/bitmask.h"
19
20struct cmd_struct {
21 const char *cmd;
22 int (*main)(int, const char **);
23 int needs_root;
24};
25
26#define ARRAY_SIZE(x) (sizeof(x)/sizeof(x[0]))
27
28static int cmd_help(int argc, const char **argv);
29
30/* Global cpu_info object available for all binaries
31 * Info only retrieved from CPU 0
32 *
33 * Values will be zero/unknown on non X86 archs
34 */
35struct cpupower_cpu_info cpupower_cpu_info;
36int run_as_root;
37/* Affected cpus chosen by -c/--cpu param */
38struct bitmask *cpus_chosen;
39
40#ifdef DEBUG
41int be_verbose;
42#endif
43
44static void print_help(void);
45
46static struct cmd_struct commands[] = {
47 { "frequency-info", cmd_freq_info, 0 },
48 { "frequency-set", cmd_freq_set, 1 },
49 { "idle-info", cmd_idle_info, 0 },
50 { "set", cmd_set, 1 },
51 { "info", cmd_info, 0 },
52 { "monitor", cmd_monitor, 0 },
53 { "help", cmd_help, 0 },
54 /* { "bench", cmd_bench, 1 }, */
55};
56
57static void print_help(void)
58{
59 unsigned int i;
60
61#ifdef DEBUG
62 printf(_("Usage:\tcpupower [-d|--debug] [-c|--cpu cpulist ] <command> [<args>]\n"));
63#else
64 printf(_("Usage:\tcpupower [-c|--cpu cpulist ] <command> [<args>]\n"));
65#endif
66 printf(_("Supported commands are:\n"));
67 for (i = 0; i < ARRAY_SIZE(commands); i++)
68 printf("\t%s\n", commands[i].cmd);
69 printf(_("\nNot all commands can make use of the -c cpulist option.\n"));
70 printf(_("\nUse 'cpupower help <command>' for getting help for above commands.\n"));
71}
72
73static int print_man_page(const char *subpage)
74{
75 int len;
76 char *page;
77
78 len = 10; /* enough for "cpupower-" */
79 if (subpage != NULL)
80 len += strlen(subpage);
81
82 page = malloc(len);
83 if (!page)
84 return -ENOMEM;
85
86 sprintf(page, "cpupower");
87 if ((subpage != NULL) && strcmp(subpage, "help")) {
88 strcat(page, "-");
89 strcat(page, subpage);
90 }
91
92 execlp("man", "man", page, NULL);
93
94 /* should not be reached */
95 return -EINVAL;
96}
97
98static int cmd_help(int argc, const char **argv)
99{
100 if (argc > 1) {
101 print_man_page(argv[1]); /* exits within execlp() */
102 return EXIT_FAILURE;
103 }
104
105 print_help();
106 return EXIT_SUCCESS;
107}
108
109static void print_version(void)
110{
111 printf(PACKAGE " " VERSION "\n");
112 printf(_("Report errors and bugs to %s, please.\n"), PACKAGE_BUGREPORT);
113}
114
115static void handle_options(int *argc, const char ***argv)
116{
117 int ret, x, new_argc = 0;
118
119 if (*argc < 1)
120 return;
121
122 for (x = 0; x < *argc && ((*argv)[x])[0] == '-'; x++) {
123 const char *param = (*argv)[x];
124 if (!strcmp(param, "-h") || !strcmp(param, "--help")) {
125 print_help();
126 exit(EXIT_SUCCESS);
127 } else if (!strcmp(param, "-c") || !strcmp(param, "--cpu")) {
128 if (*argc < 2) {
129 print_help();
130 exit(EXIT_FAILURE);
131 }
132 if (!strcmp((*argv)[x+1], "all"))
133 bitmask_setall(cpus_chosen);
134 else {
135 ret = bitmask_parselist(
136 (*argv)[x+1], cpus_chosen);
137 if (ret < 0) {
138 fprintf(stderr, _("Error parsing cpu "
139 "list\n"));
140 exit(EXIT_FAILURE);
141 }
142 }
143 x += 1;
144 /* Cut out param: cpupower -c 1 info -> cpupower info */
145 new_argc += 2;
146 continue;
147 } else if (!strcmp(param, "-v") ||
148 !strcmp(param, "--version")) {
149 print_version();
150 exit(EXIT_SUCCESS);
151#ifdef DEBUG
152 } else if (!strcmp(param, "-d") || !strcmp(param, "--debug")) {
153 be_verbose = 1;
154 new_argc++;
155 continue;
156#endif
157 } else {
158 fprintf(stderr, "Unknown option: %s\n", param);
159 print_help();
160 exit(EXIT_FAILURE);
161 }
162 }
163 *argc -= new_argc;
164 *argv += new_argc;
165}
166
167int main(int argc, const char *argv[])
168{
169 const char *cmd;
170 unsigned int i, ret;
171
172 cpus_chosen = bitmask_alloc(sysconf(_SC_NPROCESSORS_CONF));
173
174 argc--;
175 argv += 1;
176
177 handle_options(&argc, &argv);
178
179 cmd = argv[0];
180
181 if (argc < 1) {
182 print_help();
183 return EXIT_FAILURE;
184 }
185
186 setlocale(LC_ALL, "");
187 textdomain(PACKAGE);
188
189 /* Turn "perf cmd --help" into "perf help cmd" */
190 if (argc > 1 && !strcmp(argv[1], "--help")) {
191 argv[1] = argv[0];
192 argv[0] = cmd = "help";
193 }
194
195 get_cpu_info(0, &cpupower_cpu_info);
196 run_as_root = !getuid();
197
198 for (i = 0; i < ARRAY_SIZE(commands); i++) {
199 struct cmd_struct *p = commands + i;
200 if (strcmp(p->cmd, cmd))
201 continue;
202 if (!run_as_root && p->needs_root) {
203 fprintf(stderr, _("Subcommand %s needs root "
204 "privileges\n"), cmd);
205 return EXIT_FAILURE;
206 }
207 ret = p->main(argc, argv);
208 if (cpus_chosen)
209 bitmask_free(cpus_chosen);
210 return ret;
211 }
212 print_help();
213 return EXIT_FAILURE;
214}
diff --git a/tools/power/cpupower/utils/helpers/amd.c b/tools/power/cpupower/utils/helpers/amd.c
new file mode 100644
index 00000000000..87d5605bdda
--- /dev/null
+++ b/tools/power/cpupower/utils/helpers/amd.c
@@ -0,0 +1,137 @@
1#if defined(__i386__) || defined(__x86_64__)
2#include <unistd.h>
3#include <errno.h>
4#include <stdio.h>
5#include <stdint.h>
6
7#include <pci/pci.h>
8
9#include "helpers/helpers.h"
10
11#define MSR_AMD_PSTATE_STATUS 0xc0010063
12#define MSR_AMD_PSTATE 0xc0010064
13#define MSR_AMD_PSTATE_LIMIT 0xc0010061
14
15union msr_pstate {
16 struct {
17 unsigned fid:6;
18 unsigned did:3;
19 unsigned vid:7;
20 unsigned res1:6;
21 unsigned nbdid:1;
22 unsigned res2:2;
23 unsigned nbvid:7;
24 unsigned iddval:8;
25 unsigned idddiv:2;
26 unsigned res3:21;
27 unsigned en:1;
28 } bits;
29 unsigned long long val;
30};
31
32static int get_did(int family, union msr_pstate pstate)
33{
34 int t;
35
36 if (family == 0x12)
37 t = pstate.val & 0xf;
38 else
39 t = pstate.bits.did;
40
41 return t;
42}
43
44static int get_cof(int family, union msr_pstate pstate)
45{
46 int t;
47 int fid, did;
48
49 did = get_did(family, pstate);
50
51 t = 0x10;
52 fid = pstate.bits.fid;
53 if (family == 0x11)
54 t = 0x8;
55
56 return (100 * (fid + t)) >> did;
57}
58
59/* Needs:
60 * cpu -> the cpu that gets evaluated
61 * cpu_family -> The cpu's family (0x10, 0x12,...)
62 * boots_states -> how much boost states the machines support
63 *
64 * Fills up:
65 * pstates -> a pointer to an array of size MAX_HW_PSTATES
66 * must be initialized with zeros.
67 * All available HW pstates (including boost states)
68 * no -> amount of pstates above array got filled up with
69 *
70 * returns zero on success, -1 on failure
71 */
72int decode_pstates(unsigned int cpu, unsigned int cpu_family,
73 int boost_states, unsigned long *pstates, int *no)
74{
75 int i, psmax, pscur;
76 union msr_pstate pstate;
77 unsigned long long val;
78
79 /* Only read out frequencies from HW when CPU might be boostable
80 to keep the code as short and clean as possible.
81 Otherwise frequencies are exported via ACPI tables.
82 */
83 if (cpu_family < 0x10 || cpu_family == 0x14)
84 return -1;
85
86 if (read_msr(cpu, MSR_AMD_PSTATE_LIMIT, &val))
87 return -1;
88
89 psmax = (val >> 4) & 0x7;
90
91 if (read_msr(cpu, MSR_AMD_PSTATE_STATUS, &val))
92 return -1;
93
94 pscur = val & 0x7;
95
96 pscur += boost_states;
97 psmax += boost_states;
98 for (i = 0; i <= psmax; i++) {
99 if (i >= MAX_HW_PSTATES) {
100 fprintf(stderr, "HW pstates [%d] exceeding max [%d]\n",
101 psmax, MAX_HW_PSTATES);
102 return -1;
103 }
104 if (read_msr(cpu, MSR_AMD_PSTATE + i, &pstate.val))
105 return -1;
106 pstates[i] = get_cof(cpu_family, pstate);
107 }
108 *no = i;
109 return 0;
110}
111
112int amd_pci_get_num_boost_states(int *active, int *states)
113{
114 struct pci_access *pci_acc;
115 int vendor_id = 0x1022;
116 int boost_dev_ids[4] = {0x1204, 0x1604, 0x1704, 0};
117 struct pci_dev *device;
118 uint8_t val = 0;
119
120 *active = *states = 0;
121
122 device = pci_acc_init(&pci_acc, vendor_id, boost_dev_ids);
123
124 if (device == NULL)
125 return -ENODEV;
126
127 val = pci_read_byte(device, 0x15c);
128 if (val & 3)
129 *active = 1;
130 else
131 *active = 0;
132 *states = (val >> 2) & 7;
133
134 pci_cleanup(pci_acc);
135 return 0;
136}
137#endif /* defined(__i386__) || defined(__x86_64__) */
diff --git a/tools/power/cpupower/utils/helpers/bitmask.c b/tools/power/cpupower/utils/helpers/bitmask.c
new file mode 100644
index 00000000000..5c074c60f90
--- /dev/null
+++ b/tools/power/cpupower/utils/helpers/bitmask.c
@@ -0,0 +1,292 @@
1#include <stdio.h>
2#include <stdlib.h>
3#include <string.h>
4
5#include <helpers/bitmask.h>
6
7/* How many bits in an unsigned long */
8#define bitsperlong (8 * sizeof(unsigned long))
9
10/* howmany(a,b) : how many elements of size b needed to hold all of a */
11#define howmany(x, y) (((x)+((y)-1))/(y))
12
13/* How many longs in mask of n bits */
14#define longsperbits(n) howmany(n, bitsperlong)
15
16#define max(a, b) ((a) > (b) ? (a) : (b))
17
18/*
19 * Allocate and free `struct bitmask *`
20 */
21
22/* Allocate a new `struct bitmask` with a size of n bits */
23struct bitmask *bitmask_alloc(unsigned int n)
24{
25 struct bitmask *bmp;
26
27 bmp = malloc(sizeof(*bmp));
28 if (bmp == 0)
29 return 0;
30 bmp->size = n;
31 bmp->maskp = calloc(longsperbits(n), sizeof(unsigned long));
32 if (bmp->maskp == 0) {
33 free(bmp);
34 return 0;
35 }
36 return bmp;
37}
38
39/* Free `struct bitmask` */
40void bitmask_free(struct bitmask *bmp)
41{
42 if (bmp == 0)
43 return;
44 free(bmp->maskp);
45 bmp->maskp = (unsigned long *)0xdeadcdef; /* double free tripwire */
46 free(bmp);
47}
48
49/*
50 * The routines _getbit() and _setbit() are the only
51 * routines that actually understand the layout of bmp->maskp[].
52 *
53 * On little endian architectures, this could simply be an array of
54 * bytes. But the kernel layout of bitmasks _is_ visible to userspace
55 * via the sched_(set/get)affinity calls in Linux 2.6, and on big
56 * endian architectures, it is painfully obvious that this is an
57 * array of unsigned longs.
58 */
59
60/* Return the value (0 or 1) of bit n in bitmask bmp */
61static unsigned int _getbit(const struct bitmask *bmp, unsigned int n)
62{
63 if (n < bmp->size)
64 return (bmp->maskp[n/bitsperlong] >> (n % bitsperlong)) & 1;
65 else
66 return 0;
67}
68
69/* Set bit n in bitmask bmp to value v (0 or 1) */
70static void _setbit(struct bitmask *bmp, unsigned int n, unsigned int v)
71{
72 if (n < bmp->size) {
73 if (v)
74 bmp->maskp[n/bitsperlong] |= 1UL << (n % bitsperlong);
75 else
76 bmp->maskp[n/bitsperlong] &=
77 ~(1UL << (n % bitsperlong));
78 }
79}
80
81/*
82 * When parsing bitmask lists, only allow numbers, separated by one
83 * of the allowed next characters.
84 *
85 * The parameter 'sret' is the return from a sscanf "%u%c". It is
86 * -1 if the sscanf input string was empty. It is 0 if the first
87 * character in the sscanf input string was not a decimal number.
88 * It is 1 if the unsigned number matching the "%u" was the end of the
89 * input string. It is 2 if one or more additional characters followed
90 * the matched unsigned number. If it is 2, then 'nextc' is the first
91 * character following the number. The parameter 'ok_next_chars'
92 * is the nul-terminated list of allowed next characters.
93 *
94 * The mask term just scanned was ok if and only if either the numbers
95 * matching the %u were all of the input or if the next character in
96 * the input past the numbers was one of the allowed next characters.
97 */
98static int scan_was_ok(int sret, char nextc, const char *ok_next_chars)
99{
100 return sret == 1 ||
101 (sret == 2 && strchr(ok_next_chars, nextc) != NULL);
102}
103
104static const char *nexttoken(const char *q, int sep)
105{
106 if (q)
107 q = strchr(q, sep);
108 if (q)
109 q++;
110 return q;
111}
112
113/* Set a single bit i in bitmask */
114struct bitmask *bitmask_setbit(struct bitmask *bmp, unsigned int i)
115{
116 _setbit(bmp, i, 1);
117 return bmp;
118}
119
120/* Set all bits in bitmask: bmp = ~0 */
121struct bitmask *bitmask_setall(struct bitmask *bmp)
122{
123 unsigned int i;
124 for (i = 0; i < bmp->size; i++)
125 _setbit(bmp, i, 1);
126 return bmp;
127}
128
129/* Clear all bits in bitmask: bmp = 0 */
130struct bitmask *bitmask_clearall(struct bitmask *bmp)
131{
132 unsigned int i;
133 for (i = 0; i < bmp->size; i++)
134 _setbit(bmp, i, 0);
135 return bmp;
136}
137
138/* True if all bits are clear */
139int bitmask_isallclear(const struct bitmask *bmp)
140{
141 unsigned int i;
142 for (i = 0; i < bmp->size; i++)
143 if (_getbit(bmp, i))
144 return 0;
145 return 1;
146}
147
148/* True if specified bit i is set */
149int bitmask_isbitset(const struct bitmask *bmp, unsigned int i)
150{
151 return _getbit(bmp, i);
152}
153
154/* Number of lowest set bit (min) */
155unsigned int bitmask_first(const struct bitmask *bmp)
156{
157 return bitmask_next(bmp, 0);
158}
159
160/* Number of highest set bit (max) */
161unsigned int bitmask_last(const struct bitmask *bmp)
162{
163 unsigned int i;
164 unsigned int m = bmp->size;
165 for (i = 0; i < bmp->size; i++)
166 if (_getbit(bmp, i))
167 m = i;
168 return m;
169}
170
171/* Number of next set bit at or above given bit i */
172unsigned int bitmask_next(const struct bitmask *bmp, unsigned int i)
173{
174 unsigned int n;
175 for (n = i; n < bmp->size; n++)
176 if (_getbit(bmp, n))
177 break;
178 return n;
179}
180
181/*
182 * Parses a comma-separated list of numbers and ranges of numbers,
183 * with optional ':%u' strides modifying ranges, into provided bitmask.
184 * Some examples of input lists and their equivalent simple list:
185 * Input Equivalent to
186 * 0-3 0,1,2,3
187 * 0-7:2 0,2,4,6
188 * 1,3,5-7 1,3,5,6,7
189 * 0-3:2,8-15:4 0,2,8,12
190 */
191int bitmask_parselist(const char *buf, struct bitmask *bmp)
192{
193 const char *p, *q;
194
195 bitmask_clearall(bmp);
196
197 q = buf;
198 while (p = q, q = nexttoken(q, ','), p) {
199 unsigned int a; /* begin of range */
200 unsigned int b; /* end of range */
201 unsigned int s; /* stride */
202 const char *c1, *c2; /* next tokens after '-' or ',' */
203 char nextc; /* char after sscanf %u match */
204 int sret; /* sscanf return (number of matches) */
205
206 sret = sscanf(p, "%u%c", &a, &nextc);
207 if (!scan_was_ok(sret, nextc, ",-"))
208 goto err;
209 b = a;
210 s = 1;
211 c1 = nexttoken(p, '-');
212 c2 = nexttoken(p, ',');
213 if (c1 != NULL && (c2 == NULL || c1 < c2)) {
214 sret = sscanf(c1, "%u%c", &b, &nextc);
215 if (!scan_was_ok(sret, nextc, ",:"))
216 goto err;
217 c1 = nexttoken(c1, ':');
218 if (c1 != NULL && (c2 == NULL || c1 < c2)) {
219 sret = sscanf(c1, "%u%c", &s, &nextc);
220 if (!scan_was_ok(sret, nextc, ","))
221 goto err;
222 }
223 }
224 if (!(a <= b))
225 goto err;
226 if (b >= bmp->size)
227 goto err;
228 while (a <= b) {
229 _setbit(bmp, a, 1);
230 a += s;
231 }
232 }
233 return 0;
234err:
235 bitmask_clearall(bmp);
236 return -1;
237}
238
239/*
240 * emit(buf, buflen, rbot, rtop, len)
241 *
242 * Helper routine for bitmask_displaylist(). Write decimal number
243 * or range to buf+len, suppressing output past buf+buflen, with optional
244 * comma-prefix. Return len of what would be written to buf, if it
245 * all fit.
246 */
247
248static inline int emit(char *buf, int buflen, int rbot, int rtop, int len)
249{
250 if (len > 0)
251 len += snprintf(buf + len, max(buflen - len, 0), ",");
252 if (rbot == rtop)
253 len += snprintf(buf + len, max(buflen - len, 0), "%d", rbot);
254 else
255 len += snprintf(buf + len, max(buflen - len, 0), "%d-%d",
256 rbot, rtop);
257 return len;
258}
259
260/*
261 * Write decimal list representation of bmp to buf.
262 *
263 * Output format is a comma-separated list of decimal numbers and
264 * ranges. Consecutively set bits are shown as two hyphen-separated
265 * decimal numbers, the smallest and largest bit numbers set in
266 * the range. Output format is compatible with the format
267 * accepted as input by bitmap_parselist().
268 *
269 * The return value is the number of characters which would be
270 * generated for the given input, excluding the trailing '\0', as
271 * per ISO C99.
272 */
273
274int bitmask_displaylist(char *buf, int buflen, const struct bitmask *bmp)
275{
276 int len = 0;
277 /* current bit is 'cur', most recently seen range is [rbot, rtop] */
278 unsigned int cur, rbot, rtop;
279
280 if (buflen > 0)
281 *buf = 0;
282 rbot = cur = bitmask_first(bmp);
283 while (cur < bmp->size) {
284 rtop = cur;
285 cur = bitmask_next(bmp, cur+1);
286 if (cur >= bmp->size || cur > rtop + 1) {
287 len = emit(buf, buflen, rbot, rtop, len);
288 rbot = cur;
289 }
290 }
291 return len;
292}
diff --git a/tools/power/cpupower/utils/helpers/bitmask.h b/tools/power/cpupower/utils/helpers/bitmask.h
new file mode 100644
index 00000000000..eb289df4105
--- /dev/null
+++ b/tools/power/cpupower/utils/helpers/bitmask.h
@@ -0,0 +1,33 @@
1#ifndef __CPUPOWER_BITMASK__
2#define __CPUPOWER_BITMASK__
3
4/* Taken over from libbitmask, a project initiated from sgi:
5 * Url: http://oss.sgi.com/projects/cpusets/
6 * Unfortunately it's not very widespread, therefore relevant parts are
7 * pasted here.
8 */
9
10struct bitmask {
11 unsigned int size;
12 unsigned long *maskp;
13};
14
15struct bitmask *bitmask_alloc(unsigned int n);
16void bitmask_free(struct bitmask *bmp);
17
18struct bitmask *bitmask_setbit(struct bitmask *bmp, unsigned int i);
19struct bitmask *bitmask_setall(struct bitmask *bmp);
20struct bitmask *bitmask_clearall(struct bitmask *bmp);
21
22unsigned int bitmask_first(const struct bitmask *bmp);
23unsigned int bitmask_next(const struct bitmask *bmp, unsigned int i);
24unsigned int bitmask_last(const struct bitmask *bmp);
25int bitmask_isallclear(const struct bitmask *bmp);
26int bitmask_isbitset(const struct bitmask *bmp, unsigned int i);
27
28int bitmask_parselist(const char *buf, struct bitmask *bmp);
29int bitmask_displaylist(char *buf, int len, const struct bitmask *bmp);
30
31
32
33#endif /*__CPUPOWER_BITMASK__ */
diff --git a/tools/power/cpupower/utils/helpers/cpuid.c b/tools/power/cpupower/utils/helpers/cpuid.c
new file mode 100644
index 00000000000..906895d21cc
--- /dev/null
+++ b/tools/power/cpupower/utils/helpers/cpuid.c
@@ -0,0 +1,176 @@
1#include <stdio.h>
2#include <errno.h>
3#include <string.h>
4#include <unistd.h>
5#include <stdlib.h>
6
7#include "helpers/helpers.h"
8
9static const char *cpu_vendor_table[X86_VENDOR_MAX] = {
10 "Unknown", "GenuineIntel", "AuthenticAMD",
11};
12
13#if defined(__i386__) || defined(__x86_64__)
14
15/* from gcc */
16#include <cpuid.h>
17
18/*
19 * CPUID functions returning a single datum
20 *
21 * Define unsigned int cpuid_e[abcd]x(unsigned int op)
22 */
23#define cpuid_func(reg) \
24 unsigned int cpuid_##reg(unsigned int op) \
25 { \
26 unsigned int eax, ebx, ecx, edx; \
27 __cpuid(op, eax, ebx, ecx, edx); \
28 return reg; \
29 }
30cpuid_func(eax);
31cpuid_func(ebx);
32cpuid_func(ecx);
33cpuid_func(edx);
34
35#endif /* defined(__i386__) || defined(__x86_64__) */
36
37/* get_cpu_info
38 *
39 * Extract CPU vendor, family, model, stepping info from /proc/cpuinfo
40 *
41 * Returns 0 on success or a negativ error code
42 *
43 * TBD: Should there be a cpuid alternative for this if /proc is not mounted?
44 */
45int get_cpu_info(unsigned int cpu, struct cpupower_cpu_info *cpu_info)
46{
47 FILE *fp;
48 char value[64];
49 unsigned int proc, x;
50 unsigned int unknown = 0xffffff;
51 unsigned int cpuid_level, ext_cpuid_level;
52
53 int ret = -EINVAL;
54
55 cpu_info->vendor = X86_VENDOR_UNKNOWN;
56 cpu_info->family = unknown;
57 cpu_info->model = unknown;
58 cpu_info->stepping = unknown;
59 cpu_info->caps = 0;
60
61 fp = fopen("/proc/cpuinfo", "r");
62 if (!fp)
63 return -EIO;
64
65 while (!feof(fp)) {
66 if (!fgets(value, 64, fp))
67 continue;
68 value[63 - 1] = '\0';
69
70 if (!strncmp(value, "processor\t: ", 12))
71 sscanf(value, "processor\t: %u", &proc);
72
73 if (proc != cpu)
74 continue;
75
76 /* Get CPU vendor */
77 if (!strncmp(value, "vendor_id", 9)) {
78 for (x = 1; x < X86_VENDOR_MAX; x++) {
79 if (strstr(value, cpu_vendor_table[x]))
80 cpu_info->vendor = x;
81 }
82 /* Get CPU family, etc. */
83 } else if (!strncmp(value, "cpu family\t: ", 13)) {
84 sscanf(value, "cpu family\t: %u",
85 &cpu_info->family);
86 } else if (!strncmp(value, "model\t\t: ", 9)) {
87 sscanf(value, "model\t\t: %u",
88 &cpu_info->model);
89 } else if (!strncmp(value, "stepping\t: ", 10)) {
90 sscanf(value, "stepping\t: %u",
91 &cpu_info->stepping);
92
93 /* Exit -> all values must have been set */
94 if (cpu_info->vendor == X86_VENDOR_UNKNOWN ||
95 cpu_info->family == unknown ||
96 cpu_info->model == unknown ||
97 cpu_info->stepping == unknown) {
98 ret = -EINVAL;
99 goto out;
100 }
101
102 ret = 0;
103 goto out;
104 }
105 }
106 ret = -ENODEV;
107out:
108 fclose(fp);
109 /* Get some useful CPU capabilities from cpuid */
110 if (cpu_info->vendor != X86_VENDOR_AMD &&
111 cpu_info->vendor != X86_VENDOR_INTEL)
112 return ret;
113
114 cpuid_level = cpuid_eax(0);
115 ext_cpuid_level = cpuid_eax(0x80000000);
116
117 /* Invariant TSC */
118 if (ext_cpuid_level >= 0x80000007 &&
119 (cpuid_edx(0x80000007) & (1 << 8)))
120 cpu_info->caps |= CPUPOWER_CAP_INV_TSC;
121
122 /* Aperf/Mperf registers support */
123 if (cpuid_level >= 6 && (cpuid_ecx(6) & 0x1))
124 cpu_info->caps |= CPUPOWER_CAP_APERF;
125
126 /* AMD Boost state enable/disable register */
127 if (cpu_info->vendor == X86_VENDOR_AMD) {
128 if (ext_cpuid_level >= 0x80000007 &&
129 (cpuid_edx(0x80000007) & (1 << 9)))
130 cpu_info->caps |= CPUPOWER_CAP_AMD_CBP;
131 }
132
133 if (cpu_info->vendor == X86_VENDOR_INTEL) {
134 if (cpuid_level >= 6 &&
135 (cpuid_eax(6) & (1 << 1)))
136 cpu_info->caps |= CPUPOWER_CAP_INTEL_IDA;
137 }
138
139 if (cpu_info->vendor == X86_VENDOR_INTEL) {
140 /* Intel's perf-bias MSR support */
141 if (cpuid_level >= 6 && (cpuid_ecx(6) & (1 << 3)))
142 cpu_info->caps |= CPUPOWER_CAP_PERF_BIAS;
143
144 /* Intel's Turbo Ratio Limit support */
145 if (cpu_info->family == 6) {
146 switch (cpu_info->model) {
147 case 0x1A: /* Core i7, Xeon 5500 series
148 * Bloomfield, Gainstown NHM-EP
149 */
150 case 0x1E: /* Core i7 and i5 Processor
151 * Clarksfield, Lynnfield, Jasper Forest
152 */
153 case 0x1F: /* Core i7 and i5 Processor - Nehalem */
154 case 0x25: /* Westmere Client
155 * Clarkdale, Arrandale
156 */
157 case 0x2C: /* Westmere EP - Gulftown */
158 cpu_info->caps |= CPUPOWER_CAP_HAS_TURBO_RATIO;
159 case 0x2A: /* SNB */
160 case 0x2D: /* SNB Xeon */
161 cpu_info->caps |= CPUPOWER_CAP_HAS_TURBO_RATIO;
162 cpu_info->caps |= CPUPOWER_CAP_IS_SNB;
163 break;
164 case 0x2E: /* Nehalem-EX Xeon - Beckton */
165 case 0x2F: /* Westmere-EX Xeon - Eagleton */
166 default:
167 break;
168 }
169 }
170 }
171
172 /* printf("ID: %u - Extid: 0x%x - Caps: 0x%llx\n",
173 cpuid_level, ext_cpuid_level, cpu_info->caps);
174 */
175 return ret;
176}
diff --git a/tools/power/cpupower/utils/helpers/helpers.h b/tools/power/cpupower/utils/helpers/helpers.h
new file mode 100644
index 00000000000..2747e738efb
--- /dev/null
+++ b/tools/power/cpupower/utils/helpers/helpers.h
@@ -0,0 +1,190 @@
1/*
2 * (C) 2010,2011 Thomas Renninger <trenn@suse.de>, Novell Inc.
3 *
4 * Licensed under the terms of the GNU GPL License version 2.
5 *
6 * Miscellaneous helpers which do not fit or are worth
7 * to put into separate headers
8 */
9
10#ifndef __CPUPOWERUTILS_HELPERS__
11#define __CPUPOWERUTILS_HELPERS__
12
13#include <libintl.h>
14#include <locale.h>
15
16#include "helpers/bitmask.h"
17
18/* Internationalization ****************************/
19#ifdef NLS
20
21#define _(String) gettext(String)
22#ifndef gettext_noop
23#define gettext_noop(String) String
24#endif
25#define N_(String) gettext_noop(String)
26
27#else /* !NLS */
28
29#define _(String) String
30#define N_(String) String
31
32#endif
33/* Internationalization ****************************/
34
35extern int run_as_root;
36extern struct bitmask *cpus_chosen;
37
38/* Global verbose (-d) stuff *********************************/
39/*
40 * define DEBUG via global Makefile variable
41 * Debug output is sent to stderr, do:
42 * cpupower monitor 2>/tmp/debug
43 * to split debug output away from normal output
44*/
45#ifdef DEBUG
46extern int be_verbose;
47
48#define dprint(fmt, ...) { \
49 if (be_verbose) { \
50 fprintf(stderr, "%s: " fmt, \
51 __func__, ##__VA_ARGS__); \
52 } \
53 }
54#else
55static inline void dprint(const char *fmt, ...) { }
56#endif
57extern int be_verbose;
58/* Global verbose (-v) stuff *********************************/
59
60/* cpuid and cpuinfo helpers **************************/
61enum cpupower_cpu_vendor {X86_VENDOR_UNKNOWN = 0, X86_VENDOR_INTEL,
62 X86_VENDOR_AMD, X86_VENDOR_MAX};
63
64#define CPUPOWER_CAP_INV_TSC 0x00000001
65#define CPUPOWER_CAP_APERF 0x00000002
66#define CPUPOWER_CAP_AMD_CBP 0x00000004
67#define CPUPOWER_CAP_PERF_BIAS 0x00000008
68#define CPUPOWER_CAP_HAS_TURBO_RATIO 0x00000010
69#define CPUPOWER_CAP_IS_SNB 0x00000011
70#define CPUPOWER_CAP_INTEL_IDA 0x00000012
71
72#define MAX_HW_PSTATES 10
73
74struct cpupower_cpu_info {
75 enum cpupower_cpu_vendor vendor;
76 unsigned int family;
77 unsigned int model;
78 unsigned int stepping;
79 /* CPU capabilities read out from cpuid */
80 unsigned long long caps;
81};
82
83/* get_cpu_info
84 *
85 * Extract CPU vendor, family, model, stepping info from /proc/cpuinfo
86 *
87 * Returns 0 on success or a negativ error code
88 * Only used on x86, below global's struct values are zero/unknown on
89 * other archs
90 */
91extern int get_cpu_info(unsigned int cpu, struct cpupower_cpu_info *cpu_info);
92extern struct cpupower_cpu_info cpupower_cpu_info;
93/* cpuid and cpuinfo helpers **************************/
94
95
96/* CPU topology/hierarchy parsing ******************/
97struct cpupower_topology {
98 /* Amount of CPU cores, packages and threads per core in the system */
99 unsigned int cores;
100 unsigned int pkgs;
101 unsigned int threads; /* per core */
102
103 /* Array gets mallocated with cores entries, holding per core info */
104 struct {
105 int pkg;
106 int core;
107 int cpu;
108
109 /* flags */
110 unsigned int is_online:1;
111 } *core_info;
112};
113
114extern int get_cpu_topology(struct cpupower_topology *cpu_top);
115extern void cpu_topology_release(struct cpupower_topology cpu_top);
116/* CPU topology/hierarchy parsing ******************/
117
118/* X86 ONLY ****************************************/
119#if defined(__i386__) || defined(__x86_64__)
120
121#include <pci/pci.h>
122
123/* Read/Write msr ****************************/
124extern int read_msr(int cpu, unsigned int idx, unsigned long long *val);
125extern int write_msr(int cpu, unsigned int idx, unsigned long long val);
126
127extern int msr_intel_set_perf_bias(unsigned int cpu, unsigned int val);
128extern int msr_intel_get_perf_bias(unsigned int cpu);
129extern unsigned long long msr_intel_get_turbo_ratio(unsigned int cpu);
130
131/* Read/Write msr ****************************/
132
133/* PCI stuff ****************************/
134extern int amd_pci_get_num_boost_states(int *active, int *states);
135extern struct pci_dev *pci_acc_init(struct pci_access **pacc, int vendor_id,
136 int *dev_ids);
137
138/* PCI stuff ****************************/
139
140/* AMD HW pstate decoding **************************/
141
142extern int decode_pstates(unsigned int cpu, unsigned int cpu_family,
143 int boost_states, unsigned long *pstates, int *no);
144
145/* AMD HW pstate decoding **************************/
146
147extern int cpufreq_has_boost_support(unsigned int cpu, int *support,
148 int *active, int * states);
149/*
150 * CPUID functions returning a single datum
151 */
152unsigned int cpuid_eax(unsigned int op);
153unsigned int cpuid_ebx(unsigned int op);
154unsigned int cpuid_ecx(unsigned int op);
155unsigned int cpuid_edx(unsigned int op);
156
157/* cpuid and cpuinfo helpers **************************/
158/* X86 ONLY ********************************************/
159#else
160static inline int decode_pstates(unsigned int cpu, unsigned int cpu_family,
161 int boost_states, unsigned long *pstates,
162 int *no)
163{ return -1; };
164
165static inline int read_msr(int cpu, unsigned int idx, unsigned long long *val)
166{ return -1; };
167static inline int write_msr(int cpu, unsigned int idx, unsigned long long val)
168{ return -1; };
169static inline int msr_intel_set_perf_bias(unsigned int cpu, unsigned int val)
170{ return -1; };
171static inline int msr_intel_get_perf_bias(unsigned int cpu)
172{ return -1; };
173static inline unsigned long long msr_intel_get_turbo_ratio(unsigned int cpu)
174{ return 0; };
175
176/* Read/Write msr ****************************/
177
178static inline int cpufreq_has_boost_support(unsigned int cpu, int *support,
179 int *active, int * states)
180{ return -1; }
181
182/* cpuid and cpuinfo helpers **************************/
183
184static inline unsigned int cpuid_eax(unsigned int op) { return 0; };
185static inline unsigned int cpuid_ebx(unsigned int op) { return 0; };
186static inline unsigned int cpuid_ecx(unsigned int op) { return 0; };
187static inline unsigned int cpuid_edx(unsigned int op) { return 0; };
188#endif /* defined(__i386__) || defined(__x86_64__) */
189
190#endif /* __CPUPOWERUTILS_HELPERS__ */
diff --git a/tools/power/cpupower/utils/helpers/misc.c b/tools/power/cpupower/utils/helpers/misc.c
new file mode 100644
index 00000000000..1609243f5c6
--- /dev/null
+++ b/tools/power/cpupower/utils/helpers/misc.c
@@ -0,0 +1,27 @@
1#if defined(__i386__) || defined(__x86_64__)
2
3#include "helpers/helpers.h"
4
5int cpufreq_has_boost_support(unsigned int cpu, int *support, int *active,
6 int *states)
7{
8 struct cpupower_cpu_info cpu_info;
9 int ret;
10
11 *support = *active = *states = 0;
12
13 ret = get_cpu_info(0, &cpu_info);
14 if (ret)
15 return ret;
16
17 if (cpupower_cpu_info.caps & CPUPOWER_CAP_AMD_CBP) {
18 *support = 1;
19 amd_pci_get_num_boost_states(active, states);
20 if (ret <= 0)
21 return ret;
22 *support = 1;
23 } else if (cpupower_cpu_info.caps & CPUPOWER_CAP_INTEL_IDA)
24 *support = *active = 1;
25 return 0;
26}
27#endif /* #if defined(__i386__) || defined(__x86_64__) */
diff --git a/tools/power/cpupower/utils/helpers/msr.c b/tools/power/cpupower/utils/helpers/msr.c
new file mode 100644
index 00000000000..31a4b24a8bc
--- /dev/null
+++ b/tools/power/cpupower/utils/helpers/msr.c
@@ -0,0 +1,115 @@
1#if defined(__i386__) || defined(__x86_64__)
2
3#include <fcntl.h>
4#include <stdio.h>
5#include <unistd.h>
6#include <stdint.h>
7
8#include "helpers/helpers.h"
9
10/* Intel specific MSRs */
11#define MSR_IA32_PERF_STATUS 0x198
12#define MSR_IA32_MISC_ENABLES 0x1a0
13#define MSR_IA32_ENERGY_PERF_BIAS 0x1b0
14#define MSR_NEHALEM_TURBO_RATIO_LIMIT 0x1ad
15
16/*
17 * read_msr
18 *
19 * Will return 0 on success and -1 on failure.
20 * Possible errno values could be:
21 * EFAULT -If the read/write did not fully complete
22 * EIO -If the CPU does not support MSRs
23 * ENXIO -If the CPU does not exist
24 */
25
26int read_msr(int cpu, unsigned int idx, unsigned long long *val)
27{
28 int fd;
29 char msr_file_name[64];
30
31 sprintf(msr_file_name, "/dev/cpu/%d/msr", cpu);
32 fd = open(msr_file_name, O_RDONLY);
33 if (fd < 0)
34 return -1;
35 if (lseek(fd, idx, SEEK_CUR) == -1)
36 goto err;
37 if (read(fd, val, sizeof *val) != sizeof *val)
38 goto err;
39 close(fd);
40 return 0;
41 err:
42 close(fd);
43 return -1;
44}
45
46/*
47 * write_msr
48 *
49 * Will return 0 on success and -1 on failure.
50 * Possible errno values could be:
51 * EFAULT -If the read/write did not fully complete
52 * EIO -If the CPU does not support MSRs
53 * ENXIO -If the CPU does not exist
54 */
55int write_msr(int cpu, unsigned int idx, unsigned long long val)
56{
57 int fd;
58 char msr_file_name[64];
59
60 sprintf(msr_file_name, "/dev/cpu/%d/msr", cpu);
61 fd = open(msr_file_name, O_WRONLY);
62 if (fd < 0)
63 return -1;
64 if (lseek(fd, idx, SEEK_CUR) == -1)
65 goto err;
66 if (write(fd, &val, sizeof val) != sizeof val)
67 goto err;
68 close(fd);
69 return 0;
70 err:
71 close(fd);
72 return -1;
73}
74
75int msr_intel_get_perf_bias(unsigned int cpu)
76{
77 unsigned long long val;
78 int ret;
79
80 if (!(cpupower_cpu_info.caps & CPUPOWER_CAP_PERF_BIAS))
81 return -1;
82
83 ret = read_msr(cpu, MSR_IA32_ENERGY_PERF_BIAS, &val);
84 if (ret)
85 return ret;
86 return val;
87}
88
89int msr_intel_set_perf_bias(unsigned int cpu, unsigned int val)
90{
91 int ret;
92
93 if (!(cpupower_cpu_info.caps & CPUPOWER_CAP_PERF_BIAS))
94 return -1;
95
96 ret = write_msr(cpu, MSR_IA32_ENERGY_PERF_BIAS, val);
97 if (ret)
98 return ret;
99 return 0;
100}
101
102unsigned long long msr_intel_get_turbo_ratio(unsigned int cpu)
103{
104 unsigned long long val;
105 int ret;
106
107 if (!(cpupower_cpu_info.caps & CPUPOWER_CAP_HAS_TURBO_RATIO))
108 return -1;
109
110 ret = read_msr(cpu, MSR_NEHALEM_TURBO_RATIO_LIMIT, &val);
111 if (ret)
112 return ret;
113 return val;
114}
115#endif
diff --git a/tools/power/cpupower/utils/helpers/pci.c b/tools/power/cpupower/utils/helpers/pci.c
new file mode 100644
index 00000000000..cd2eb6fe41c
--- /dev/null
+++ b/tools/power/cpupower/utils/helpers/pci.c
@@ -0,0 +1,44 @@
1#if defined(__i386__) || defined(__x86_64__)
2
3#include <helpers/helpers.h>
4
5/*
6 * pci_acc_init
7 *
8 * PCI access helper function depending on libpci
9 *
10 * **pacc : if a valid pci_dev is returned
11 * *pacc must be passed to pci_acc_cleanup to free it
12 *
13 * vendor_id : the pci vendor id matching the pci device to access
14 * dev_ids : device ids matching the pci device to access
15 *
16 * Returns :
17 * struct pci_dev which can be used with pci_{read,write}_* functions
18 * to access the PCI config space of matching pci devices
19 */
20struct pci_dev *pci_acc_init(struct pci_access **pacc, int vendor_id,
21 int *dev_ids)
22{
23 struct pci_filter filter_nb_link = { -1, -1, -1, -1, vendor_id, 0};
24 struct pci_dev *device;
25 unsigned int i;
26
27 *pacc = pci_alloc();
28 if (*pacc == NULL)
29 return NULL;
30
31 pci_init(*pacc);
32 pci_scan_bus(*pacc);
33
34 for (i = 0; dev_ids[i] != 0; i++) {
35 filter_nb_link.device = dev_ids[i];
36 for (device = (*pacc)->devices; device; device = device->next) {
37 if (pci_filter_match(&filter_nb_link, device))
38 return device;
39 }
40 }
41 pci_cleanup(*pacc);
42 return NULL;
43}
44#endif /* defined(__i386__) || defined(__x86_64__) */
diff --git a/tools/power/cpupower/utils/helpers/sysfs.c b/tools/power/cpupower/utils/helpers/sysfs.c
new file mode 100644
index 00000000000..c6343024a61
--- /dev/null
+++ b/tools/power/cpupower/utils/helpers/sysfs.c
@@ -0,0 +1,408 @@
1/*
2 * (C) 2004-2009 Dominik Brodowski <linux@dominikbrodowski.de>
3 * (C) 2011 Thomas Renninger <trenn@novell.com> Novell Inc.
4 *
5 * Licensed under the terms of the GNU GPL License version 2.
6 */
7
8#include <stdio.h>
9#include <errno.h>
10#include <stdlib.h>
11#include <string.h>
12#include <sys/types.h>
13#include <sys/stat.h>
14#include <fcntl.h>
15#include <unistd.h>
16
17#include "helpers/sysfs.h"
18
19unsigned int sysfs_read_file(const char *path, char *buf, size_t buflen)
20{
21 int fd;
22 ssize_t numread;
23
24 fd = open(path, O_RDONLY);
25 if (fd == -1)
26 return 0;
27
28 numread = read(fd, buf, buflen - 1);
29 if (numread < 1) {
30 close(fd);
31 return 0;
32 }
33
34 buf[numread] = '\0';
35 close(fd);
36
37 return (unsigned int) numread;
38}
39
40static unsigned int sysfs_write_file(const char *path,
41 const char *value, size_t len)
42{
43 int fd;
44 ssize_t numwrite;
45
46 fd = open(path, O_WRONLY);
47 if (fd == -1)
48 return 0;
49
50 numwrite = write(fd, value, len);
51 if (numwrite < 1) {
52 close(fd);
53 return 0;
54 }
55 close(fd);
56 return (unsigned int) numwrite;
57}
58
59/*
60 * Detect whether a CPU is online
61 *
62 * Returns:
63 * 1 -> if CPU is online
64 * 0 -> if CPU is offline
65 * negative errno values in error case
66 */
67int sysfs_is_cpu_online(unsigned int cpu)
68{
69 char path[SYSFS_PATH_MAX];
70 int fd;
71 ssize_t numread;
72 unsigned long long value;
73 char linebuf[MAX_LINE_LEN];
74 char *endp;
75 struct stat statbuf;
76
77 snprintf(path, sizeof(path), PATH_TO_CPU "cpu%u", cpu);
78
79 if (stat(path, &statbuf) != 0)
80 return 0;
81
82 /*
83 * kernel without CONFIG_HOTPLUG_CPU
84 * -> cpuX directory exists, but not cpuX/online file
85 */
86 snprintf(path, sizeof(path), PATH_TO_CPU "cpu%u/online", cpu);
87 if (stat(path, &statbuf) != 0)
88 return 1;
89
90 fd = open(path, O_RDONLY);
91 if (fd == -1)
92 return -errno;
93
94 numread = read(fd, linebuf, MAX_LINE_LEN - 1);
95 if (numread < 1) {
96 close(fd);
97 return -EIO;
98 }
99 linebuf[numread] = '\0';
100 close(fd);
101
102 value = strtoull(linebuf, &endp, 0);
103 if (value > 1 || value < 0)
104 return -EINVAL;
105
106 return value;
107}
108
109/* CPUidle idlestate specific /sys/devices/system/cpu/cpuX/cpuidle/ access */
110
111/*
112 * helper function to read file from /sys into given buffer
113 * fname is a relative path under "cpuX/cpuidle/stateX/" dir
114 * cstates starting with 0, C0 is not counted as cstate.
115 * This means if you want C1 info, pass 0 as idlestate param
116 */
117unsigned int sysfs_idlestate_read_file(unsigned int cpu, unsigned int idlestate,
118 const char *fname, char *buf, size_t buflen)
119{
120 char path[SYSFS_PATH_MAX];
121 int fd;
122 ssize_t numread;
123
124 snprintf(path, sizeof(path), PATH_TO_CPU "cpu%u/cpuidle/state%u/%s",
125 cpu, idlestate, fname);
126
127 fd = open(path, O_RDONLY);
128 if (fd == -1)
129 return 0;
130
131 numread = read(fd, buf, buflen - 1);
132 if (numread < 1) {
133 close(fd);
134 return 0;
135 }
136
137 buf[numread] = '\0';
138 close(fd);
139
140 return (unsigned int) numread;
141}
142
143/* read access to files which contain one numeric value */
144
145enum idlestate_value {
146 IDLESTATE_USAGE,
147 IDLESTATE_POWER,
148 IDLESTATE_LATENCY,
149 IDLESTATE_TIME,
150 MAX_IDLESTATE_VALUE_FILES
151};
152
153static const char *idlestate_value_files[MAX_IDLESTATE_VALUE_FILES] = {
154 [IDLESTATE_USAGE] = "usage",
155 [IDLESTATE_POWER] = "power",
156 [IDLESTATE_LATENCY] = "latency",
157 [IDLESTATE_TIME] = "time",
158};
159
160static unsigned long long sysfs_idlestate_get_one_value(unsigned int cpu,
161 unsigned int idlestate,
162 enum idlestate_value which)
163{
164 unsigned long long value;
165 unsigned int len;
166 char linebuf[MAX_LINE_LEN];
167 char *endp;
168
169 if (which >= MAX_IDLESTATE_VALUE_FILES)
170 return 0;
171
172 len = sysfs_idlestate_read_file(cpu, idlestate,
173 idlestate_value_files[which],
174 linebuf, sizeof(linebuf));
175 if (len == 0)
176 return 0;
177
178 value = strtoull(linebuf, &endp, 0);
179
180 if (endp == linebuf || errno == ERANGE)
181 return 0;
182
183 return value;
184}
185
186/* read access to files which contain one string */
187
188enum idlestate_string {
189 IDLESTATE_DESC,
190 IDLESTATE_NAME,
191 MAX_IDLESTATE_STRING_FILES
192};
193
194static const char *idlestate_string_files[MAX_IDLESTATE_STRING_FILES] = {
195 [IDLESTATE_DESC] = "desc",
196 [IDLESTATE_NAME] = "name",
197};
198
199
200static char *sysfs_idlestate_get_one_string(unsigned int cpu,
201 unsigned int idlestate,
202 enum idlestate_string which)
203{
204 char linebuf[MAX_LINE_LEN];
205 char *result;
206 unsigned int len;
207
208 if (which >= MAX_IDLESTATE_STRING_FILES)
209 return NULL;
210
211 len = sysfs_idlestate_read_file(cpu, idlestate,
212 idlestate_string_files[which],
213 linebuf, sizeof(linebuf));
214 if (len == 0)
215 return NULL;
216
217 result = strdup(linebuf);
218 if (result == NULL)
219 return NULL;
220
221 if (result[strlen(result) - 1] == '\n')
222 result[strlen(result) - 1] = '\0';
223
224 return result;
225}
226
227unsigned long sysfs_get_idlestate_latency(unsigned int cpu,
228 unsigned int idlestate)
229{
230 return sysfs_idlestate_get_one_value(cpu, idlestate, IDLESTATE_LATENCY);
231}
232
233unsigned long sysfs_get_idlestate_usage(unsigned int cpu,
234 unsigned int idlestate)
235{
236 return sysfs_idlestate_get_one_value(cpu, idlestate, IDLESTATE_USAGE);
237}
238
239unsigned long long sysfs_get_idlestate_time(unsigned int cpu,
240 unsigned int idlestate)
241{
242 return sysfs_idlestate_get_one_value(cpu, idlestate, IDLESTATE_TIME);
243}
244
245char *sysfs_get_idlestate_name(unsigned int cpu, unsigned int idlestate)
246{
247 return sysfs_idlestate_get_one_string(cpu, idlestate, IDLESTATE_NAME);
248}
249
250char *sysfs_get_idlestate_desc(unsigned int cpu, unsigned int idlestate)
251{
252 return sysfs_idlestate_get_one_string(cpu, idlestate, IDLESTATE_DESC);
253}
254
255/*
256 * Returns number of supported C-states of CPU core cpu
257 * Negativ in error case
258 * Zero if cpuidle does not export any C-states
259 */
260int sysfs_get_idlestate_count(unsigned int cpu)
261{
262 char file[SYSFS_PATH_MAX];
263 struct stat statbuf;
264 int idlestates = 1;
265
266
267 snprintf(file, SYSFS_PATH_MAX, PATH_TO_CPU "cpuidle");
268 if (stat(file, &statbuf) != 0 || !S_ISDIR(statbuf.st_mode))
269 return -ENODEV;
270
271 snprintf(file, SYSFS_PATH_MAX, PATH_TO_CPU "cpu%u/cpuidle/state0", cpu);
272 if (stat(file, &statbuf) != 0 || !S_ISDIR(statbuf.st_mode))
273 return 0;
274
275 while (stat(file, &statbuf) == 0 && S_ISDIR(statbuf.st_mode)) {
276 snprintf(file, SYSFS_PATH_MAX, PATH_TO_CPU
277 "cpu%u/cpuidle/state%d", cpu, idlestates);
278 idlestates++;
279 }
280 idlestates--;
281 return idlestates;
282}
283
284/* CPUidle general /sys/devices/system/cpu/cpuidle/ sysfs access ********/
285
286/*
287 * helper function to read file from /sys into given buffer
288 * fname is a relative path under "cpu/cpuidle/" dir
289 */
290static unsigned int sysfs_cpuidle_read_file(const char *fname, char *buf,
291 size_t buflen)
292{
293 char path[SYSFS_PATH_MAX];
294
295 snprintf(path, sizeof(path), PATH_TO_CPU "cpuidle/%s", fname);
296
297 return sysfs_read_file(path, buf, buflen);
298}
299
300
301
302/* read access to files which contain one string */
303
304enum cpuidle_string {
305 CPUIDLE_GOVERNOR,
306 CPUIDLE_GOVERNOR_RO,
307 CPUIDLE_DRIVER,
308 MAX_CPUIDLE_STRING_FILES
309};
310
311static const char *cpuidle_string_files[MAX_CPUIDLE_STRING_FILES] = {
312 [CPUIDLE_GOVERNOR] = "current_governor",
313 [CPUIDLE_GOVERNOR_RO] = "current_governor_ro",
314 [CPUIDLE_DRIVER] = "current_driver",
315};
316
317
318static char *sysfs_cpuidle_get_one_string(enum cpuidle_string which)
319{
320 char linebuf[MAX_LINE_LEN];
321 char *result;
322 unsigned int len;
323
324 if (which >= MAX_CPUIDLE_STRING_FILES)
325 return NULL;
326
327 len = sysfs_cpuidle_read_file(cpuidle_string_files[which],
328 linebuf, sizeof(linebuf));
329 if (len == 0)
330 return NULL;
331
332 result = strdup(linebuf);
333 if (result == NULL)
334 return NULL;
335
336 if (result[strlen(result) - 1] == '\n')
337 result[strlen(result) - 1] = '\0';
338
339 return result;
340}
341
342char *sysfs_get_cpuidle_governor(void)
343{
344 char *tmp = sysfs_cpuidle_get_one_string(CPUIDLE_GOVERNOR_RO);
345 if (!tmp)
346 return sysfs_cpuidle_get_one_string(CPUIDLE_GOVERNOR);
347 else
348 return tmp;
349}
350
351char *sysfs_get_cpuidle_driver(void)
352{
353 return sysfs_cpuidle_get_one_string(CPUIDLE_DRIVER);
354}
355/* CPUidle idlestate specific /sys/devices/system/cpu/cpuX/cpuidle/ access */
356
357/*
358 * Get sched_mc or sched_smt settings
359 * Pass "mc" or "smt" as argument
360 *
361 * Returns negative value on failure
362 */
363int sysfs_get_sched(const char *smt_mc)
364{
365 unsigned long value;
366 char linebuf[MAX_LINE_LEN];
367 char *endp;
368 char path[SYSFS_PATH_MAX];
369
370 if (strcmp("mc", smt_mc) && strcmp("smt", smt_mc))
371 return -EINVAL;
372
373 snprintf(path, sizeof(path),
374 PATH_TO_CPU "sched_%s_power_savings", smt_mc);
375 if (sysfs_read_file(path, linebuf, MAX_LINE_LEN) == 0)
376 return -1;
377 value = strtoul(linebuf, &endp, 0);
378 if (endp == linebuf || errno == ERANGE)
379 return -1;
380 return value;
381}
382
383/*
384 * Get sched_mc or sched_smt settings
385 * Pass "mc" or "smt" as argument
386 *
387 * Returns negative value on failure
388 */
389int sysfs_set_sched(const char *smt_mc, int val)
390{
391 char linebuf[MAX_LINE_LEN];
392 char path[SYSFS_PATH_MAX];
393 struct stat statbuf;
394
395 if (strcmp("mc", smt_mc) && strcmp("smt", smt_mc))
396 return -EINVAL;
397
398 snprintf(path, sizeof(path),
399 PATH_TO_CPU "sched_%s_power_savings", smt_mc);
400 sprintf(linebuf, "%d", val);
401
402 if (stat(path, &statbuf) != 0)
403 return -ENODEV;
404
405 if (sysfs_write_file(path, linebuf, MAX_LINE_LEN) == 0)
406 return -1;
407 return 0;
408}
diff --git a/tools/power/cpupower/utils/helpers/sysfs.h b/tools/power/cpupower/utils/helpers/sysfs.h
new file mode 100644
index 00000000000..8cb797bbceb
--- /dev/null
+++ b/tools/power/cpupower/utils/helpers/sysfs.h
@@ -0,0 +1,30 @@
1#ifndef __CPUPOWER_HELPERS_SYSFS_H__
2#define __CPUPOWER_HELPERS_SYSFS_H__
3
4#define PATH_TO_CPU "/sys/devices/system/cpu/"
5#define MAX_LINE_LEN 255
6#define SYSFS_PATH_MAX 255
7
8extern unsigned int sysfs_read_file(const char *path, char *buf, size_t buflen);
9
10extern int sysfs_is_cpu_online(unsigned int cpu);
11
12extern unsigned long sysfs_get_idlestate_latency(unsigned int cpu,
13 unsigned int idlestate);
14extern unsigned long sysfs_get_idlestate_usage(unsigned int cpu,
15 unsigned int idlestate);
16extern unsigned long long sysfs_get_idlestate_time(unsigned int cpu,
17 unsigned int idlestate);
18extern char *sysfs_get_idlestate_name(unsigned int cpu,
19 unsigned int idlestate);
20extern char *sysfs_get_idlestate_desc(unsigned int cpu,
21 unsigned int idlestate);
22extern int sysfs_get_idlestate_count(unsigned int cpu);
23
24extern char *sysfs_get_cpuidle_governor(void);
25extern char *sysfs_get_cpuidle_driver(void);
26
27extern int sysfs_get_sched(const char *smt_mc);
28extern int sysfs_set_sched(const char *smt_mc, int val);
29
30#endif /* __CPUPOWER_HELPERS_SYSFS_H__ */
diff --git a/tools/power/cpupower/utils/helpers/topology.c b/tools/power/cpupower/utils/helpers/topology.c
new file mode 100644
index 00000000000..4eae2c47ba4
--- /dev/null
+++ b/tools/power/cpupower/utils/helpers/topology.c
@@ -0,0 +1,111 @@
1/*
2 * (C) 2010,2011 Thomas Renninger <trenn@suse.de>, Novell Inc.
3 *
4 * Licensed under the terms of the GNU GPL License version 2.
5 *
6 * ToDo: Needs to be done more properly for AMD/Intel specifics
7 */
8
9/* Helper struct for qsort, must be in sync with cpupower_topology.cpu_info */
10/* Be careful: Need to pass unsigned to the sort, so that offlined cores are
11 in the end, but double check for -1 for offlined cpus at other places */
12
13#include <stdlib.h>
14#include <stdio.h>
15#include <unistd.h>
16#include <errno.h>
17#include <fcntl.h>
18
19#include <helpers/helpers.h>
20#include <helpers/sysfs.h>
21
22/* returns -1 on failure, 0 on success */
23int sysfs_topology_read_file(unsigned int cpu, const char *fname)
24{
25 unsigned long value;
26 char linebuf[MAX_LINE_LEN];
27 char *endp;
28 char path[SYSFS_PATH_MAX];
29
30 snprintf(path, sizeof(path), PATH_TO_CPU "cpu%u/topology/%s",
31 cpu, fname);
32 if (sysfs_read_file(path, linebuf, MAX_LINE_LEN) == 0)
33 return -1;
34 value = strtoul(linebuf, &endp, 0);
35 if (endp == linebuf || errno == ERANGE)
36 return -1;
37 return value;
38}
39
40struct cpuid_core_info {
41 unsigned int pkg;
42 unsigned int thread;
43 unsigned int cpu;
44 /* flags */
45 unsigned int is_online:1;
46};
47
48static int __compare(const void *t1, const void *t2)
49{
50 struct cpuid_core_info *top1 = (struct cpuid_core_info *)t1;
51 struct cpuid_core_info *top2 = (struct cpuid_core_info *)t2;
52 if (top1->pkg < top2->pkg)
53 return -1;
54 else if (top1->pkg > top2->pkg)
55 return 1;
56 else if (top1->thread < top2->thread)
57 return -1;
58 else if (top1->thread > top2->thread)
59 return 1;
60 else if (top1->cpu < top2->cpu)
61 return -1;
62 else if (top1->cpu > top2->cpu)
63 return 1;
64 else
65 return 0;
66}
67
68/*
69 * Returns amount of cpus, negative on error, cpu_top must be
70 * passed to cpu_topology_release to free resources
71 *
72 * Array is sorted after ->pkg, ->core, then ->cpu
73 */
74int get_cpu_topology(struct cpupower_topology *cpu_top)
75{
76 int cpu, cpus = sysconf(_SC_NPROCESSORS_CONF);
77
78 cpu_top->core_info = malloc(sizeof(struct cpupower_topology) * cpus);
79 if (cpu_top->core_info == NULL)
80 return -ENOMEM;
81 cpu_top->pkgs = cpu_top->cores = 0;
82 for (cpu = 0; cpu < cpus; cpu++) {
83 cpu_top->core_info[cpu].cpu = cpu;
84 cpu_top->core_info[cpu].is_online = sysfs_is_cpu_online(cpu);
85 cpu_top->core_info[cpu].pkg =
86 sysfs_topology_read_file(cpu, "physical_package_id");
87 if ((int)cpu_top->core_info[cpu].pkg != -1 &&
88 cpu_top->core_info[cpu].pkg > cpu_top->pkgs)
89 cpu_top->pkgs = cpu_top->core_info[cpu].pkg;
90 cpu_top->core_info[cpu].core =
91 sysfs_topology_read_file(cpu, "core_id");
92 }
93 cpu_top->pkgs++;
94
95 qsort(cpu_top->core_info, cpus, sizeof(struct cpuid_core_info),
96 __compare);
97
98 /* Intel's cores count is not consecutively numbered, there may
99 * be a core_id of 3, but none of 2. Assume there always is 0
100 * Get amount of cores by counting duplicates in a package
101 for (cpu = 0; cpu_top->core_info[cpu].pkg = 0 && cpu < cpus; cpu++) {
102 if (cpu_top->core_info[cpu].core == 0)
103 cpu_top->cores++;
104 */
105 return cpus;
106}
107
108void cpu_topology_release(struct cpupower_topology cpu_top)
109{
110 free(cpu_top.core_info);
111}
diff --git a/tools/power/cpupower/utils/idle_monitor/amd_fam14h_idle.c b/tools/power/cpupower/utils/idle_monitor/amd_fam14h_idle.c
new file mode 100644
index 00000000000..202e555988b
--- /dev/null
+++ b/tools/power/cpupower/utils/idle_monitor/amd_fam14h_idle.c
@@ -0,0 +1,338 @@
1/*
2 * (C) 2010,2011 Thomas Renninger <trenn@suse.de>, Novell Inc.
3 *
4 * Licensed under the terms of the GNU GPL License version 2.
5 *
6 * PCI initialization based on example code from:
7 * Andreas Herrmann <andreas.herrmann3@amd.com>
8 */
9
10#if defined(__i386__) || defined(__x86_64__)
11
12#include <stdio.h>
13#include <stdlib.h>
14#include <stdint.h>
15#include <time.h>
16#include <string.h>
17
18#include <pci/pci.h>
19
20#include "idle_monitor/cpupower-monitor.h"
21#include "helpers/helpers.h"
22
23/******** PCI parts could go into own file and get shared ***************/
24
25#define PCI_NON_PC0_OFFSET 0xb0
26#define PCI_PC1_OFFSET 0xb4
27#define PCI_PC6_OFFSET 0xb8
28
29#define PCI_MONITOR_ENABLE_REG 0xe0
30
31#define PCI_NON_PC0_ENABLE_BIT 0
32#define PCI_PC1_ENABLE_BIT 1
33#define PCI_PC6_ENABLE_BIT 2
34
35#define PCI_NBP1_STAT_OFFSET 0x98
36#define PCI_NBP1_ACTIVE_BIT 2
37#define PCI_NBP1_ENTERED_BIT 1
38
39#define PCI_NBP1_CAP_OFFSET 0x90
40#define PCI_NBP1_CAPABLE_BIT 31
41
42#define OVERFLOW_MS 343597 /* 32 bit register filled at 12500 HZ
43 (1 tick per 80ns) */
44
45enum amd_fam14h_states {NON_PC0 = 0, PC1, PC6, NBP1,
46 AMD_FAM14H_STATE_NUM};
47
48static int fam14h_get_count_percent(unsigned int self_id, double *percent,
49 unsigned int cpu);
50static int fam14h_nbp1_count(unsigned int id, unsigned long long *count,
51 unsigned int cpu);
52
53static cstate_t amd_fam14h_cstates[AMD_FAM14H_STATE_NUM] = {
54 {
55 .name = "!PC0",
56 .desc = N_("Package in sleep state (PC1 or deeper)"),
57 .id = NON_PC0,
58 .range = RANGE_PACKAGE,
59 .get_count_percent = fam14h_get_count_percent,
60 },
61 {
62 .name = "PC1",
63 .desc = N_("Processor Package C1"),
64 .id = PC1,
65 .range = RANGE_PACKAGE,
66 .get_count_percent = fam14h_get_count_percent,
67 },
68 {
69 .name = "PC6",
70 .desc = N_("Processor Package C6"),
71 .id = PC6,
72 .range = RANGE_PACKAGE,
73 .get_count_percent = fam14h_get_count_percent,
74 },
75 {
76 .name = "NBP1",
77 .desc = N_("North Bridge P1 boolean counter (returns 0 or 1)"),
78 .id = NBP1,
79 .range = RANGE_PACKAGE,
80 .get_count = fam14h_nbp1_count,
81 },
82};
83
84static struct pci_access *pci_acc;
85static int pci_vendor_id = 0x1022;
86static int pci_dev_ids[2] = {0x1716, 0};
87static struct pci_dev *amd_fam14h_pci_dev;
88
89static int nbp1_entered;
90
91struct timespec start_time;
92static unsigned long long timediff;
93
94#ifdef DEBUG
95struct timespec dbg_time;
96long dbg_timediff;
97#endif
98
99static unsigned long long *previous_count[AMD_FAM14H_STATE_NUM];
100static unsigned long long *current_count[AMD_FAM14H_STATE_NUM];
101
102static int amd_fam14h_get_pci_info(struct cstate *state,
103 unsigned int *pci_offset,
104 unsigned int *enable_bit,
105 unsigned int cpu)
106{
107 switch (state->id) {
108 case NON_PC0:
109 *enable_bit = PCI_NON_PC0_ENABLE_BIT;
110 *pci_offset = PCI_NON_PC0_OFFSET;
111 break;
112 case PC1:
113 *enable_bit = PCI_PC1_ENABLE_BIT;
114 *pci_offset = PCI_PC1_OFFSET;
115 break;
116 case PC6:
117 *enable_bit = PCI_PC6_ENABLE_BIT;
118 *pci_offset = PCI_PC6_OFFSET;
119 break;
120 case NBP1:
121 *enable_bit = PCI_NBP1_ENTERED_BIT;
122 *pci_offset = PCI_NBP1_STAT_OFFSET;
123 break;
124 default:
125 return -1;
126 };
127 return 0;
128}
129
130static int amd_fam14h_init(cstate_t *state, unsigned int cpu)
131{
132 int enable_bit, pci_offset, ret;
133 uint32_t val;
134
135 ret = amd_fam14h_get_pci_info(state, &pci_offset, &enable_bit, cpu);
136 if (ret)
137 return ret;
138
139 /* NBP1 needs extra treating -> write 1 to D18F6x98 bit 1 for init */
140 if (state->id == NBP1) {
141 val = pci_read_long(amd_fam14h_pci_dev, pci_offset);
142 val |= 1 << enable_bit;
143 val = pci_write_long(amd_fam14h_pci_dev, pci_offset, val);
144 return ret;
145 }
146
147 /* Enable monitor */
148 val = pci_read_long(amd_fam14h_pci_dev, PCI_MONITOR_ENABLE_REG);
149 dprint("Init %s: read at offset: 0x%x val: %u\n", state->name,
150 PCI_MONITOR_ENABLE_REG, (unsigned int) val);
151 val |= 1 << enable_bit;
152 pci_write_long(amd_fam14h_pci_dev, PCI_MONITOR_ENABLE_REG, val);
153
154 dprint("Init %s: offset: 0x%x enable_bit: %d - val: %u (%u)\n",
155 state->name, PCI_MONITOR_ENABLE_REG, enable_bit,
156 (unsigned int) val, cpu);
157
158 /* Set counter to zero */
159 pci_write_long(amd_fam14h_pci_dev, pci_offset, 0);
160 previous_count[state->id][cpu] = 0;
161
162 return 0;
163}
164
165static int amd_fam14h_disable(cstate_t *state, unsigned int cpu)
166{
167 int enable_bit, pci_offset, ret;
168 uint32_t val;
169
170 ret = amd_fam14h_get_pci_info(state, &pci_offset, &enable_bit, cpu);
171 if (ret)
172 return ret;
173
174 val = pci_read_long(amd_fam14h_pci_dev, pci_offset);
175 dprint("%s: offset: 0x%x %u\n", state->name, pci_offset, val);
176 if (state->id == NBP1) {
177 /* was the bit whether NBP1 got entered set? */
178 nbp1_entered = (val & (1 << PCI_NBP1_ACTIVE_BIT)) |
179 (val & (1 << PCI_NBP1_ENTERED_BIT));
180
181 dprint("NBP1 was %sentered - 0x%x - enable_bit: "
182 "%d - pci_offset: 0x%x\n",
183 nbp1_entered ? "" : "not ",
184 val, enable_bit, pci_offset);
185 return ret;
186 }
187 current_count[state->id][cpu] = val;
188
189 dprint("%s: Current - %llu (%u)\n", state->name,
190 current_count[state->id][cpu], cpu);
191 dprint("%s: Previous - %llu (%u)\n", state->name,
192 previous_count[state->id][cpu], cpu);
193
194 val = pci_read_long(amd_fam14h_pci_dev, PCI_MONITOR_ENABLE_REG);
195 val &= ~(1 << enable_bit);
196 pci_write_long(amd_fam14h_pci_dev, PCI_MONITOR_ENABLE_REG, val);
197
198 return 0;
199}
200
201static int fam14h_nbp1_count(unsigned int id, unsigned long long *count,
202 unsigned int cpu)
203{
204 if (id == NBP1) {
205 if (nbp1_entered)
206 *count = 1;
207 else
208 *count = 0;
209 return 0;
210 }
211 return -1;
212}
213static int fam14h_get_count_percent(unsigned int id, double *percent,
214 unsigned int cpu)
215{
216 unsigned long diff;
217
218 if (id >= AMD_FAM14H_STATE_NUM)
219 return -1;
220 /* residency count in 80ns -> divide through 12.5 to get us residency */
221 diff = current_count[id][cpu] - previous_count[id][cpu];
222
223 if (timediff == 0)
224 *percent = 0.0;
225 else
226 *percent = 100.0 * diff / timediff / 12.5;
227
228 dprint("Timediff: %llu - res~: %lu us - percent: %.2f %%\n",
229 timediff, diff * 10 / 125, *percent);
230
231 return 0;
232}
233
234static int amd_fam14h_start(void)
235{
236 int num, cpu;
237 clock_gettime(CLOCK_REALTIME, &start_time);
238 for (num = 0; num < AMD_FAM14H_STATE_NUM; num++) {
239 for (cpu = 0; cpu < cpu_count; cpu++)
240 amd_fam14h_init(&amd_fam14h_cstates[num], cpu);
241 }
242#ifdef DEBUG
243 clock_gettime(CLOCK_REALTIME, &dbg_time);
244 dbg_timediff = timespec_diff_us(start_time, dbg_time);
245 dprint("Enabling counters took: %lu us\n",
246 dbg_timediff);
247#endif
248 return 0;
249}
250
251static int amd_fam14h_stop(void)
252{
253 int num, cpu;
254 struct timespec end_time;
255
256 clock_gettime(CLOCK_REALTIME, &end_time);
257
258 for (num = 0; num < AMD_FAM14H_STATE_NUM; num++) {
259 for (cpu = 0; cpu < cpu_count; cpu++)
260 amd_fam14h_disable(&amd_fam14h_cstates[num], cpu);
261 }
262#ifdef DEBUG
263 clock_gettime(CLOCK_REALTIME, &dbg_time);
264 dbg_timediff = timespec_diff_us(end_time, dbg_time);
265 dprint("Disabling counters took: %lu ns\n", dbg_timediff);
266#endif
267 timediff = timespec_diff_us(start_time, end_time);
268 if (timediff / 1000 > OVERFLOW_MS)
269 print_overflow_err((unsigned int)timediff / 1000000,
270 OVERFLOW_MS / 1000);
271
272 return 0;
273}
274
275static int is_nbp1_capable(void)
276{
277 uint32_t val;
278 val = pci_read_long(amd_fam14h_pci_dev, PCI_NBP1_CAP_OFFSET);
279 return val & (1 << 31);
280}
281
282struct cpuidle_monitor *amd_fam14h_register(void)
283{
284 int num;
285
286 if (cpupower_cpu_info.vendor != X86_VENDOR_AMD)
287 return NULL;
288
289 if (cpupower_cpu_info.family == 0x14) {
290 if (cpu_count <= 0 || cpu_count > 2) {
291 fprintf(stderr, "AMD fam14h: Invalid cpu count: %d\n",
292 cpu_count);
293 return NULL;
294 }
295 } else
296 return NULL;
297
298 /* We do not alloc for nbp1 machine wide counter */
299 for (num = 0; num < AMD_FAM14H_STATE_NUM - 1; num++) {
300 previous_count[num] = calloc(cpu_count,
301 sizeof(unsigned long long));
302 current_count[num] = calloc(cpu_count,
303 sizeof(unsigned long long));
304 }
305
306 amd_fam14h_pci_dev = pci_acc_init(&pci_acc, pci_vendor_id, pci_dev_ids);
307 if (amd_fam14h_pci_dev == NULL || pci_acc == NULL)
308 return NULL;
309
310 if (!is_nbp1_capable())
311 amd_fam14h_monitor.hw_states_num = AMD_FAM14H_STATE_NUM - 1;
312
313 amd_fam14h_monitor.name_len = strlen(amd_fam14h_monitor.name);
314 return &amd_fam14h_monitor;
315}
316
317static void amd_fam14h_unregister(void)
318{
319 int num;
320 for (num = 0; num < AMD_FAM14H_STATE_NUM - 1; num++) {
321 free(previous_count[num]);
322 free(current_count[num]);
323 }
324 pci_cleanup(pci_acc);
325}
326
327struct cpuidle_monitor amd_fam14h_monitor = {
328 .name = "Ontario",
329 .hw_states = amd_fam14h_cstates,
330 .hw_states_num = AMD_FAM14H_STATE_NUM,
331 .start = amd_fam14h_start,
332 .stop = amd_fam14h_stop,
333 .do_register = amd_fam14h_register,
334 .unregister = amd_fam14h_unregister,
335 .needs_root = 1,
336 .overflow_s = OVERFLOW_MS / 1000,
337};
338#endif /* #if defined(__i386__) || defined(__x86_64__) */
diff --git a/tools/power/cpupower/utils/idle_monitor/cpuidle_sysfs.c b/tools/power/cpupower/utils/idle_monitor/cpuidle_sysfs.c
new file mode 100644
index 00000000000..bcd22a1a397
--- /dev/null
+++ b/tools/power/cpupower/utils/idle_monitor/cpuidle_sysfs.c
@@ -0,0 +1,196 @@
1/*
2 * (C) 2010,2011 Thomas Renninger <trenn@suse.de>, Novell Inc
3 *
4 * Licensed under the terms of the GNU GPL License version 2.
5 *
6 */
7
8#include <stdio.h>
9#include <stdlib.h>
10#include <stdint.h>
11#include <string.h>
12#include <limits.h>
13
14#include "helpers/sysfs.h"
15#include "helpers/helpers.h"
16#include "idle_monitor/cpupower-monitor.h"
17
18#define CPUIDLE_STATES_MAX 10
19static cstate_t cpuidle_cstates[CPUIDLE_STATES_MAX];
20struct cpuidle_monitor cpuidle_sysfs_monitor;
21
22static unsigned long long **previous_count;
23static unsigned long long **current_count;
24struct timespec start_time;
25static unsigned long long timediff;
26
27static int cpuidle_get_count_percent(unsigned int id, double *percent,
28 unsigned int cpu)
29{
30 unsigned long long statediff = current_count[cpu][id]
31 - previous_count[cpu][id];
32 dprint("%s: - diff: %llu - percent: %f (%u)\n",
33 cpuidle_cstates[id].name, timediff, *percent, cpu);
34
35 if (timediff == 0)
36 *percent = 0.0;
37 else
38 *percent = ((100.0 * statediff) / timediff);
39
40 dprint("%s: - timediff: %llu - statediff: %llu - percent: %f (%u)\n",
41 cpuidle_cstates[id].name, timediff, statediff, *percent, cpu);
42
43 return 0;
44}
45
46static int cpuidle_start(void)
47{
48 int cpu, state;
49 clock_gettime(CLOCK_REALTIME, &start_time);
50 for (cpu = 0; cpu < cpu_count; cpu++) {
51 for (state = 0; state < cpuidle_sysfs_monitor.hw_states_num;
52 state++) {
53 previous_count[cpu][state] =
54 sysfs_get_idlestate_time(cpu, state);
55 dprint("CPU %d - State: %d - Val: %llu\n",
56 cpu, state, previous_count[cpu][state]);
57 }
58 };
59 return 0;
60}
61
62static int cpuidle_stop(void)
63{
64 int cpu, state;
65 struct timespec end_time;
66 clock_gettime(CLOCK_REALTIME, &end_time);
67 timediff = timespec_diff_us(start_time, end_time);
68
69 for (cpu = 0; cpu < cpu_count; cpu++) {
70 for (state = 0; state < cpuidle_sysfs_monitor.hw_states_num;
71 state++) {
72 current_count[cpu][state] =
73 sysfs_get_idlestate_time(cpu, state);
74 dprint("CPU %d - State: %d - Val: %llu\n",
75 cpu, state, previous_count[cpu][state]);
76 }
77 };
78 return 0;
79}
80
81void fix_up_intel_idle_driver_name(char *tmp, int num)
82{
83 /* fix up cpuidle name for intel idle driver */
84 if (!strncmp(tmp, "NHM-", 4)) {
85 switch (num) {
86 case 1:
87 strcpy(tmp, "C1");
88 break;
89 case 2:
90 strcpy(tmp, "C3");
91 break;
92 case 3:
93 strcpy(tmp, "C6");
94 break;
95 }
96 } else if (!strncmp(tmp, "SNB-", 4)) {
97 switch (num) {
98 case 1:
99 strcpy(tmp, "C1");
100 break;
101 case 2:
102 strcpy(tmp, "C3");
103 break;
104 case 3:
105 strcpy(tmp, "C6");
106 break;
107 case 4:
108 strcpy(tmp, "C7");
109 break;
110 }
111 } else if (!strncmp(tmp, "ATM-", 4)) {
112 switch (num) {
113 case 1:
114 strcpy(tmp, "C1");
115 break;
116 case 2:
117 strcpy(tmp, "C2");
118 break;
119 case 3:
120 strcpy(tmp, "C4");
121 break;
122 case 4:
123 strcpy(tmp, "C6");
124 break;
125 }
126 }
127}
128
129static struct cpuidle_monitor *cpuidle_register(void)
130{
131 int num;
132 char *tmp;
133
134 /* Assume idle state count is the same for all CPUs */
135 cpuidle_sysfs_monitor.hw_states_num = sysfs_get_idlestate_count(0);
136
137 if (cpuidle_sysfs_monitor.hw_states_num <= 0)
138 return NULL;
139
140 for (num = 0; num < cpuidle_sysfs_monitor.hw_states_num; num++) {
141 tmp = sysfs_get_idlestate_name(0, num);
142 if (tmp == NULL)
143 continue;
144
145 fix_up_intel_idle_driver_name(tmp, num);
146 strncpy(cpuidle_cstates[num].name, tmp, CSTATE_NAME_LEN - 1);
147 free(tmp);
148
149 tmp = sysfs_get_idlestate_desc(0, num);
150 if (tmp == NULL)
151 continue;
152 strncpy(cpuidle_cstates[num].desc, tmp, CSTATE_DESC_LEN - 1);
153 free(tmp);
154
155 cpuidle_cstates[num].range = RANGE_THREAD;
156 cpuidle_cstates[num].id = num;
157 cpuidle_cstates[num].get_count_percent =
158 cpuidle_get_count_percent;
159 };
160
161 /* Free this at program termination */
162 previous_count = malloc(sizeof(long long *) * cpu_count);
163 current_count = malloc(sizeof(long long *) * cpu_count);
164 for (num = 0; num < cpu_count; num++) {
165 previous_count[num] = malloc(sizeof(long long) *
166 cpuidle_sysfs_monitor.hw_states_num);
167 current_count[num] = malloc(sizeof(long long) *
168 cpuidle_sysfs_monitor.hw_states_num);
169 }
170
171 cpuidle_sysfs_monitor.name_len = strlen(cpuidle_sysfs_monitor.name);
172 return &cpuidle_sysfs_monitor;
173}
174
175void cpuidle_unregister(void)
176{
177 int num;
178
179 for (num = 0; num < cpu_count; num++) {
180 free(previous_count[num]);
181 free(current_count[num]);
182 }
183 free(previous_count);
184 free(current_count);
185}
186
187struct cpuidle_monitor cpuidle_sysfs_monitor = {
188 .name = "Idle_Stats",
189 .hw_states = cpuidle_cstates,
190 .start = cpuidle_start,
191 .stop = cpuidle_stop,
192 .do_register = cpuidle_register,
193 .unregister = cpuidle_unregister,
194 .needs_root = 0,
195 .overflow_s = UINT_MAX,
196};
diff --git a/tools/power/cpupower/utils/idle_monitor/cpupower-monitor.c b/tools/power/cpupower/utils/idle_monitor/cpupower-monitor.c
new file mode 100644
index 00000000000..0d6571e418d
--- /dev/null
+++ b/tools/power/cpupower/utils/idle_monitor/cpupower-monitor.c
@@ -0,0 +1,440 @@
1/*
2 * (C) 2010,2011 Thomas Renninger <trenn@suse.de>, Novell Inc.
3 *
4 * Licensed under the terms of the GNU GPL License version 2.
5 *
6 * Output format inspired by Len Brown's <lenb@kernel.org> turbostat tool.
7 *
8 */
9
10
11#include <stdio.h>
12#include <unistd.h>
13#include <stdlib.h>
14#include <string.h>
15#include <time.h>
16#include <signal.h>
17#include <sys/types.h>
18#include <sys/wait.h>
19#include <libgen.h>
20
21#include "idle_monitor/cpupower-monitor.h"
22#include "idle_monitor/idle_monitors.h"
23#include "helpers/helpers.h"
24
25/* Define pointers to all monitors. */
26#define DEF(x) & x ## _monitor ,
27struct cpuidle_monitor *all_monitors[] = {
28#include "idle_monitors.def"
290
30};
31
32static struct cpuidle_monitor *monitors[MONITORS_MAX];
33static unsigned int avail_monitors;
34
35static char *progname;
36
37enum operation_mode_e { list = 1, show, show_all };
38static int mode;
39static int interval = 1;
40static char *show_monitors_param;
41static struct cpupower_topology cpu_top;
42
43/* ToDo: Document this in the manpage */
44static char range_abbr[RANGE_MAX] = { 'T', 'C', 'P', 'M', };
45
46static void print_wrong_arg_exit(void)
47{
48 printf(_("invalid or unknown argument\n"));
49 exit(EXIT_FAILURE);
50}
51
52long long timespec_diff_us(struct timespec start, struct timespec end)
53{
54 struct timespec temp;
55 if ((end.tv_nsec - start.tv_nsec) < 0) {
56 temp.tv_sec = end.tv_sec - start.tv_sec - 1;
57 temp.tv_nsec = 1000000000 + end.tv_nsec - start.tv_nsec;
58 } else {
59 temp.tv_sec = end.tv_sec - start.tv_sec;
60 temp.tv_nsec = end.tv_nsec - start.tv_nsec;
61 }
62 return (temp.tv_sec * 1000000) + (temp.tv_nsec / 1000);
63}
64
65void print_n_spaces(int n)
66{
67 int x;
68 for (x = 0; x < n; x++)
69 printf(" ");
70}
71
72/* size of s must be at least n + 1 */
73int fill_string_with_spaces(char *s, int n)
74{
75 int len = strlen(s);
76 if (len > n)
77 return -1;
78 for (; len < n; len++)
79 s[len] = ' ';
80 s[len] = '\0';
81 return 0;
82}
83
84void print_header(int topology_depth)
85{
86 int unsigned mon;
87 int state, need_len, pr_mon_len;
88 cstate_t s;
89 char buf[128] = "";
90 int percent_width = 4;
91
92 fill_string_with_spaces(buf, topology_depth * 5 - 1);
93 printf("%s|", buf);
94
95 for (mon = 0; mon < avail_monitors; mon++) {
96 pr_mon_len = 0;
97 need_len = monitors[mon]->hw_states_num * (percent_width + 3)
98 - 1;
99 if (mon != 0) {
100 printf("|| ");
101 need_len--;
102 }
103 sprintf(buf, "%s", monitors[mon]->name);
104 fill_string_with_spaces(buf, need_len);
105 printf("%s", buf);
106 }
107 printf("\n");
108
109 if (topology_depth > 2)
110 printf("PKG |");
111 if (topology_depth > 1)
112 printf("CORE|");
113 if (topology_depth > 0)
114 printf("CPU |");
115
116 for (mon = 0; mon < avail_monitors; mon++) {
117 if (mon != 0)
118 printf("|| ");
119 else
120 printf(" ");
121 for (state = 0; state < monitors[mon]->hw_states_num; state++) {
122 if (state != 0)
123 printf(" | ");
124 s = monitors[mon]->hw_states[state];
125 sprintf(buf, "%s", s.name);
126 fill_string_with_spaces(buf, percent_width);
127 printf("%s", buf);
128 }
129 printf(" ");
130 }
131 printf("\n");
132}
133
134
135void print_results(int topology_depth, int cpu)
136{
137 unsigned int mon;
138 int state, ret;
139 double percent;
140 unsigned long long result;
141 cstate_t s;
142
143 /* Be careful CPUs may got resorted for pkg value do not just use cpu */
144 if (!bitmask_isbitset(cpus_chosen, cpu_top.core_info[cpu].cpu))
145 return;
146
147 if (topology_depth > 2)
148 printf("%4d|", cpu_top.core_info[cpu].pkg);
149 if (topology_depth > 1)
150 printf("%4d|", cpu_top.core_info[cpu].core);
151 if (topology_depth > 0)
152 printf("%4d|", cpu_top.core_info[cpu].cpu);
153
154 for (mon = 0; mon < avail_monitors; mon++) {
155 if (mon != 0)
156 printf("||");
157
158 for (state = 0; state < monitors[mon]->hw_states_num; state++) {
159 if (state != 0)
160 printf("|");
161
162 s = monitors[mon]->hw_states[state];
163
164 if (s.get_count_percent) {
165 ret = s.get_count_percent(s.id, &percent,
166 cpu_top.core_info[cpu].cpu);
167 if (ret)
168 printf("******");
169 else if (percent >= 100.0)
170 printf("%6.1f", percent);
171 else
172 printf("%6.2f", percent);
173 } else if (s.get_count) {
174 ret = s.get_count(s.id, &result,
175 cpu_top.core_info[cpu].cpu);
176 if (ret)
177 printf("******");
178 else
179 printf("%6llu", result);
180 } else {
181 printf(_("Monitor %s, Counter %s has no count "
182 "function. Implementation error\n"),
183 monitors[mon]->name, s.name);
184 exit(EXIT_FAILURE);
185 }
186 }
187 }
188 /*
189 * The monitor could still provide useful data, for example
190 * AMD HW counters partly sit in PCI config space.
191 * It's up to the monitor plug-in to check .is_online, this one
192 * is just for additional info.
193 */
194 if (!cpu_top.core_info[cpu].is_online) {
195 printf(_(" *is offline\n"));
196 return;
197 } else
198 printf("\n");
199}
200
201
202/* param: string passed by -m param (The list of monitors to show)
203 *
204 * Monitors must have been registered already, matching monitors
205 * are picked out and available monitors array is overridden
206 * with matching ones
207 *
208 * Monitors get sorted in the same order the user passes them
209*/
210
211static void parse_monitor_param(char *param)
212{
213 unsigned int num;
214 int mon, hits = 0;
215 char *tmp = param, *token;
216 struct cpuidle_monitor *tmp_mons[MONITORS_MAX];
217
218
219 for (mon = 0; mon < MONITORS_MAX; mon++, tmp = NULL) {
220 token = strtok(tmp, ",");
221 if (token == NULL)
222 break;
223 if (strlen(token) >= MONITOR_NAME_LEN) {
224 printf(_("%s: max monitor name length"
225 " (%d) exceeded\n"), token, MONITOR_NAME_LEN);
226 continue;
227 }
228
229 for (num = 0; num < avail_monitors; num++) {
230 if (!strcmp(monitors[num]->name, token)) {
231 dprint("Found requested monitor: %s\n", token);
232 tmp_mons[hits] = monitors[num];
233 hits++;
234 }
235 }
236 }
237 if (hits == 0) {
238 printf(_("No matching monitor found in %s, "
239 "try -l option\n"), param);
240 exit(EXIT_FAILURE);
241 }
242 /* Override detected/registerd monitors array with requested one */
243 memcpy(monitors, tmp_mons,
244 sizeof(struct cpuidle_monitor *) * MONITORS_MAX);
245 avail_monitors = hits;
246}
247
248void list_monitors(void)
249{
250 unsigned int mon;
251 int state;
252 cstate_t s;
253
254 for (mon = 0; mon < avail_monitors; mon++) {
255 printf(_("Monitor \"%s\" (%d states) - Might overflow after %u "
256 "s\n"),
257 monitors[mon]->name, monitors[mon]->hw_states_num,
258 monitors[mon]->overflow_s);
259
260 for (state = 0; state < monitors[mon]->hw_states_num; state++) {
261 s = monitors[mon]->hw_states[state];
262 /*
263 * ToDo show more state capabilities:
264 * percent, time (granlarity)
265 */
266 printf("%s\t[%c] -> %s\n", s.name, range_abbr[s.range],
267 gettext(s.desc));
268 }
269 }
270}
271
272int fork_it(char **argv)
273{
274 int status;
275 unsigned int num;
276 unsigned long long timediff;
277 pid_t child_pid;
278 struct timespec start, end;
279
280 child_pid = fork();
281 clock_gettime(CLOCK_REALTIME, &start);
282
283 for (num = 0; num < avail_monitors; num++)
284 monitors[num]->start();
285
286 if (!child_pid) {
287 /* child */
288 execvp(argv[0], argv);
289 } else {
290 /* parent */
291 if (child_pid == -1) {
292 perror("fork");
293 exit(1);
294 }
295
296 signal(SIGINT, SIG_IGN);
297 signal(SIGQUIT, SIG_IGN);
298 if (waitpid(child_pid, &status, 0) == -1) {
299 perror("wait");
300 exit(1);
301 }
302 }
303 clock_gettime(CLOCK_REALTIME, &end);
304 for (num = 0; num < avail_monitors; num++)
305 monitors[num]->stop();
306
307 timediff = timespec_diff_us(start, end);
308 if (WIFEXITED(status))
309 printf(_("%s took %.5f seconds and exited with status %d\n"),
310 argv[0], timediff / (1000.0 * 1000),
311 WEXITSTATUS(status));
312 return 0;
313}
314
315int do_interval_measure(int i)
316{
317 unsigned int num;
318
319 for (num = 0; num < avail_monitors; num++) {
320 dprint("HW C-state residency monitor: %s - States: %d\n",
321 monitors[num]->name, monitors[num]->hw_states_num);
322 monitors[num]->start();
323 }
324 sleep(i);
325 for (num = 0; num < avail_monitors; num++)
326 monitors[num]->stop();
327
328 return 0;
329}
330
331static void cmdline(int argc, char *argv[])
332{
333 int opt;
334 progname = basename(argv[0]);
335
336 while ((opt = getopt(argc, argv, "+li:m:")) != -1) {
337 switch (opt) {
338 case 'l':
339 if (mode)
340 print_wrong_arg_exit();
341 mode = list;
342 break;
343 case 'i':
344 /* only allow -i with -m or no option */
345 if (mode && mode != show)
346 print_wrong_arg_exit();
347 interval = atoi(optarg);
348 break;
349 case 'm':
350 if (mode)
351 print_wrong_arg_exit();
352 mode = show;
353 show_monitors_param = optarg;
354 break;
355 default:
356 print_wrong_arg_exit();
357 }
358 }
359 if (!mode)
360 mode = show_all;
361}
362
363int cmd_monitor(int argc, char **argv)
364{
365 unsigned int num;
366 struct cpuidle_monitor *test_mon;
367 int cpu;
368
369 cmdline(argc, argv);
370 cpu_count = get_cpu_topology(&cpu_top);
371 if (cpu_count < 0) {
372 printf(_("Cannot read number of available processors\n"));
373 return EXIT_FAILURE;
374 }
375
376 /* Default is: monitor all CPUs */
377 if (bitmask_isallclear(cpus_chosen))
378 bitmask_setall(cpus_chosen);
379
380 dprint("System has up to %d CPU cores\n", cpu_count);
381
382 for (num = 0; all_monitors[num]; num++) {
383 dprint("Try to register: %s\n", all_monitors[num]->name);
384 test_mon = all_monitors[num]->do_register();
385 if (test_mon) {
386 if (test_mon->needs_root && !run_as_root) {
387 fprintf(stderr, _("Available monitor %s needs "
388 "root access\n"), test_mon->name);
389 continue;
390 }
391 monitors[avail_monitors] = test_mon;
392 dprint("%s registered\n", all_monitors[num]->name);
393 avail_monitors++;
394 }
395 }
396
397 if (avail_monitors == 0) {
398 printf(_("No HW Cstate monitors found\n"));
399 return 1;
400 }
401
402 if (mode == list) {
403 list_monitors();
404 exit(EXIT_SUCCESS);
405 }
406
407 if (mode == show)
408 parse_monitor_param(show_monitors_param);
409
410 dprint("Packages: %d - Cores: %d - CPUs: %d\n",
411 cpu_top.pkgs, cpu_top.cores, cpu_count);
412
413 /*
414 * if any params left, it must be a command to fork
415 */
416 if (argc - optind)
417 fork_it(argv + optind);
418 else
419 do_interval_measure(interval);
420
421 /* ToDo: Topology parsing needs fixing first to do
422 this more generically */
423 if (cpu_top.pkgs > 1)
424 print_header(3);
425 else
426 print_header(1);
427
428 for (cpu = 0; cpu < cpu_count; cpu++) {
429 if (cpu_top.pkgs > 1)
430 print_results(3, cpu);
431 else
432 print_results(1, cpu);
433 }
434
435 for (num = 0; num < avail_monitors; num++)
436 monitors[num]->unregister();
437
438 cpu_topology_release(cpu_top);
439 return 0;
440}
diff --git a/tools/power/cpupower/utils/idle_monitor/cpupower-monitor.h b/tools/power/cpupower/utils/idle_monitor/cpupower-monitor.h
new file mode 100644
index 00000000000..9312ee1f2db
--- /dev/null
+++ b/tools/power/cpupower/utils/idle_monitor/cpupower-monitor.h
@@ -0,0 +1,68 @@
1/*
2 * (C) 2010,2011 Thomas Renninger <trenn@suse.de>, Novell Inc.
3 *
4 * Licensed under the terms of the GNU GPL License version 2.
5 *
6 */
7
8#ifndef __CPUIDLE_INFO_HW__
9#define __CPUIDLE_INFO_HW__
10
11#include <stdarg.h>
12#include <time.h>
13
14#include "idle_monitor/idle_monitors.h"
15
16#define MONITORS_MAX 20
17#define MONITOR_NAME_LEN 20
18#define CSTATE_NAME_LEN 5
19#define CSTATE_DESC_LEN 60
20
21int cpu_count;
22
23/* Hard to define the right names ...: */
24enum power_range_e {
25 RANGE_THREAD, /* Lowest in topology hierarcy, AMD: core, Intel: thread
26 kernel sysfs: cpu */
27 RANGE_CORE, /* AMD: unit, Intel: core, kernel_sysfs: core_id */
28 RANGE_PACKAGE, /* Package, processor socket */
29 RANGE_MACHINE, /* Machine, platform wide */
30 RANGE_MAX };
31
32typedef struct cstate {
33 int id;
34 enum power_range_e range;
35 char name[CSTATE_NAME_LEN];
36 char desc[CSTATE_DESC_LEN];
37
38 /* either provide a percentage or a general count */
39 int (*get_count_percent)(unsigned int self_id, double *percent,
40 unsigned int cpu);
41 int (*get_count)(unsigned int self_id, unsigned long long *count,
42 unsigned int cpu);
43} cstate_t;
44
45struct cpuidle_monitor {
46 /* Name must not contain whitespaces */
47 char name[MONITOR_NAME_LEN];
48 int name_len;
49 int hw_states_num;
50 cstate_t *hw_states;
51 int (*start) (void);
52 int (*stop) (void);
53 struct cpuidle_monitor* (*do_register) (void);
54 void (*unregister)(void);
55 unsigned int overflow_s;
56 int needs_root;
57};
58
59extern long long timespec_diff_us(struct timespec start, struct timespec end);
60
61#define print_overflow_err(mes, ov) \
62{ \
63 fprintf(stderr, gettext("Measure took %u seconds, but registers could " \
64 "overflow at %u seconds, results " \
65 "could be inaccurate\n"), mes, ov); \
66}
67
68#endif /* __CPUIDLE_INFO_HW__ */
diff --git a/tools/power/cpupower/utils/idle_monitor/idle_monitors.def b/tools/power/cpupower/utils/idle_monitor/idle_monitors.def
new file mode 100644
index 00000000000..e3f8d9b2b18
--- /dev/null
+++ b/tools/power/cpupower/utils/idle_monitor/idle_monitors.def
@@ -0,0 +1,7 @@
1#if defined(__i386__) || defined(__x86_64__)
2DEF(amd_fam14h)
3DEF(intel_nhm)
4DEF(intel_snb)
5DEF(mperf)
6#endif
7DEF(cpuidle_sysfs)
diff --git a/tools/power/cpupower/utils/idle_monitor/idle_monitors.h b/tools/power/cpupower/utils/idle_monitor/idle_monitors.h
new file mode 100644
index 00000000000..4fcdeb1e07e
--- /dev/null
+++ b/tools/power/cpupower/utils/idle_monitor/idle_monitors.h
@@ -0,0 +1,18 @@
1/*
2 * (C) 2010,2011 Thomas Renninger <trenn@suse.de>, Novell Inc.
3 *
4 * Licensed under the terms of the GNU GPL License version 2.
5 *
6 * Based on the idea from Michael Matz <matz@suse.de>
7 *
8 */
9
10#ifndef _CPUIDLE_IDLE_MONITORS_H_
11#define _CPUIDLE_IDLE_MONITORS_H_
12
13#define DEF(x) extern struct cpuidle_monitor x ##_monitor;
14#include "idle_monitors.def"
15#undef DEF
16extern struct cpuidle_monitor *all_monitors[];
17
18#endif /* _CPUIDLE_IDLE_MONITORS_H_ */
diff --git a/tools/power/cpupower/utils/idle_monitor/mperf_monitor.c b/tools/power/cpupower/utils/idle_monitor/mperf_monitor.c
new file mode 100644
index 00000000000..5650ab5a2c2
--- /dev/null
+++ b/tools/power/cpupower/utils/idle_monitor/mperf_monitor.c
@@ -0,0 +1,338 @@
1/*
2 * (C) 2010,2011 Thomas Renninger <trenn@suse.de>, Novell Inc.
3 *
4 * Licensed under the terms of the GNU GPL License version 2.
5 */
6
7#if defined(__i386__) || defined(__x86_64__)
8
9#include <stdio.h>
10#include <stdint.h>
11#include <stdlib.h>
12#include <string.h>
13#include <limits.h>
14
15#include <cpufreq.h>
16
17#include "helpers/helpers.h"
18#include "idle_monitor/cpupower-monitor.h"
19
20#define MSR_APERF 0xE8
21#define MSR_MPERF 0xE7
22
23#define MSR_TSC 0x10
24
25#define MSR_AMD_HWCR 0xc0010015
26
27enum mperf_id { C0 = 0, Cx, AVG_FREQ, MPERF_CSTATE_COUNT };
28
29static int mperf_get_count_percent(unsigned int self_id, double *percent,
30 unsigned int cpu);
31static int mperf_get_count_freq(unsigned int id, unsigned long long *count,
32 unsigned int cpu);
33static struct timespec time_start, time_end;
34
35static cstate_t mperf_cstates[MPERF_CSTATE_COUNT] = {
36 {
37 .name = "C0",
38 .desc = N_("Processor Core not idle"),
39 .id = C0,
40 .range = RANGE_THREAD,
41 .get_count_percent = mperf_get_count_percent,
42 },
43 {
44 .name = "Cx",
45 .desc = N_("Processor Core in an idle state"),
46 .id = Cx,
47 .range = RANGE_THREAD,
48 .get_count_percent = mperf_get_count_percent,
49 },
50
51 {
52 .name = "Freq",
53 .desc = N_("Average Frequency (including boost) in MHz"),
54 .id = AVG_FREQ,
55 .range = RANGE_THREAD,
56 .get_count = mperf_get_count_freq,
57 },
58};
59
60enum MAX_FREQ_MODE { MAX_FREQ_SYSFS, MAX_FREQ_TSC_REF };
61static int max_freq_mode;
62/*
63 * The max frequency mperf is ticking at (in C0), either retrieved via:
64 * 1) calculated after measurements if we know TSC ticks at mperf/P0 frequency
65 * 2) cpufreq /sys/devices/.../cpu0/cpufreq/cpuinfo_max_freq at init time
66 * 1. Is preferred as it also works without cpufreq subsystem (e.g. on Xen)
67 */
68static unsigned long max_frequency;
69
70static unsigned long long tsc_at_measure_start;
71static unsigned long long tsc_at_measure_end;
72static unsigned long long *mperf_previous_count;
73static unsigned long long *aperf_previous_count;
74static unsigned long long *mperf_current_count;
75static unsigned long long *aperf_current_count;
76
77/* valid flag for all CPUs. If a MSR read failed it will be zero */
78static int *is_valid;
79
80static int mperf_get_tsc(unsigned long long *tsc)
81{
82 int ret;
83 ret = read_msr(0, MSR_TSC, tsc);
84 if (ret)
85 dprint("Reading TSC MSR failed, returning %llu\n", *tsc);
86 return ret;
87}
88
89static int mperf_init_stats(unsigned int cpu)
90{
91 unsigned long long val;
92 int ret;
93
94 ret = read_msr(cpu, MSR_APERF, &val);
95 aperf_previous_count[cpu] = val;
96 ret |= read_msr(cpu, MSR_MPERF, &val);
97 mperf_previous_count[cpu] = val;
98 is_valid[cpu] = !ret;
99
100 return 0;
101}
102
103static int mperf_measure_stats(unsigned int cpu)
104{
105 unsigned long long val;
106 int ret;
107
108 ret = read_msr(cpu, MSR_APERF, &val);
109 aperf_current_count[cpu] = val;
110 ret |= read_msr(cpu, MSR_MPERF, &val);
111 mperf_current_count[cpu] = val;
112 is_valid[cpu] = !ret;
113
114 return 0;
115}
116
117static int mperf_get_count_percent(unsigned int id, double *percent,
118 unsigned int cpu)
119{
120 unsigned long long aperf_diff, mperf_diff, tsc_diff;
121 unsigned long long timediff;
122
123 if (!is_valid[cpu])
124 return -1;
125
126 if (id != C0 && id != Cx)
127 return -1;
128
129 mperf_diff = mperf_current_count[cpu] - mperf_previous_count[cpu];
130 aperf_diff = aperf_current_count[cpu] - aperf_previous_count[cpu];
131
132 if (max_freq_mode == MAX_FREQ_TSC_REF) {
133 tsc_diff = tsc_at_measure_end - tsc_at_measure_start;
134 *percent = 100.0 * mperf_diff / tsc_diff;
135 dprint("%s: TSC Ref - mperf_diff: %llu, tsc_diff: %llu\n",
136 mperf_cstates[id].name, mperf_diff, tsc_diff);
137 } else if (max_freq_mode == MAX_FREQ_SYSFS) {
138 timediff = timespec_diff_us(time_start, time_end);
139 *percent = 100.0 * mperf_diff / timediff;
140 dprint("%s: MAXFREQ - mperf_diff: %llu, time_diff: %llu\n",
141 mperf_cstates[id].name, mperf_diff, timediff);
142 } else
143 return -1;
144
145 if (id == Cx)
146 *percent = 100.0 - *percent;
147
148 dprint("%s: previous: %llu - current: %llu - (%u)\n",
149 mperf_cstates[id].name, mperf_diff, aperf_diff, cpu);
150 dprint("%s: %f\n", mperf_cstates[id].name, *percent);
151 return 0;
152}
153
154static int mperf_get_count_freq(unsigned int id, unsigned long long *count,
155 unsigned int cpu)
156{
157 unsigned long long aperf_diff, mperf_diff, time_diff, tsc_diff;
158
159 if (id != AVG_FREQ)
160 return 1;
161
162 if (!is_valid[cpu])
163 return -1;
164
165 mperf_diff = mperf_current_count[cpu] - mperf_previous_count[cpu];
166 aperf_diff = aperf_current_count[cpu] - aperf_previous_count[cpu];
167
168 if (max_freq_mode == MAX_FREQ_TSC_REF) {
169 /* Calculate max_freq from TSC count */
170 tsc_diff = tsc_at_measure_end - tsc_at_measure_start;
171 time_diff = timespec_diff_us(time_start, time_end);
172 max_frequency = tsc_diff / time_diff;
173 }
174
175 *count = max_frequency * ((double)aperf_diff / mperf_diff);
176 dprint("%s: Average freq based on %s maximum frequency:\n",
177 mperf_cstates[id].name,
178 (max_freq_mode == MAX_FREQ_TSC_REF) ? "TSC calculated" : "sysfs read");
179 dprint("%max_frequency: %lu", max_frequency);
180 dprint("aperf_diff: %llu\n", aperf_diff);
181 dprint("mperf_diff: %llu\n", mperf_diff);
182 dprint("avg freq: %llu\n", *count);
183 return 0;
184}
185
186static int mperf_start(void)
187{
188 int cpu;
189 unsigned long long dbg;
190
191 clock_gettime(CLOCK_REALTIME, &time_start);
192 mperf_get_tsc(&tsc_at_measure_start);
193
194 for (cpu = 0; cpu < cpu_count; cpu++)
195 mperf_init_stats(cpu);
196
197 mperf_get_tsc(&dbg);
198 dprint("TSC diff: %llu\n", dbg - tsc_at_measure_start);
199 return 0;
200}
201
202static int mperf_stop(void)
203{
204 unsigned long long dbg;
205 int cpu;
206
207 for (cpu = 0; cpu < cpu_count; cpu++)
208 mperf_measure_stats(cpu);
209
210 mperf_get_tsc(&tsc_at_measure_end);
211 clock_gettime(CLOCK_REALTIME, &time_end);
212
213 mperf_get_tsc(&dbg);
214 dprint("TSC diff: %llu\n", dbg - tsc_at_measure_end);
215
216 return 0;
217}
218
219/*
220 * Mperf register is defined to tick at P0 (maximum) frequency
221 *
222 * Instead of reading out P0 which can be tricky to read out from HW,
223 * we use TSC counter if it reliably ticks at P0/mperf frequency.
224 *
225 * Still try to fall back to:
226 * /sys/devices/system/cpu/cpu0/cpufreq/cpuinfo_max_freq
227 * on older Intel HW without invariant TSC feature.
228 * Or on AMD machines where TSC does not tick at P0 (do not exist yet, but
229 * it's still double checked (MSR_AMD_HWCR)).
230 *
231 * On these machines the user would still get useful mperf
232 * stats when acpi-cpufreq driver is loaded.
233 */
234static int init_maxfreq_mode(void)
235{
236 int ret;
237 unsigned long long hwcr;
238 unsigned long min;
239
240 if (!cpupower_cpu_info.caps & CPUPOWER_CAP_INV_TSC)
241 goto use_sysfs;
242
243 if (cpupower_cpu_info.vendor == X86_VENDOR_AMD) {
244 /* MSR_AMD_HWCR tells us whether TSC runs at P0/mperf
245 * freq.
246 * A test whether hwcr is accessable/available would be:
247 * (cpupower_cpu_info.family > 0x10 ||
248 * cpupower_cpu_info.family == 0x10 &&
249 * cpupower_cpu_info.model >= 0x2))
250 * This should be the case for all aperf/mperf
251 * capable AMD machines and is therefore safe to test here.
252 * Compare with Linus kernel git commit: acf01734b1747b1ec4
253 */
254 ret = read_msr(0, MSR_AMD_HWCR, &hwcr);
255 /*
256 * If the MSR read failed, assume a Xen system that did
257 * not explicitly provide access to it and assume TSC works
258 */
259 if (ret != 0) {
260 dprint("TSC read 0x%x failed - assume TSC working\n",
261 MSR_AMD_HWCR);
262 return 0;
263 } else if (1 & (hwcr >> 24)) {
264 max_freq_mode = MAX_FREQ_TSC_REF;
265 return 0;
266 } else { /* Use sysfs max frequency if available */ }
267 } else if (cpupower_cpu_info.vendor == X86_VENDOR_INTEL) {
268 /*
269 * On Intel we assume mperf (in C0) is ticking at same
270 * rate than TSC
271 */
272 max_freq_mode = MAX_FREQ_TSC_REF;
273 return 0;
274 }
275use_sysfs:
276 if (cpufreq_get_hardware_limits(0, &min, &max_frequency)) {
277 dprint("Cannot retrieve max freq from cpufreq kernel "
278 "subsystem\n");
279 return -1;
280 }
281 max_freq_mode = MAX_FREQ_SYSFS;
282 return 0;
283}
284
285/*
286 * This monitor provides:
287 *
288 * 1) Average frequency a CPU resided in
289 * This always works if the CPU has aperf/mperf capabilities
290 *
291 * 2) C0 and Cx (any sleep state) time a CPU resided in
292 * Works if mperf timer stops ticking in sleep states which
293 * seem to be the case on all current HW.
294 * Both is directly retrieved from HW registers and is independent
295 * from kernel statistics.
296 */
297struct cpuidle_monitor mperf_monitor;
298struct cpuidle_monitor *mperf_register(void)
299{
300 if (!(cpupower_cpu_info.caps & CPUPOWER_CAP_APERF))
301 return NULL;
302
303 if (init_maxfreq_mode())
304 return NULL;
305
306 /* Free this at program termination */
307 is_valid = calloc(cpu_count, sizeof(int));
308 mperf_previous_count = calloc(cpu_count, sizeof(unsigned long long));
309 aperf_previous_count = calloc(cpu_count, sizeof(unsigned long long));
310 mperf_current_count = calloc(cpu_count, sizeof(unsigned long long));
311 aperf_current_count = calloc(cpu_count, sizeof(unsigned long long));
312
313 mperf_monitor.name_len = strlen(mperf_monitor.name);
314 return &mperf_monitor;
315}
316
317void mperf_unregister(void)
318{
319 free(mperf_previous_count);
320 free(aperf_previous_count);
321 free(mperf_current_count);
322 free(aperf_current_count);
323 free(is_valid);
324}
325
326struct cpuidle_monitor mperf_monitor = {
327 .name = "Mperf",
328 .hw_states_num = MPERF_CSTATE_COUNT,
329 .hw_states = mperf_cstates,
330 .start = mperf_start,
331 .stop = mperf_stop,
332 .do_register = mperf_register,
333 .unregister = mperf_unregister,
334 .needs_root = 1,
335 .overflow_s = 922000000 /* 922337203 seconds TSC overflow
336 at 20GHz */
337};
338#endif /* #if defined(__i386__) || defined(__x86_64__) */
diff --git a/tools/power/cpupower/utils/idle_monitor/nhm_idle.c b/tools/power/cpupower/utils/idle_monitor/nhm_idle.c
new file mode 100644
index 00000000000..d2a91dd0d56
--- /dev/null
+++ b/tools/power/cpupower/utils/idle_monitor/nhm_idle.c
@@ -0,0 +1,216 @@
1/*
2 * (C) 2010,2011 Thomas Renninger <trenn@suse.de>, Novell Inc.
3 *
4 * Licensed under the terms of the GNU GPL License version 2.
5 *
6 * Based on Len Brown's <lenb@kernel.org> turbostat tool.
7 */
8
9#if defined(__i386__) || defined(__x86_64__)
10
11#include <stdio.h>
12#include <stdint.h>
13#include <stdlib.h>
14#include <string.h>
15
16#include "helpers/helpers.h"
17#include "idle_monitor/cpupower-monitor.h"
18
19#define MSR_PKG_C3_RESIDENCY 0x3F8
20#define MSR_PKG_C6_RESIDENCY 0x3F9
21#define MSR_CORE_C3_RESIDENCY 0x3FC
22#define MSR_CORE_C6_RESIDENCY 0x3FD
23
24#define MSR_TSC 0x10
25
26#define NHM_CSTATE_COUNT 4
27
28enum intel_nhm_id { C3 = 0, C6, PC3, PC6, TSC = 0xFFFF };
29
30static int nhm_get_count_percent(unsigned int self_id, double *percent,
31 unsigned int cpu);
32
33static cstate_t nhm_cstates[NHM_CSTATE_COUNT] = {
34 {
35 .name = "C3",
36 .desc = N_("Processor Core C3"),
37 .id = C3,
38 .range = RANGE_CORE,
39 .get_count_percent = nhm_get_count_percent,
40 },
41 {
42 .name = "C6",
43 .desc = N_("Processor Core C6"),
44 .id = C6,
45 .range = RANGE_CORE,
46 .get_count_percent = nhm_get_count_percent,
47 },
48
49 {
50 .name = "PC3",
51 .desc = N_("Processor Package C3"),
52 .id = PC3,
53 .range = RANGE_PACKAGE,
54 .get_count_percent = nhm_get_count_percent,
55 },
56 {
57 .name = "PC6",
58 .desc = N_("Processor Package C6"),
59 .id = PC6,
60 .range = RANGE_PACKAGE,
61 .get_count_percent = nhm_get_count_percent,
62 },
63};
64
65static unsigned long long tsc_at_measure_start;
66static unsigned long long tsc_at_measure_end;
67static unsigned long long *previous_count[NHM_CSTATE_COUNT];
68static unsigned long long *current_count[NHM_CSTATE_COUNT];
69/* valid flag for all CPUs. If a MSR read failed it will be zero */
70static int *is_valid;
71
72static int nhm_get_count(enum intel_nhm_id id, unsigned long long *val,
73 unsigned int cpu)
74{
75 int msr;
76
77 switch (id) {
78 case C3:
79 msr = MSR_CORE_C3_RESIDENCY;
80 break;
81 case C6:
82 msr = MSR_CORE_C6_RESIDENCY;
83 break;
84 case PC3:
85 msr = MSR_PKG_C3_RESIDENCY;
86 break;
87 case PC6:
88 msr = MSR_PKG_C6_RESIDENCY;
89 break;
90 case TSC:
91 msr = MSR_TSC;
92 break;
93 default:
94 return -1;
95 };
96 if (read_msr(cpu, msr, val))
97 return -1;
98
99 return 0;
100}
101
102static int nhm_get_count_percent(unsigned int id, double *percent,
103 unsigned int cpu)
104{
105 *percent = 0.0;
106
107 if (!is_valid[cpu])
108 return -1;
109
110 *percent = (100.0 *
111 (current_count[id][cpu] - previous_count[id][cpu])) /
112 (tsc_at_measure_end - tsc_at_measure_start);
113
114 dprint("%s: previous: %llu - current: %llu - (%u)\n",
115 nhm_cstates[id].name, previous_count[id][cpu],
116 current_count[id][cpu], cpu);
117
118 dprint("%s: tsc_diff: %llu - count_diff: %llu - percent: %2.f (%u)\n",
119 nhm_cstates[id].name,
120 (unsigned long long) tsc_at_measure_end - tsc_at_measure_start,
121 current_count[id][cpu] - previous_count[id][cpu],
122 *percent, cpu);
123
124 return 0;
125}
126
127static int nhm_start(void)
128{
129 int num, cpu;
130 unsigned long long dbg, val;
131
132 nhm_get_count(TSC, &tsc_at_measure_start, 0);
133
134 for (num = 0; num < NHM_CSTATE_COUNT; num++) {
135 for (cpu = 0; cpu < cpu_count; cpu++) {
136 is_valid[cpu] = !nhm_get_count(num, &val, cpu);
137 previous_count[num][cpu] = val;
138 }
139 }
140 nhm_get_count(TSC, &dbg, 0);
141 dprint("TSC diff: %llu\n", dbg - tsc_at_measure_start);
142 return 0;
143}
144
145static int nhm_stop(void)
146{
147 unsigned long long val;
148 unsigned long long dbg;
149 int num, cpu;
150
151 nhm_get_count(TSC, &tsc_at_measure_end, 0);
152
153 for (num = 0; num < NHM_CSTATE_COUNT; num++) {
154 for (cpu = 0; cpu < cpu_count; cpu++) {
155 is_valid[cpu] = !nhm_get_count(num, &val, cpu);
156 current_count[num][cpu] = val;
157 }
158 }
159 nhm_get_count(TSC, &dbg, 0);
160 dprint("TSC diff: %llu\n", dbg - tsc_at_measure_end);
161
162 return 0;
163}
164
165struct cpuidle_monitor intel_nhm_monitor;
166
167struct cpuidle_monitor *intel_nhm_register(void)
168{
169 int num;
170
171 if (cpupower_cpu_info.vendor != X86_VENDOR_INTEL)
172 return NULL;
173
174 if (!(cpupower_cpu_info.caps & CPUPOWER_CAP_INV_TSC))
175 return NULL;
176
177 if (!(cpupower_cpu_info.caps & CPUPOWER_CAP_APERF))
178 return NULL;
179
180 /* Free this at program termination */
181 is_valid = calloc(cpu_count, sizeof(int));
182 for (num = 0; num < NHM_CSTATE_COUNT; num++) {
183 previous_count[num] = calloc(cpu_count,
184 sizeof(unsigned long long));
185 current_count[num] = calloc(cpu_count,
186 sizeof(unsigned long long));
187 }
188
189 intel_nhm_monitor.name_len = strlen(intel_nhm_monitor.name);
190 return &intel_nhm_monitor;
191}
192
193void intel_nhm_unregister(void)
194{
195 int num;
196
197 for (num = 0; num < NHM_CSTATE_COUNT; num++) {
198 free(previous_count[num]);
199 free(current_count[num]);
200 }
201 free(is_valid);
202}
203
204struct cpuidle_monitor intel_nhm_monitor = {
205 .name = "Nehalem",
206 .hw_states_num = NHM_CSTATE_COUNT,
207 .hw_states = nhm_cstates,
208 .start = nhm_start,
209 .stop = nhm_stop,
210 .do_register = intel_nhm_register,
211 .unregister = intel_nhm_unregister,
212 .needs_root = 1,
213 .overflow_s = 922000000 /* 922337203 seconds TSC overflow
214 at 20GHz */
215};
216#endif
diff --git a/tools/power/cpupower/utils/idle_monitor/snb_idle.c b/tools/power/cpupower/utils/idle_monitor/snb_idle.c
new file mode 100644
index 00000000000..a1bc07cd53e
--- /dev/null
+++ b/tools/power/cpupower/utils/idle_monitor/snb_idle.c
@@ -0,0 +1,190 @@
1/*
2 * (C) 2010,2011 Thomas Renninger <trenn@suse.de>, Novell Inc.
3 *
4 * Licensed under the terms of the GNU GPL License version 2.
5 *
6 * Based on Len Brown's <lenb@kernel.org> turbostat tool.
7 */
8
9#if defined(__i386__) || defined(__x86_64__)
10
11#include <stdio.h>
12#include <stdint.h>
13#include <stdlib.h>
14#include <string.h>
15
16#include "helpers/helpers.h"
17#include "idle_monitor/cpupower-monitor.h"
18
19#define MSR_PKG_C2_RESIDENCY 0x60D
20#define MSR_PKG_C7_RESIDENCY 0x3FA
21#define MSR_CORE_C7_RESIDENCY 0x3FE
22
23#define MSR_TSC 0x10
24
25enum intel_snb_id { C7 = 0, PC2, PC7, SNB_CSTATE_COUNT, TSC = 0xFFFF };
26
27static int snb_get_count_percent(unsigned int self_id, double *percent,
28 unsigned int cpu);
29
30static cstate_t snb_cstates[SNB_CSTATE_COUNT] = {
31 {
32 .name = "C7",
33 .desc = N_("Processor Core C7"),
34 .id = C7,
35 .range = RANGE_CORE,
36 .get_count_percent = snb_get_count_percent,
37 },
38 {
39 .name = "PC2",
40 .desc = N_("Processor Package C2"),
41 .id = PC2,
42 .range = RANGE_PACKAGE,
43 .get_count_percent = snb_get_count_percent,
44 },
45 {
46 .name = "PC7",
47 .desc = N_("Processor Package C7"),
48 .id = PC7,
49 .range = RANGE_PACKAGE,
50 .get_count_percent = snb_get_count_percent,
51 },
52};
53
54static unsigned long long tsc_at_measure_start;
55static unsigned long long tsc_at_measure_end;
56static unsigned long long *previous_count[SNB_CSTATE_COUNT];
57static unsigned long long *current_count[SNB_CSTATE_COUNT];
58/* valid flag for all CPUs. If a MSR read failed it will be zero */
59static int *is_valid;
60
61static int snb_get_count(enum intel_snb_id id, unsigned long long *val,
62 unsigned int cpu)
63{
64 int msr;
65
66 switch (id) {
67 case C7:
68 msr = MSR_CORE_C7_RESIDENCY;
69 break;
70 case PC2:
71 msr = MSR_PKG_C2_RESIDENCY;
72 break;
73 case PC7:
74 msr = MSR_PKG_C7_RESIDENCY;
75 break;
76 case TSC:
77 msr = MSR_TSC;
78 break;
79 default:
80 return -1;
81 };
82 if (read_msr(cpu, msr, val))
83 return -1;
84 return 0;
85}
86
87static int snb_get_count_percent(unsigned int id, double *percent,
88 unsigned int cpu)
89{
90 *percent = 0.0;
91
92 if (!is_valid[cpu])
93 return -1;
94
95 *percent = (100.0 *
96 (current_count[id][cpu] - previous_count[id][cpu])) /
97 (tsc_at_measure_end - tsc_at_measure_start);
98
99 dprint("%s: previous: %llu - current: %llu - (%u)\n",
100 snb_cstates[id].name, previous_count[id][cpu],
101 current_count[id][cpu], cpu);
102
103 dprint("%s: tsc_diff: %llu - count_diff: %llu - percent: %2.f (%u)\n",
104 snb_cstates[id].name,
105 (unsigned long long) tsc_at_measure_end - tsc_at_measure_start,
106 current_count[id][cpu] - previous_count[id][cpu],
107 *percent, cpu);
108
109 return 0;
110}
111
112static int snb_start(void)
113{
114 int num, cpu;
115 unsigned long long val;
116
117 for (num = 0; num < SNB_CSTATE_COUNT; num++) {
118 for (cpu = 0; cpu < cpu_count; cpu++) {
119 snb_get_count(num, &val, cpu);
120 previous_count[num][cpu] = val;
121 }
122 }
123 snb_get_count(TSC, &tsc_at_measure_start, 0);
124 return 0;
125}
126
127static int snb_stop(void)
128{
129 unsigned long long val;
130 int num, cpu;
131
132 snb_get_count(TSC, &tsc_at_measure_end, 0);
133
134 for (num = 0; num < SNB_CSTATE_COUNT; num++) {
135 for (cpu = 0; cpu < cpu_count; cpu++) {
136 is_valid[cpu] = !snb_get_count(num, &val, cpu);
137 current_count[num][cpu] = val;
138 }
139 }
140 return 0;
141}
142
143struct cpuidle_monitor intel_snb_monitor;
144
145static struct cpuidle_monitor *snb_register(void)
146{
147 int num;
148
149 if (cpupower_cpu_info.vendor != X86_VENDOR_INTEL
150 || cpupower_cpu_info.family != 6)
151 return NULL;
152
153 if (cpupower_cpu_info.model != 0x2A
154 && cpupower_cpu_info.model != 0x2D)
155 return NULL;
156
157 is_valid = calloc(cpu_count, sizeof(int));
158 for (num = 0; num < SNB_CSTATE_COUNT; num++) {
159 previous_count[num] = calloc(cpu_count,
160 sizeof(unsigned long long));
161 current_count[num] = calloc(cpu_count,
162 sizeof(unsigned long long));
163 }
164 intel_snb_monitor.name_len = strlen(intel_snb_monitor.name);
165 return &intel_snb_monitor;
166}
167
168void snb_unregister(void)
169{
170 int num;
171 free(is_valid);
172 for (num = 0; num < SNB_CSTATE_COUNT; num++) {
173 free(previous_count[num]);
174 free(current_count[num]);
175 }
176}
177
178struct cpuidle_monitor intel_snb_monitor = {
179 .name = "SandyBridge",
180 .hw_states = snb_cstates,
181 .hw_states_num = SNB_CSTATE_COUNT,
182 .start = snb_start,
183 .stop = snb_stop,
184 .do_register = snb_register,
185 .unregister = snb_unregister,
186 .needs_root = 1,
187 .overflow_s = 922000000 /* 922337203 seconds TSC overflow
188 at 20GHz */
189};
190#endif /* defined(__i386__) || defined(__x86_64__) */
diff --git a/tools/power/cpupower/utils/version-gen.sh b/tools/power/cpupower/utils/version-gen.sh
new file mode 100755
index 00000000000..5ec41c55699
--- /dev/null
+++ b/tools/power/cpupower/utils/version-gen.sh
@@ -0,0 +1,35 @@
1#!/bin/sh
2#
3# Script which prints out the version to use for building cpupowerutils.
4# Must be called from tools/power/cpupower/
5#
6# Heavily based on tools/perf/util/PERF-VERSION-GEN .
7
8LF='
9'
10
11# First check if there is a .git to get the version from git describe
12# otherwise try to get the version from the kernel makefile
13if test -d ../../../.git -o -f ../../../.git &&
14 VN=$(git describe --abbrev=4 HEAD 2>/dev/null) &&
15 case "$VN" in
16 *$LF*) (exit 1) ;;
17 v[0-9]*)
18 git update-index -q --refresh
19 test -z "$(git diff-index --name-only HEAD --)" ||
20 VN="$VN-dirty" ;;
21 esac
22then
23 VN=$(echo "$VN" | sed -e 's/-/./g');
24else
25 eval $(grep '^VERSION[[:space:]]*=' ../../../Makefile|tr -d ' ')
26 eval $(grep '^PATCHLEVEL[[:space:]]*=' ../../../Makefile|tr -d ' ')
27 eval $(grep '^SUBLEVEL[[:space:]]*=' ../../../Makefile|tr -d ' ')
28 eval $(grep '^EXTRAVERSION[[:space:]]*=' ../../../Makefile|tr -d ' ')
29
30 VN="${VERSION}.${PATCHLEVEL}.${SUBLEVEL}${EXTRAVERSION}"
31fi
32
33VN=$(expr "$VN" : v*'\(.*\)')
34
35echo $VN