From 227205adc5aff04348f9f58e032fbbaa148d5296610314bfa3b0f17271282139 Mon Sep 17 00:00:00 2001 From: Thomas Renninger Date: Fri, 14 Mar 2014 03:24:09 +0000 Subject: [PATCH 1/2] - Introduce idle state disable-by-latency and enable-all Part of fate#316611 OBS-URL: https://build.opensuse.org/package/show/hardware/cpupower?expand=0&rev=33 --- cpupower.changes | 6 ++ cpupower.spec | 6 +- cpupower_disable_by_latency.patch | 143 ++++++++++++++++++++++++++++++ 3 files changed, 153 insertions(+), 2 deletions(-) create mode 100644 cpupower_disable_by_latency.patch diff --git a/cpupower.changes b/cpupower.changes index c10347e..179e9d8 100644 --- a/cpupower.changes +++ b/cpupower.changes @@ -1,3 +1,9 @@ +------------------------------------------------------------------- +Fri Mar 14 03:22:50 UTC 2014 - trenn@suse.de + +- Introduce idle state disable-by-latency and enable-all + Part of fate#316611 + ------------------------------------------------------------------- Fri Feb 14 13:32:00 UTC 2014 - trenn@suse.de diff --git a/cpupower.spec b/cpupower.spec index 3bf3392..2b3e3c5 100644 --- a/cpupower.spec +++ b/cpupower.spec @@ -31,7 +31,8 @@ Group: System/Base Source: %{name}-%{version}.tar.bz2 Source1: turbostat-%{tsversion}.tar.bz2 Source2: cpupower_export_tarball_from_git.sh -Patch1: turbostat_fix_man_perm.patch +Patch1: cpupower_disable_by_latency.patch +Patch2: turbostat_fix_man_perm.patch BuildRoot: %{_tmppath}/%{name}-%{version}-build BuildRequires: gettext-tools BuildRequires: pciutils @@ -76,8 +77,9 @@ powersave module. %prep %setup -D -b 1 -cd ../turbostat-%{tsversion} %patch1 -p1 +cd ../turbostat-%{tsversion} +%patch2 -p1 %build # This package failed when testing with -Wl,-as-needed being default. diff --git a/cpupower_disable_by_latency.patch b/cpupower_disable_by_latency.patch new file mode 100644 index 0000000..7578b16 --- /dev/null +++ b/cpupower_disable_by_latency.patch @@ -0,0 +1,143 @@ +cpupower: Introduce idle state disable-by-latency and enable-all + +Signed-off-by: Thomas Renninger + +diff --git a/man/cpupower-idle-set.1 b/man/cpupower-idle-set.1 +index 6b16072..1de0bd9 100644 +--- a/man/cpupower-idle-set.1 ++++ b/man/cpupower-idle-set.1 +@@ -13,11 +13,15 @@ sleep states. This can be handy for power vs performance tuning. + .SH "OPTIONS" + .LP + .TP +-\fB\-d\fR \fB\-\-disable\fR ++\fB\-d\fR \fB\-\-disable\fR + Disable a specific processor sleep state. + .TP +-\fB\-e\fR \fB\-\-enable\fR ++\fB\-e\fR \fB\-\-enable\fR + Enable a specific processor sleep state. ++\fB\-D\fR \fB\-\-disable-by-latency\fR ++Disable all idle states with a equal or higher latency than ++\fB\-E\fR \fB\-\-enable-all\fR ++Enable all idle states if not enabled already. + + .SH "REMARKS" + .LP +diff --git a/utils/cpuidle-set.c b/utils/cpuidle-set.c +index c78141c..d45d8d7 100644 +--- a/utils/cpuidle-set.c ++++ b/utils/cpuidle-set.c +@@ -13,8 +13,14 @@ + #include "helpers/sysfs.h" + + static struct option info_opts[] = { +- { .name = "disable", .has_arg = required_argument, .flag = NULL, .val = 'd'}, +- { .name = "enable", .has_arg = required_argument, .flag = NULL, .val = 'e'}, ++ { .name = "disable", ++ .has_arg = required_argument, .flag = NULL, .val = 'd'}, ++ { .name = "enable", ++ .has_arg = required_argument, .flag = NULL, .val = 'e'}, ++ { .name = "disable-by-latency", ++ .has_arg = required_argument, .flag = NULL, .val = 'D'}, ++ { .name = "enable-all", ++ .has_arg = no_argument, .flag = NULL, .val = 'E'}, + { }, + }; + +@@ -23,11 +29,13 @@ int cmd_idle_set(int argc, char **argv) + { + extern char *optarg; + extern int optind, opterr, optopt; +- int ret = 0, cont = 1, param = 0, idlestate = 0; +- unsigned int cpu = 0; ++ int ret = 0, cont = 1, param = 0, disabled; ++ unsigned long long latency = 0, state_latency; ++ unsigned int cpu = 0, idlestate = 0, idlestates = 0; ++ char *endptr; + + do { +- ret = getopt_long(argc, argv, "d:e:", info_opts, NULL); ++ ret = getopt_long(argc, argv, "d:e:ED:", info_opts, NULL); + if (ret == -1) + break; + switch (ret) { +@@ -53,6 +61,27 @@ int cmd_idle_set(int argc, char **argv) + param = ret; + idlestate = atoi(optarg); + break; ++ case 'D': ++ if (param) { ++ param = -1; ++ cont = 0; ++ break; ++ } ++ param = ret; ++ latency = strtoull(optarg, &endptr, 10); ++ if (*endptr != '\0') { ++ printf(_("Bad latency value: %s\n"), optarg); ++ exit(EXIT_FAILURE); ++ } ++ break; ++ case 'E': ++ if (param) { ++ param = -1; ++ cont = 0; ++ break; ++ } ++ param = ret; ++ break; + case -1: + cont = 0; + break; +@@ -79,8 +108,14 @@ int cmd_idle_set(int argc, char **argv) + if (!bitmask_isbitset(cpus_chosen, cpu)) + continue; + +- switch (param) { ++ if (sysfs_is_cpu_online(cpu) != 1) ++ continue; ++ ++ idlestates = sysfs_get_idlestate_count(cpu); ++ if (idlestates <= 0) ++ continue; + ++ switch (param) { + case 'd': + ret = sysfs_idlestate_disable(cpu, idlestate, 1); + if (ret == 0) +@@ -107,6 +142,34 @@ int cmd_idle_set(int argc, char **argv) + printf(_("Idlestate %u not enabled on CPU %u\n"), + idlestate, cpu); + break; ++ case 'D': ++ for (idlestate = 0; idlestate < idlestates; idlestate++) { ++ disabled = sysfs_is_idlestate_disabled ++ (cpu, idlestate); ++ state_latency = sysfs_get_idlestate_latency ++ (cpu, idlestate); ++ printf("CPU: %u - idlestate %u - state_latency: %llu - latency: %llu\n", ++ cpu, idlestate, state_latency, latency); ++ if (disabled == 1 || latency > state_latency) ++ continue; ++ ret = sysfs_idlestate_disable ++ (cpu, idlestate, 1); ++ if (ret == 0) ++ printf(_("Idlestate %u disabled on CPU %u\n"), idlestate, cpu); ++ } ++ break; ++ case 'E': ++ for (idlestate = 0; idlestate < idlestates; idlestate++) { ++ disabled = sysfs_is_idlestate_disabled ++ (cpu, idlestate); ++ if (disabled == 1) { ++ ret = sysfs_idlestate_disable ++ (cpu, idlestate, 0); ++ if (ret == 0) ++ printf(_("Idlestate %u enabled on CPU %u\n"), idlestate, cpu); ++ } ++ } ++ break; + default: + /* Not reachable with proper args checking */ + printf(_("Invalid or unknown argument\n")); From 1fde58f49e668023b63c3e64a3cc3ffea7c6b6288137dd98624974a872a7a53b Mon Sep 17 00:00:00 2001 From: Thomas Renninger Date: Fri, 14 Mar 2014 03:24:44 +0000 Subject: [PATCH 2/2] Add cpupower_disable_by_latency.patch OBS-URL: https://build.opensuse.org/package/show/hardware/cpupower?expand=0&rev=34 --- cpupower.changes | 1 + 1 file changed, 1 insertion(+) diff --git a/cpupower.changes b/cpupower.changes index 179e9d8..821c01a 100644 --- a/cpupower.changes +++ b/cpupower.changes @@ -3,6 +3,7 @@ Fri Mar 14 03:22:50 UTC 2014 - trenn@suse.de - Introduce idle state disable-by-latency and enable-all Part of fate#316611 + Add cpupower_disable_by_latency.patch ------------------------------------------------------------------- Fri Feb 14 13:32:00 UTC 2014 - trenn@suse.de