Sophie

Sophie

distrib > Fedora > 18 > x86_64 > by-pkgid > 7c1d1ed9f4efe8d5dd847bb8b79d399b > files > 3

powertop-2.4-6.fc18.src.rpm

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