diff --git a/add_idle_manpages_in_Makefile.patch b/add_idle_manpages_in_Makefile.patch new file mode 100644 index 0000000..307e6e2 --- /dev/null +++ b/add_idle_manpages_in_Makefile.patch @@ -0,0 +1,13 @@ +Index: cpupower-3.13/Makefile +=================================================================== +--- cpupower-3.13.orig/Makefile ++++ cpupower-3.13/Makefile +@@ -274,6 +274,8 @@ 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-idle-set.1 $(DESTDIR)${mandir}/man1/cpupower-idle-set.1 ++ $(INSTALL_DATA) -D man/cpupower-idle-info.1 $(DESTDIR)${mandir}/man1/cpupower-idle-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 diff --git a/cpupower-3.14.tar.bz2 b/cpupower-3.14.tar.bz2 new file mode 100644 index 0000000..006be9d --- /dev/null +++ b/cpupower-3.14.tar.bz2 @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:73a55c6cf0701186077c087f456ddd664b6c4601532d68f4bca63eb8eab418ee +size 71414 diff --git a/cpupower-always_try_to_load_msr_driver_as_root.patch b/cpupower-always_try_to_load_msr_driver_as_root.patch new file mode 100644 index 0000000..03c4d1c --- /dev/null +++ b/cpupower-always_try_to_load_msr_driver_as_root.patch @@ -0,0 +1,43 @@ +cpupower: If root, try to load msr driver on x86 if /dev/cpu/0/msr is not avail + +Signed-off-by: Thomas Renninger + +diff --git a/utils/cpupower.c b/utils/cpupower.c +index 7efc570..7cdcf88 100644 +--- a/utils/cpupower.c ++++ b/utils/cpupower.c +@@ -12,6 +12,9 @@ + #include + #include + #include ++#include ++#include ++#include + + #include "builtin.h" + #include "helpers/helpers.h" +@@ -169,6 +172,8 @@ int main(int argc, const char *argv[]) + { + const char *cmd; + unsigned int i, ret; ++ struct stat statbuf; ++ struct utsname uts; + + cpus_chosen = bitmask_alloc(sysconf(_SC_NPROCESSORS_CONF)); + +@@ -195,6 +200,15 @@ int main(int argc, const char *argv[]) + + get_cpu_info(0, &cpupower_cpu_info); + run_as_root = !getuid(); ++ if (run_as_root) { ++ ret = uname(&uts); ++ if (!ret && !strcmp(uts.machine, "x86_64") && ++ stat("/dev/cpu/0/msr", &statbuf) != 0) { ++ if (system("modprobe msr") == -1) ++ fprintf(stderr, _("MSR access not available.\n")); ++ } ++ } ++ + + for (i = 0; i < ARRAY_SIZE(commands); i++) { + struct cmd_struct *p = commands + i; diff --git a/cpupower-remove_mc_scheduler_bits.patch b/cpupower-remove_mc_scheduler_bits.patch new file mode 100644 index 0000000..2702ae9 --- /dev/null +++ b/cpupower-remove_mc_scheduler_bits.patch @@ -0,0 +1,234 @@ +cpupower: Remove mc and smt power aware scheduler info/settings + +These kernel interfaces got removed by: +commit 8e7fbcbc22c12414bcc9dfdd683637f58fb32759 +Author: Peter Zijlstra +Date: Mon Jan 9 11:28:35 2012 +0100 + + sched: Remove stale power aware scheduling remnants and dysfunctional knobs + +No need to further keep them as userspace configurations. + +Signed-off-by: Thomas Renninger + +diff --git a/tools/power/cpupower/man/cpupower-info.1 b/tools/power/cpupower/man/cpupower-info.1 +index 58e2119..340bcd0 100644 +--- a/tools/power/cpupower/man/cpupower-info.1 ++++ b/tools/power/cpupower/man/cpupower-info.1 +@@ -3,7 +3,7 @@ + cpupower\-info \- Shows processor power related kernel or hardware configurations + .SH SYNOPSIS + .ft B +-.B cpupower info [ \-b ] [ \-s ] [ \-m ] ++.B cpupower info [ \-b ] + + .SH DESCRIPTION + \fBcpupower info \fP shows kernel configurations or processor hardware +diff --git a/tools/power/cpupower/man/cpupower-set.1 b/tools/power/cpupower/man/cpupower-set.1 +index 9dbd536..2bcc696 100644 +--- a/tools/power/cpupower/man/cpupower-set.1 ++++ b/tools/power/cpupower/man/cpupower-set.1 +@@ -3,7 +3,7 @@ + cpupower\-set \- Set processor power related kernel or hardware configurations + .SH SYNOPSIS + .ft B +-.B cpupower set [ \-b VAL ] [ \-s VAL ] [ \-m VAL ] ++.B cpupower set [ \-b VAL ] + + + .SH DESCRIPTION +@@ -55,35 +55,6 @@ Use \fBcpupower -c all info -b\fP to verify. + + This options needs the msr kernel driver (CONFIG_X86_MSR) loaded. + .RE +-.PP +-\-\-sched\-mc, \-m [ VAL ] +-.RE +-\-\-sched\-smt, \-s [ VAL ] +-.RS 4 +-\-\-sched\-mc utilizes cores in one processor package/socket first before +-processes are scheduled to other processor packages/sockets. +- +-\-\-sched\-smt utilizes thread siblings of one processor core first before +-processes are scheduled to other cores. +- +-The impact on power consumption and performance (positiv or negativ) heavily +-depends on processor support for deep sleep states, frequency scaling and +-frequency boost modes and their dependencies between other thread siblings +-and processor cores. +- +-Taken over from kernel documentation: +- +-Adjust the kernel's multi-core scheduler support. +- +-Possible values are: +-.RS 2 +-0 - No power saving load balance (default value) +- +-1 - Fill one thread/core/package first for long running threads +- +-2 - Also bias task wakeups to semi-idle cpu package for power +-savings +-.RE + + .SH "SEE ALSO" + cpupower-info(1), cpupower-monitor(1), powertop(1) +diff --git a/tools/power/cpupower/utils/cpupower-info.c b/tools/power/cpupower/utils/cpupower-info.c +index 0ac2577..136d979 100644 +--- a/tools/power/cpupower/utils/cpupower-info.c ++++ b/tools/power/cpupower/utils/cpupower-info.c +@@ -18,8 +18,6 @@ + + static struct option set_opts[] = { + { .name = "perf-bias", .has_arg = optional_argument, .flag = NULL, .val = 'b'}, +- { .name = "sched-mc", .has_arg = optional_argument, .flag = NULL, .val = 'm'}, +- { .name = "sched-smt", .has_arg = optional_argument, .flag = NULL, .val = 's'}, + { }, + }; + +@@ -37,8 +35,6 @@ int cmd_info(int argc, char **argv) + + union { + struct { +- int sched_mc:1; +- int sched_smt:1; + int perf_bias:1; + }; + int params; +@@ -49,23 +45,13 @@ int cmd_info(int argc, char **argv) + textdomain(PACKAGE); + + /* parameter parsing */ +- while ((ret = getopt_long(argc, argv, "msb", set_opts, NULL)) != -1) { ++ while ((ret = getopt_long(argc, argv, "b", set_opts, NULL)) != -1) { + switch (ret) { + case 'b': + if (params.perf_bias) + print_wrong_arg_exit(); + params.perf_bias = 1; + break; +- case 'm': +- if (params.sched_mc) +- print_wrong_arg_exit(); +- params.sched_mc = 1; +- break; +- case 's': +- if (params.sched_smt) +- print_wrong_arg_exit(); +- params.sched_smt = 1; +- break; + default: + print_wrong_arg_exit(); + } +@@ -78,25 +64,6 @@ int cmd_info(int argc, char **argv) + if (bitmask_isallclear(cpus_chosen)) + bitmask_setbit(cpus_chosen, 0); + +- if (params.sched_mc) { +- ret = sysfs_get_sched("mc"); +- printf(_("System's multi core scheduler setting: ")); +- if (ret < 0) +- /* if sysfs file is missing it's: errno == ENOENT */ +- printf(_("not supported\n")); +- else +- printf("%d\n", ret); +- } +- if (params.sched_smt) { +- ret = sysfs_get_sched("smt"); +- printf(_("System's thread sibling scheduler setting: ")); +- if (ret < 0) +- /* if sysfs file is missing it's: errno == ENOENT */ +- printf(_("not supported\n")); +- else +- printf("%d\n", ret); +- } +- + /* Add more per cpu options here */ + if (!params.perf_bias) + return ret; +diff --git a/tools/power/cpupower/utils/cpupower-set.c b/tools/power/cpupower/utils/cpupower-set.c +index bcf1d2f..573c75f 100644 +--- a/tools/power/cpupower/utils/cpupower-set.c ++++ b/tools/power/cpupower/utils/cpupower-set.c +@@ -19,8 +19,6 @@ + + static struct option set_opts[] = { + { .name = "perf-bias", .has_arg = required_argument, .flag = NULL, .val = 'b'}, +- { .name = "sched-mc", .has_arg = required_argument, .flag = NULL, .val = 'm'}, +- { .name = "sched-smt", .has_arg = required_argument, .flag = NULL, .val = 's'}, + { }, + }; + +@@ -38,13 +36,11 @@ int cmd_set(int argc, char **argv) + + union { + struct { +- int sched_mc:1; +- int sched_smt:1; + int perf_bias:1; + }; + int params; + } params; +- int sched_mc = 0, sched_smt = 0, perf_bias = 0; ++ int perf_bias = 0; + int ret = 0; + + setlocale(LC_ALL, ""); +@@ -52,7 +48,7 @@ int cmd_set(int argc, char **argv) + + params.params = 0; + /* parameter parsing */ +- while ((ret = getopt_long(argc, argv, "m:s:b:", ++ while ((ret = getopt_long(argc, argv, "b:", + set_opts, NULL)) != -1) { + switch (ret) { + case 'b': +@@ -66,28 +62,6 @@ int cmd_set(int argc, char **argv) + } + params.perf_bias = 1; + break; +- case 'm': +- if (params.sched_mc) +- print_wrong_arg_exit(); +- sched_mc = atoi(optarg); +- if (sched_mc < 0 || sched_mc > 2) { +- printf(_("--sched-mc param out " +- "of range [0-%d]\n"), 2); +- print_wrong_arg_exit(); +- } +- params.sched_mc = 1; +- break; +- case 's': +- if (params.sched_smt) +- print_wrong_arg_exit(); +- sched_smt = atoi(optarg); +- if (sched_smt < 0 || sched_smt > 2) { +- printf(_("--sched-smt param out " +- "of range [0-%d]\n"), 2); +- print_wrong_arg_exit(); +- } +- params.sched_smt = 1; +- break; + default: + print_wrong_arg_exit(); + } +@@ -96,19 +70,6 @@ int cmd_set(int argc, char **argv) + if (!params.params) + print_wrong_arg_exit(); + +- if (params.sched_mc) { +- ret = sysfs_set_sched("mc", sched_mc); +- if (ret) +- fprintf(stderr, _("Error setting sched-mc %s\n"), +- (ret == -ENODEV) ? "not supported" : ""); +- } +- if (params.sched_smt) { +- ret = sysfs_set_sched("smt", sched_smt); +- if (ret) +- fprintf(stderr, _("Error setting sched-smt %s\n"), +- (ret == -ENODEV) ? "not supported" : ""); +- } +- + /* Default is: set all CPUs */ + if (bitmask_isallclear(cpus_chosen)) + bitmask_setall(cpus_chosen); diff --git a/cpupower-return_zero_on_success.patch b/cpupower-return_zero_on_success.patch new file mode 100644 index 0000000..9f17c71 --- /dev/null +++ b/cpupower-return_zero_on_success.patch @@ -0,0 +1,23 @@ +cpupower: cpupower info -b should return 0 on success, not the perf bias value + +Signed-off-by: Thomas Renninger + +diff --git a/utils/cpupower-info.c b/utils/cpupower-info.c +index 3f68632..3e27975 100644 +--- a/utils/cpupower-info.c ++++ b/utils/cpupower-info.c +@@ -125,11 +125,11 @@ int cmd_info(int argc, char **argv) + if (params.perf_bias) { + ret = msr_intel_get_perf_bias(cpu); + if (ret < 0) { +- printf(_("Could not read perf-bias value\n")); +- break; ++ printf(_("Could not read perf-bias value[%d]\n"), ret); ++ exit(EXIT_FAILURE); + } else + printf(_("perf-bias: %d\n"), ret); + } + } +- return ret; ++ return 0; + } diff --git a/cpupower.changes b/cpupower.changes index 821c01a..2b2077f 100644 --- a/cpupower.changes +++ b/cpupower.changes @@ -1,3 +1,33 @@ +------------------------------------------------------------------- +Tue Apr 1 12:31:14 UTC 2014 - trenn@suse.de + +- Do return 0 if cpupower info -b is called instead of the perf bias value + which is already printed to stdout. + Add cpupower-return_zero_on_success.patch +- Remove mc and smt scheduler knobs. These do not exist anymore in latest + kernels for quite a while now. + Add cpupower-remove_mc_scheduler_bits.patch + +------------------------------------------------------------------- +Mon Mar 31 15:27:14 UTC 2014 - trenn@suse.de + +- If root, try to load msr driver on x86 if /dev/cpu/0/msr is not avail + Add cpupower-always_try_to_load_msr_driver_as_root.patch + +------------------------------------------------------------------- +Fri Mar 28 19:35:10 UTC 2014 - trenn@suse.de + +- Update to latest turbostat version (git 2d6e532279ddf30188d5fbd) + bnc#866862, bnc#869071, bnc#869809 +- Adjust MSR include path + add make_header_file_passable_from_outside.patch + +------------------------------------------------------------------- +Fri Mar 28 19:05:46 UTC 2014 - trenn@suse.de + +- Fix Makefile: Install latest cpupower-idle-* manpages + Add add_idle_manpages_in_Makefile.patch + ------------------------------------------------------------------- Fri Mar 14 03:22:50 UTC 2014 - trenn@suse.de diff --git a/cpupower.spec b/cpupower.spec index 2b3e3c5..def2a71 100644 --- a/cpupower.spec +++ b/cpupower.spec @@ -24,7 +24,7 @@ Url: http://www.kernel.org/pub/linux/utils/kernel/cpufreq/cpufrequtil %define version %(rpm -q --qf '%{VERSION}' kernel-source) Version: 3.13 Release: 0 -%define tsversion 3.13 +%define tsversion 3.14 Summary: Tools to determine and set CPU Power related Settings License: GPL-2.0 Group: System/Base @@ -32,7 +32,12 @@ Source: %{name}-%{version}.tar.bz2 Source1: turbostat-%{tsversion}.tar.bz2 Source2: cpupower_export_tarball_from_git.sh Patch1: cpupower_disable_by_latency.patch -Patch2: turbostat_fix_man_perm.patch +Patch2: add_idle_manpages_in_Makefile.patch +Patch3: cpupower-always_try_to_load_msr_driver_as_root.patch +Patch4: cpupower-return_zero_on_success.patch +Patch5: cpupower-remove_mc_scheduler_bits.patch +Patch20: turbostat_fix_man_perm.patch +Patch21: make_header_file_passable_from_outside.patch BuildRoot: %{_tmppath}/%{name}-%{version}-build BuildRequires: gettext-tools BuildRequires: pciutils @@ -78,8 +83,13 @@ powersave module. %prep %setup -D -b 1 %patch1 -p1 -cd ../turbostat-%{tsversion} %patch2 -p1 +%patch3 -p1 +%patch4 -p1 +%patch5 -p4 +cd ../turbostat-%{tsversion} +%patch20 -p1 +%patch21 -p1 %build # This package failed when testing with -Wl,-as-needed being default. @@ -91,7 +101,7 @@ make $CONF %{?_smp_mflags} %ifarch ix86 x86_64 cd ../turbostat-%{tsversion} -make %{?_smp_mflags} +CFLAGS="%optflags -I. -DMSRHEADER=\"\"" make %{?_smp_mflags} %endif %install diff --git a/cpupower_export_tarball_from_git.sh b/cpupower_export_tarball_from_git.sh index 61cd2f6..82e2572 100644 --- a/cpupower_export_tarball_from_git.sh +++ b/cpupower_export_tarball_from_git.sh @@ -60,7 +60,7 @@ set -x git archive --format=tar $GIT_TAG tools/power/x86/turbostat |tar -x mv tools/power/x86/turbostat turbostat${VERSION} mkdir turbostat${VERSION}/asm -cp "${GIT_DIR}"/../arch/x86/include/uapi/asm/msr-index.h turbostat${VERSION}/asm +cp "${GIT_DIR}"/../../../../../arch/x86/include/uapi/asm/msr-index.h turbostat${VERSION}/asm tar -cvjf turbostat${VERSION}.tar.bz2 turbostat${VERSION} popd mv "$DIR/cpupower${VERSION}".tar.bz2 . diff --git a/make_header_file_passable_from_outside.patch b/make_header_file_passable_from_outside.patch new file mode 100644 index 0000000..c396d9f --- /dev/null +++ b/make_header_file_passable_from_outside.patch @@ -0,0 +1,12 @@ +Index: turbostat-3.14/Makefile +=================================================================== +--- turbostat-3.14.orig/Makefile ++++ turbostat-3.14/Makefile +@@ -5,7 +5,6 @@ DESTDIR := + + turbostat : turbostat.c + CFLAGS += -Wall +-CFLAGS += -DMSRHEADER='"../../../../arch/x86/include/uapi/asm/msr-index.h"' + + %: %.c + @mkdir -p $(BUILD_OUTPUT) diff --git a/turbostat-3.13.tar.bz2 b/turbostat-3.13.tar.bz2 deleted file mode 100644 index a32eb17..0000000 --- a/turbostat-3.13.tar.bz2 +++ /dev/null @@ -1,3 +0,0 @@ -version https://git-lfs.github.com/spec/v1 -oid sha256:98aa5ffa5202cbca1836a69383d44ddba70224459bb40d2fc27ebfc6bafeef1a -size 21380 diff --git a/turbostat-3.14.tar.bz2 b/turbostat-3.14.tar.bz2 new file mode 100644 index 0000000..12c272a --- /dev/null +++ b/turbostat-3.14.tar.bz2 @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:25252937e79be9ce2c8f05ffad9f9502b78559df34d54d54f54c4a1d76ac8b17 +size 21870