diff --git a/powertop-2.3-ondemand-check.patch b/powertop-2.3-ondemand-check.patch new file mode 100644 index 0000000..faba75f --- /dev/null +++ b/powertop-2.3-ondemand-check.patch @@ -0,0 +1,42 @@ +diff -up powertop-2.3/src/tuning/cpufreq.cpp.orig powertop-2.3/src/tuning/cpufreq.cpp +--- powertop-2.3/src/tuning/cpufreq.cpp.orig 2013-01-31 22:39:27.000000000 +0100 ++++ powertop-2.3/src/tuning/cpufreq.cpp 2013-06-28 14:05:04.254925669 +0200 +@@ -63,6 +63,7 @@ int cpufreq_tunable::good_bad(void) + + char gov[1024]; + int ret = TUNE_GOOD; ++ unsigned long int ld; + + + gov[0] = 0; +@@ -91,6 +92,30 @@ int cpufreq_tunable::good_bad(void) + if (strcmp(gov, line)) + ret = TUNE_BAD; + fclose(file); ++ ++ /* check if ondemand governor is available */ ++ sprintf(filename, "/sys/devices/system/cpu/%s/cpufreq/scaling_available_governors", dirent->d_name); ++ file = fopen(filename, "r"); ++ if (!file) ++ continue; ++ memset(line, 0, 1024); ++ if (fgets(line, 1023,file)==NULL || strstr(line, "ondemand")==NULL) { ++ fclose(file); ++ continue; ++ } ++ fclose(file); ++ ++ /* check if cpu transition latency is not higher than ondemand governor max_transition_latency */ ++ sprintf(filename, "/sys/devices/system/cpu/%s/cpufreq/cpuinfo_transition_latency", dirent->d_name); ++ file = fopen(filename, "r"); ++ if (!file) ++ continue; ++ if (fscanf(file, "%lu", &ld) != 1 || ld > 10000000) ++ { ++ fclose(file); ++ continue; ++ } ++ fclose(file); + } + + closedir(dir); diff --git a/powertop.spec b/powertop.spec index 75eff0d..10b9714 100644 --- a/powertop.spec +++ b/powertop.spec @@ -1,6 +1,6 @@ Name: powertop Version: 2.3 -Release: 3%{?dist} +Release: 4%{?dist} Summary: Power consumption monitor Group: Applications/System @@ -12,7 +12,8 @@ Source0: http://01.org/powertop/sites/default/files/downloads/%{name}-%{v Patch0: powertop-2.3-always-create-params.patch # Sent upstream (http://github.com/fenrus75/powertop/pull/11) Patch1: powertop-2.3-man-fix.patch - +# Sent upstream (http://github.com/fenrus75/powertop/pull/12) +Patch2: powertop-2.3-ondemand-check.patch BuildRoot: %{_tmppath}/%{name}-%{version}-%{release}-root-%(%{__id_u} -n) BuildRequires: gettext, ncurses-devel, pciutils-devel, zlib-devel, libnl3-devel Requires(post): coreutils @@ -25,6 +26,7 @@ computer use more power than necessary while it is idle. %setup -q %patch0 -p1 -b .always-create-params %patch1 -p1 -b .man-fix +%patch2 -p1 -b .ondemand-check # remove left over object files find . -name "*.o" -exec rm {} \; @@ -57,6 +59,10 @@ rm -rf %{buildroot} %{_mandir}/man8/powertop.8* %changelog +* Fri Jun 28 2013 Jaroslav Škarvada - 2.3-4 +- Added check if ondemand governor is applicable (by ondemand-check patch) + Resolves: rhbz#697273 + * Tue Jun 25 2013 Jaroslav Škarvada - 2.3-3 - Added workload option to the man page