diff options
author | Linus Torvalds <torvalds@linux-foundation.org> | 2011-07-31 06:23:40 -1000 |
---|---|---|
committer | Linus Torvalds <torvalds@linux-foundation.org> | 2011-07-31 06:23:40 -1000 |
commit | 4d8a93c7e542c364b1c2ad1dd406ede85080eab9 (patch) | |
tree | 313d1dd3dec890b79b98a9ee420b17f6967db9fc /tools | |
parent | f33c596a2f921696391801b637ed50d514634079 (diff) | |
parent | 029e9f73667f9b4661ac9886f706d75d26850260 (diff) |
Merge git://git.kernel.org/pub/scm/linux/kernel/git/brodo/cpupowerutils
* git://git.kernel.org/pub/scm/linux/kernel/git/brodo/cpupowerutils:
cpupower: Do detect IDA (opportunistic processor performance) via cpuid
cpupower: Show Intel turbo ratio support via ./cpupower frequency-info
cpupowerutils: increase MAX_LINE_LEN
cpupower: Rename package from cpupowerutils to cpupower
cpupowerutils: Rename: libcpufreq->libcpupower
cpupowerutils: use kernel version-derived version string
cpupowerutils: utils - ConfigStyle bugfixes
cpupowerutils: helpers - ConfigStyle bugfixes
cpupowerutils: idle_monitor - ConfigStyle bugfixes
cpupowerutils: lib - ConfigStyle bugfixes
cpupowerutils: bench - ConfigStyle bugfixes
cpupowerutils: do not update po files on each and every compile
cpupowerutils: remove ccdv, use kernel quiet/verbose mechanism
cpupowerutils: use COPYING, CREDITS from top-level directory
cpupowerutils - cpufrequtils extended with quite some features
Diffstat (limited to 'tools')
70 files changed, 13855 insertions, 0 deletions
diff --git a/tools/power/cpupower/.gitignore b/tools/power/cpupower/.gitignore new file mode 100644 index 00000000000..8a83dd2ffc1 --- /dev/null +++ b/tools/power/cpupower/.gitignore @@ -0,0 +1,22 @@ +.libs +libcpupower.so +libcpupower.so.0 +libcpupower.so.0.0.0 +build/ccdv +cpufreq-info +cpufreq-set +cpufreq-aperf +lib/.libs +lib/cpufreq.lo +lib/cpufreq.o +lib/proc.lo +lib/proc.o +lib/sysfs.lo +lib/sysfs.o +po/cpupowerutils.pot +po/*.gmo +utils/cpufreq-info.o +utils/cpufreq-set.o +utils/cpufreq-aperf.o +cpupower +bench/cpufreq-bench diff --git a/tools/power/cpupower/Makefile b/tools/power/cpupower/Makefile new file mode 100644 index 00000000000..94c2cf0a98b --- /dev/null +++ b/tools/power/cpupower/Makefile @@ -0,0 +1,279 @@ +# Makefile for cpupower +# +# Copyright (C) 2005,2006 Dominik Brodowski <linux@dominikbrodowski.net> +# +# Based largely on the Makefile for udev by: +# +# Copyright (C) 2003,2004 Greg Kroah-Hartman <greg@kroah.com> +# +# This program is free software; you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation; version 2 of the License. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +# General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with this program; if not, write to the Free Software +# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA +# + +# --- CONFIGURATION BEGIN --- + +# Set the following to `true' to make a unstripped, unoptimized +# binary. Leave this set to `false' for production use. +DEBUG ?= false + +# make the build silent. Set this to something else to make it noisy again. +V ?= false + +# Internationalization support (output in different languages). +# Requires gettext. +NLS ?= true + +# Set the following to 'true' to build/install the +# cpufreq-bench benchmarking tool +CPUFRQ_BENCH ?= true + +# Prefix to the directories we're installing to +DESTDIR ?= + +# --- CONFIGURATION END --- + + + +# Package-related definitions. Distributions can modify the version +# and _should_ modify the PACKAGE_BUGREPORT definition + +VERSION= $(shell ./utils/version-gen.sh) +LIB_MAJ= 0.0.0 +LIB_MIN= 0 + +PACKAGE = cpupower +PACKAGE_BUGREPORT = cpufreq@vger.kernel.org +LANGUAGES = de fr it cs pt + + +# Directory definitions. These are default and most probably +# do not need to be changed. Please note that DESTDIR is +# added in front of any of them + +bindir ?= /usr/bin +sbindir ?= /usr/sbin +mandir ?= /usr/man +includedir ?= /usr/include +libdir ?= /usr/lib +localedir ?= /usr/share/locale +docdir ?= /usr/share/doc/packages/cpupower +confdir ?= /etc/ + +# Toolchain: what tools do we use, and what options do they need: + +CP = cp -fpR +INSTALL = /usr/bin/install -c +INSTALL_PROGRAM = ${INSTALL} +INSTALL_DATA = ${INSTALL} -m 644 +INSTALL_SCRIPT = ${INSTALL_PROGRAM} + +# If you are running a cross compiler, you may want to set this +# to something more interesting, like "arm-linux-". If you want +# to compile vs uClibc, that can be done here as well. +CROSS = #/usr/i386-linux-uclibc/usr/bin/i386-uclibc- +CC = $(CROSS)gcc +LD = $(CROSS)gcc +AR = $(CROSS)ar +STRIP = $(CROSS)strip +RANLIB = $(CROSS)ranlib +HOSTCC = gcc + + +# Now we set up the build system +# + +# set up PWD so that older versions of make will work with our build. +PWD = $(shell pwd) + +GMO_FILES = ${shell for HLANG in ${LANGUAGES}; do echo po/$$HLANG.gmo; done;} + +export CROSS CC AR STRIP RANLIB CFLAGS LDFLAGS LIB_OBJS + +# check if compiler option is supported +cc-supports = ${shell if $(CC) ${1} -S -o /dev/null -xc /dev/null > /dev/null 2>&1; then echo "$(1)"; fi;} + +# use '-Os' optimization if available, else use -O2 +OPTIMIZATION := $(call cc-supports,-Os,-O2) + +WARNINGS := -Wall -Wchar-subscripts -Wpointer-arith -Wsign-compare +WARNINGS += $(call cc-supports,-Wno-pointer-sign) +WARNINGS += $(call cc-supports,-Wdeclaration-after-statement) +WARNINGS += -Wshadow + +CFLAGS += -DVERSION=\"$(VERSION)\" -DPACKAGE=\"$(PACKAGE)\" \ + -DPACKAGE_BUGREPORT=\"$(PACKAGE_BUGREPORT)\" -D_GNU_SOURCE + +UTIL_OBJS = utils/helpers/amd.o utils/helpers/topology.o utils/helpers/msr.o \ + utils/helpers/sysfs.o utils/helpers/misc.o utils/helpers/cpuid.o \ + utils/helpers/pci.o utils/helpers/bitmask.o \ + utils/idle_monitor/nhm_idle.o utils/idle_monitor/snb_idle.o \ + utils/idle_monitor/amd_fam14h_idle.o utils/idle_monitor/cpuidle_sysfs.o \ + utils/idle_monitor/mperf_monitor.o utils/idle_monitor/cpupower-monitor.o \ + utils/cpupower.o utils/cpufreq-info.o utils/cpufreq-set.o \ + utils/cpupower-set.o utils/cpupower-info.o utils/cpuidle-info.o + +UTIL_HEADERS = utils/helpers/helpers.h utils/idle_monitor/cpupower-monitor.h \ + utils/helpers/bitmask.h \ + utils/idle_monitor/idle_monitors.h utils/idle_monitor/idle_monitors.def + +UTIL_SRC := $(UTIL_OBJS:.o=.c) + +LIB_HEADERS = lib/cpufreq.h lib/sysfs.h +LIB_SRC = lib/cpufreq.c lib/sysfs.c +LIB_OBJS = lib/cpufreq.o lib/sysfs.o + +CFLAGS += -pipe + +ifeq ($(strip $(NLS)),true) + INSTALL_NLS += install-gmo + COMPILE_NLS += create-gmo +endif + +ifeq ($(strip $(CPUFRQ_BENCH)),true) + INSTALL_BENCH += install-bench + COMPILE_BENCH += compile-bench +endif + +CFLAGS += $(WARNINGS) + +ifeq ($(strip $(V)),false) + QUIET=@ + ECHO=@echo +else + QUIET= + ECHO=@\# +endif +export QUIET ECHO + +# if DEBUG is enabled, then we do not strip or optimize +ifeq ($(strip $(DEBUG)),true) + CFLAGS += -O1 -g -DDEBUG + STRIPCMD = /bin/true -Since_we_are_debugging +else + CFLAGS += $(OPTIMIZATION) -fomit-frame-pointer + STRIPCMD = $(STRIP) -s --remove-section=.note --remove-section=.comment +endif + + +# the actual make rules + +all: libcpupower cpupower $(COMPILE_NLS) $(COMPILE_BENCH) + +lib/%.o: $(LIB_SRC) $(LIB_HEADERS) + $(ECHO) " CC " $@ + $(QUIET) $(CC) $(CFLAGS) -fPIC -o $@ -c lib/$*.c + +libcpupower.so.$(LIB_MAJ): $(LIB_OBJS) + $(ECHO) " LD " $@ + $(QUIET) $(CC) -shared $(CFLAGS) $(LDFLAGS) -o $@ \ + -Wl,-soname,libcpupower.so.$(LIB_MIN) $(LIB_OBJS) + @ln -sf $@ libcpupower.so + @ln -sf $@ libcpupower.so.$(LIB_MIN) + +libcpupower: libcpupower.so.$(LIB_MAJ) + +# Let all .o files depend on its .c file and all headers +# Might be worth to put this into utils/Makefile at some point of time +$(UTIL_OBJS): $(UTIL_HEADERS) + +.c.o: + $(ECHO) " CC " $@ + $(QUIET) $(CC) $(CFLAGS) -I./lib -I ./utils -o $@ -c $*.c + +cpupower: $(UTIL_OBJS) libcpupower.so.$(LIB_MAJ) + $(ECHO) " CC " $@ + $(QUIET) $(CC) $(CFLAGS) $(LDFLAGS) -lcpupower -lrt -lpci -L. -o $@ $(UTIL_OBJS) + $(QUIET) $(STRIPCMD) $@ + +po/$(PACKAGE).pot: $(UTIL_SRC) + $(ECHO) " GETTEXT " $@ + $(QUIET) xgettext --default-domain=$(PACKAGE) --add-comments \ + --keyword=_ --keyword=N_ $(UTIL_SRC) && \ + test -f $(PACKAGE).po && \ + mv -f $(PACKAGE).po po/$(PACKAGE).pot + +po/%.gmo: po/%.po + $(ECHO) " MSGFMT " $@ + $(QUIET) msgfmt -o $@ po/$*.po + +create-gmo: ${GMO_FILES} + +update-po: po/$(PACKAGE).pot + $(ECHO) " MSGMRG " $@ + $(QUIET) @for HLANG in $(LANGUAGES); do \ + echo -n "Updating $$HLANG "; \ + if msgmerge po/$$HLANG.po po/$(PACKAGE).pot -o \ + po/$$HLANG.new.po; then \ + mv -f po/$$HLANG.new.po po/$$HLANG.po; \ + else \ + echo "msgmerge for $$HLANG failed!"; \ + rm -f po/$$HLANG.new.po; \ + fi; \ + done; + +compile-bench: libcpupower.so.$(LIB_MAJ) + @V=$(V) confdir=$(confdir) $(MAKE) -C bench + +clean: + -find . \( -not -type d \) -and \( -name '*~' -o -name '*.[oas]' \) -type f -print \ + | xargs rm -f + -rm -f $(UTIL_BINS) + -rm -f $(IDLE_OBJS) + -rm -f cpupower + -rm -f libcpupower.so* + -rm -rf po/*.gmo po/*.pot + $(MAKE) -C bench clean + + +install-lib: + $(INSTALL) -d $(DESTDIR)${libdir} + $(CP) libcpupower.so* $(DESTDIR)${libdir}/ + $(INSTALL) -d $(DESTDIR)${includedir} + $(INSTALL_DATA) lib/cpufreq.h $(DESTDIR)${includedir}/cpufreq.h + +install-tools: + $(INSTALL) -d $(DESTDIR)${bindir} + $(INSTALL_PROGRAM) cpupower $(DESTDIR)${bindir} + +install-man: + $(INSTALL_DATA) -D man/cpupower.1 $(DESTDIR)${mandir}/man1/cpupower.1 + $(INSTALL_DATA) -D man/cpupower-frequency-set.1 $(DESTDIR)${mandir}/man1/cpupower-frequency-set.1 + $(INSTALL_DATA) -D man/cpupower-frequency-info.1 $(DESTDIR)${mandir}/man1/cpupower-frequency-info.1 + $(INSTALL_DATA) -D man/cpupower-set.1 $(DESTDIR)${mandir}/man1/cpupower-set.1 + $(INSTALL_DATA) -D man/cpupower-info.1 $(DESTDIR)${mandir}/man1/cpupower-info.1 + $(INSTALL_DATA) -D man/cpupower-monitor.1 $(DESTDIR)${mandir}/man1/cpupower-monitor.1 + +install-gmo: + $(INSTALL) -d $(DESTDIR)${localedir} + for HLANG in $(LANGUAGES); do \ + echo '$(INSTALL_DATA) -D po/$$HLANG.gmo $(DESTDIR)${localedir}/$$HLANG/LC_MESSAGES/cpupower.mo'; \ + $(INSTALL_DATA) -D po/$$HLANG.gmo $(DESTDIR)${localedir}/$$HLANG/LC_MESSAGES/cpupower.mo; \ + done; + +install-bench: + @#DESTDIR must be set from outside to survive + @sbindir=$(sbindir) bindir=$(bindir) docdir=$(docdir) confdir=$(confdir) $(MAKE) -C bench install + +install: all install-lib install-tools install-man $(INSTALL_NLS) $(INSTALL_BENCH) + +uninstall: + - rm -f $(DESTDIR)${libdir}/libcpupower.* + - rm -f $(DESTDIR)${includedir}/cpufreq.h + - rm -f $(DESTDIR)${bindir}/utils/cpupower + - rm -f $(DESTDIR)${mandir}/man1/cpufreq-set.1 + - rm -f $(DESTDIR)${mandir}/man1/cpufreq-info.1 + - for HLANG in $(LANGUAGES); do \ + rm -f $(DESTDIR)${localedir}/$$HLANG/LC_MESSAGES/cpupower.mo; \ + done; + +.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 @@ +The cpufrequtils package (homepage: +http://www.kernel.org/pub/linux/utils/kernel/cpufreq/cpufrequtils.html ) +consists of the following elements: + +requirements +------------ + +On x86 pciutils is needed at runtime (-lpci). +For compilation pciutils-devel (pci/pci.h) and a gcc version +providing cpuid.h is needed. +For both it's not explicitly checked for (yet). + + +libcpufreq +---------- + +"libcpufreq" is a library which offers a unified access method for userspace +tools and programs to the cpufreq core and drivers in the Linux kernel. This +allows for code reduction in userspace tools, a clean implementation of +the interaction to the cpufreq core, and support for both the sysfs and proc +interfaces [depending on configuration, see below]. + + +compilation and installation +---------------------------- + +make +su +make install + +should suffice on most systems. It builds default libcpufreq, +cpufreq-set and cpufreq-info files and installs them in /usr/lib and +/usr/bin, respectively. If you want to set up the paths differently and/or +want to configure the package to your specific needs, you need to open +"Makefile" with an editor of your choice and edit the block marked +CONFIGURATION. + + +THANKS +------ +Many thanks to Mattia Dongili who wrote the autotoolization and +libtoolization, the manpages and the italian language file for cpufrequtils; +to Dave Jones for his feedback and his dump_psb tool; to Bruno Ducrot for his +powernow-k8-decode and intel_gsic tools as well as the french language file; +and to various others commenting on the previous (pre-)releases of +cpufrequtils. + + + 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 @@ +ToDos sorted by priority: + +- Use bitmask functions to parse CPU topology more robust + (current implementation has issues on AMD) +- Try to read out boost states and frequencies on Intel +- Adjust README +- Somewhere saw the ability to read power consumption of + RAM from HW on Intel SandyBridge -> another monitor? +- Add another c1e debug idle monitor + -> Is by design racy with BIOS, but could be added + 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 @@ +LIBS = -L../ -lm -lcpupower + +OBJS = main.o parse.o system.o benchmark.o +CFLAGS += -D_GNU_SOURCE -I../lib -DDEFAULT_CONFIG_FILE=\"$(confdir)/cpufreq-bench.conf\" + +%.o : %.c + $(ECHO) " CC " $@ + $(QUIET) $(CC) -c $(CFLAGS) $< -o $@ + +cpufreq-bench: $(OBJS) + $(ECHO) " CC " $@ + $(QUIET) $(CC) -o $@ $(CFLAGS) $(OBJS) $(LIBS) + +all: cpufreq-bench + +install: + mkdir -p $(DESTDIR)/$(sbindir) + mkdir -p $(DESTDIR)/$(bindir) + mkdir -p $(DESTDIR)/$(docdir) + mkdir -p $(DESTDIR)/$(confdir) + install -m 755 cpufreq-bench $(DESTDIR)/$(sbindir)/cpufreq-bench + install -m 755 cpufreq-bench_plot.sh $(DESTDIR)/$(bindir)/cpufreq-bench_plot.sh + install -m 644 README-BENCH $(DESTDIR)/$(docdir)/README-BENCH + install -m 755 cpufreq-bench_script.sh $(DESTDIR)/$(docdir)/cpufreq-bench_script.sh + install -m 644 example.cfg $(DESTDIR)/$(confdir)/cpufreq-bench.conf + +clean: + rm -f *.o + 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 @@ +This is cpufreq-bench, a microbenchmark for the cpufreq framework. + +Purpose +======= + +What is this benchmark for: + - Identify worst case performance loss when doing dynamic frequency + scaling using Linux kernel governors + - Identify average reaction time of a governor to CPU load changes + - (Stress) Testing whether a cpufreq low level driver or governor works + as expected + - Identify cpufreq related performance regressions between kernels + - Possibly Real time priority testing? -> what happens if there are + processes with a higher prio than the governor's kernel thread + - ... + +What this benchmark does *not* cover: + - Power saving related regressions (In fact as better the performance + throughput is, the worse the power savings will be, but the first should + mostly count more...) + - Real world (workloads) + + +Description +=========== + +cpufreq-bench helps to test the condition of a given cpufreq governor. +For that purpose, it compares the performance governor to a configured +powersave module. + + +How it works +============ +You can specify load (100% CPU load) and sleep (0% CPU load) times in us which +will be run X time in a row (cycles): + + sleep=25000 + load=25000 + cycles=20 + +This part of the configuration file will create 25ms load/sleep turns, +repeated 20 times. + +Adding this: + sleep_step=25000 + load_step=25000 + rounds=5 +Will increase load and sleep time by 25ms 5 times. +Together you get following test: +25ms load/sleep time repeated 20 times (cycles). +50ms load/sleep time repeated 20 times (cycles). +.. +100ms load/sleep time repeated 20 times (cycles). + +First it is calibrated how long a specific CPU intensive calculation +takes on this machine and needs to be run in a loop using the performance +governor. +Then the above test runs are processed using the performance governor +and the governor to test. The time the calculation really needed +with the dynamic freq scaling governor is compared with the time needed |