Added check if ondemand governor is applicable (by ondemand-check patch)

Resolves: rhbz#697273
This commit is contained in:
Jaroslav Škarvada 2013-06-28 14:45:30 +02:00
parent 15dbabf16e
commit 788a484a79
2 changed files with 50 additions and 2 deletions

View File

@ -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);

View File

@ -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 <jskarvad@redhat.com> - 2.3-4
- Added check if ondemand governor is applicable (by ondemand-check patch)
Resolves: rhbz#697273
* Tue Jun 25 2013 Jaroslav Škarvada <jskarvad@redhat.com> - 2.3-3
- Added workload option to the man page