From ea05dcce34c5696e684ceae20c4f72d849189d0741d0bcb00cfdf0b821089dc4 Mon Sep 17 00:00:00 2001 From: Thomas Renninger Date: Tue, 20 Dec 2011 13:24:52 +0000 Subject: [PATCH] - Add idle-info manpage - Fix two bugs: memleak in idle-info and wrong idle state count OBS-URL: https://build.opensuse.org/package/show/hardware/cpupower?expand=0&rev=12 --- cpupower.changes | 6 ++++ cpupower.spec | 6 ++++ cpupower_fix_manpages.patch | 57 ++++++++++++++++++++++++++++++ cpupower_fix_memleak.patch | 34 ++++++++++++++++++ cpupower_fix_poll_idle_state.patch | 45 +++++++++++++++++++++++ 5 files changed, 148 insertions(+) create mode 100644 cpupower_fix_manpages.patch create mode 100644 cpupower_fix_memleak.patch create mode 100644 cpupower_fix_poll_idle_state.patch diff --git a/cpupower.changes b/cpupower.changes index 169528e..6d9e401 100644 --- a/cpupower.changes +++ b/cpupower.changes @@ -1,3 +1,9 @@ +------------------------------------------------------------------- +Tue Dec 20 13:22:00 UTC 2011 - trenn@suse.de + +- Add idle-info manpage +- Fix two bugs: memleak in idle-info and wrong idle state count + ------------------------------------------------------------------- Thu Dec 15 10:58:25 UTC 2011 - trenn@suse.de diff --git a/cpupower.spec b/cpupower.spec index a50911f..90d6b94 100644 --- a/cpupower.spec +++ b/cpupower.spec @@ -28,6 +28,9 @@ Summary: Tools to determine and set CPU Power related Settings License: GPL-2.0 Group: System/Base Source: %{name}-%{version}.tar.bz2 +Patch1: cpupower_fix_manpages.patch +Patch2: cpupower_fix_poll_idle_state.patch +Patch3: cpupower_fix_memleak.patch BuildRoot: %{_tmppath}/%{name}-%{version}-build BuildRequires: gettext-tools BuildRequires: pciutils @@ -71,6 +74,9 @@ powersave module. %prep %setup -q +%patch1 -p1 +%patch2 -p1 +%patch3 -p1 %build # This package failed when testing with -Wl,-as-needed being default. diff --git a/cpupower_fix_manpages.patch b/cpupower_fix_manpages.patch new file mode 100644 index 0000000..172d343 --- /dev/null +++ b/cpupower_fix_manpages.patch @@ -0,0 +1,57 @@ +cpupower: Unify cpupower-frequency-* manpages + +cpupower-frequency-* manpages slightly differed from the others. + - Use uppercase letters in the title + - Show cpupower Manual in the header + - Remove Mattia from left down corner of the manpage, he is already + listed as author + - Remove --help, prints this message -> not needed + +Signed-off-by: Thomas Renninger +CC: cpufreq@vger.kernel.org +CC: linux@dominikbrodowski.net +CC: malattia@linux.it + +--- + tools/power/cpupower/man/cpupower-frequency-info.1 | 4 +--- + tools/power/cpupower/man/cpupower-frequency-set.1 | 4 +--- + 2 files changed, 2 insertions(+), 6 deletions(-) + +diff --git a/man/cpupower-frequency-info.1 b/man/cpupower-frequency-info.1 +index bb60a8d..4a1918e 100644 +--- a/man/cpupower-frequency-info.1 ++++ b/man/cpupower-frequency-info.1 +@@ -1,4 +1,4 @@ +-.TH "cpupower-frequency-info" "1" "0.1" "Mattia Dongili" "" ++.TH "CPUPOWER\-FREQUENCY\-INFO" "1" "0.1" "" "cpupower Manual" + .SH "NAME" + .LP + cpupower frequency\-info \- Utility to retrieve cpufreq kernel information +@@ -50,8 +50,6 @@ Prints out information like provided by the /proc/cpufreq interface in 2.4. and + \fB\-m\fR \fB\-\-human\fR + human\-readable output for the \-f, \-w, \-s and \-y parameters. + .TP +-\fB\-h\fR \fB\-\-help\fR +-Prints out the help screen. + .SH "REMARKS" + .LP + By default only values of core zero are displayed. How to display settings of +diff --git a/man/cpupower-frequency-set.1 b/man/cpupower-frequency-set.1 +index 685f469..3eacc8d 100644 +--- a/man/cpupower-frequency-set.1 ++++ b/man/cpupower-frequency-set.1 +@@ -1,4 +1,4 @@ +-.TH "cpupower-freqency-set" "1" "0.1" "Mattia Dongili" "" ++.TH "CPUPOWER\-FREQUENCY\-SET" "1" "0.1" "" "cpupower Manual" + .SH "NAME" + .LP + cpupower frequency\-set \- A small tool which allows to modify cpufreq settings. +@@ -26,8 +26,6 @@ specific frequency to be set. Requires userspace governor to be available and lo + \fB\-r\fR \fB\-\-related\fR + modify all hardware-related CPUs at the same time + .TP +-\fB\-h\fR \fB\-\-help\fR +-Prints out the help screen. + .SH "REMARKS" + .LP + By default values are applied on all cores. How to modify single core diff --git a/cpupower_fix_memleak.patch b/cpupower_fix_memleak.patch new file mode 100644 index 0000000..669477f --- /dev/null +++ b/cpupower_fix_memleak.patch @@ -0,0 +1,34 @@ +cpupower: Remove unneeded code and by that fix a memleak + +Looks like some not needed debug code slipped in. +Also this code: +tmp = sysfs_get_idlestate_name(cpu, idlestates - 1); +performs a strdup and the mem was not freed again. +-> delete it. + +Signed-off-by: Thomas Renninger +CC: cpufreq@vger.kernel.org +CC: linux@dominikbrodowski.net + +--- + tools/power/cpupower/utils/cpuidle-info.c | 7 ------- + 1 files changed, 0 insertions(+), 7 deletions(-) + +diff --git a/utils/cpuidle-info.c b/utils/cpuidle-info.c +index e076beb..8145af5 100644 +--- a/utils/cpuidle-info.c ++++ b/utils/cpuidle-info.c +@@ -35,13 +35,6 @@ static void cpuidle_cpu_output(unsigned int cpu, int verbose) + printf(_("CPU %u: Can't read idle state info\n"), cpu); + return; + } +- tmp = sysfs_get_idlestate_name(cpu, idlestates - 1); +- if (!tmp) { +- printf(_("Could not determine max idle state %u\n"), +- idlestates - 1); +- return; +- } +- + printf(_("Number of idle states: %d\n"), idlestates); + printf(_("Available idle states:")); + for (idlestate = 0; idlestate < idlestates; idlestate++) { diff --git a/cpupower_fix_poll_idle_state.patch b/cpupower_fix_poll_idle_state.patch new file mode 100644 index 0000000..76d5b71 --- /dev/null +++ b/cpupower_fix_poll_idle_state.patch @@ -0,0 +1,45 @@ +cpupower: Fix number of idle states + +The number of idle states was wrong. +The POLL idle state (on X86) was missed out: +Number of idle states: 4 +Available idle states: C1-NHM C3-NHM C6-NHM + +While the POLL is not a real idle state, its +statistics should still be shown. It's now also +explained in a detailed manpage. +This should fix a bug of missing the first idle +state on other archs. + +Signed-off-by: Thomas Renninger +CC: cpufreq@vger.kernel.org +CC: linux@dominikbrodowski.net + +--- + a/utils/cpuidle-info.c | 5 ++--- + 1 files changed, 2 insertions(+), 3 deletions(-) + +diff --git a/utils/cpuidle-info.c b/utils/cpuidle-info.c +index b028267..e076beb 100644 +--- a/utils/cpuidle-info.c ++++ b/utils/cpuidle-info.c +@@ -43,9 +43,8 @@ static void cpuidle_cpu_output(unsigned int cpu, int verbose) + } + + printf(_("Number of idle states: %d\n"), idlestates); +- + printf(_("Available idle states:")); +- for (idlestate = 1; idlestate < idlestates; idlestate++) { ++ for (idlestate = 0; idlestate < idlestates; idlestate++) { + tmp = sysfs_get_idlestate_name(cpu, idlestate); + if (!tmp) + continue; +@@ -57,7 +56,7 @@ static void cpuidle_cpu_output(unsigned int cpu, int verbose) + if (!verbose) + return; + +- for (idlestate = 1; idlestate < idlestates; idlestate++) { ++ for (idlestate = 0; idlestate < idlestates; idlestate++) { + tmp = sysfs_get_idlestate_name(cpu, idlestate); + if (!tmp) + continue;