Blame SOURCES/powertop-2.3-ondemand-check.patch

4d24b8
diff -up powertop-2.3/src/tuning/cpufreq.cpp.orig powertop-2.3/src/tuning/cpufreq.cpp
4d24b8
--- powertop-2.3/src/tuning/cpufreq.cpp.orig	2013-01-31 22:39:27.000000000 +0100
4d24b8
+++ powertop-2.3/src/tuning/cpufreq.cpp	2013-06-28 14:05:04.254925669 +0200
4d24b8
@@ -63,6 +63,7 @@ int cpufreq_tunable::good_bad(void)
4d24b8
 
4d24b8
 	char gov[1024];
4d24b8
 	int ret = TUNE_GOOD;
4d24b8
+	unsigned long int ld;
4d24b8
 
4d24b8
 
4d24b8
 	gov[0] = 0;
4d24b8
@@ -91,6 +92,30 @@ int cpufreq_tunable::good_bad(void)
4d24b8
 			if (strcmp(gov, line))
4d24b8
 				ret = TUNE_BAD;
4d24b8
 		fclose(file);
4d24b8
+
4d24b8
+		/* check if ondemand governor is available */
4d24b8
+		sprintf(filename, "/sys/devices/system/cpu/%s/cpufreq/scaling_available_governors", dirent->d_name);
4d24b8
+		file = fopen(filename, "r");
4d24b8
+		if (!file)
4d24b8
+			continue;
4d24b8
+		memset(line, 0, 1024);
4d24b8
+		if (fgets(line, 1023,file)==NULL || strstr(line, "ondemand")==NULL) {
4d24b8
+			fclose(file);
4d24b8
+			continue;
4d24b8
+		}
4d24b8
+		fclose(file);
4d24b8
+
4d24b8
+		/* check if cpu transition latency is not higher than ondemand governor max_transition_latency */
4d24b8
+		sprintf(filename, "/sys/devices/system/cpu/%s/cpufreq/cpuinfo_transition_latency", dirent->d_name);
4d24b8
+		file = fopen(filename, "r");
4d24b8
+		if (!file)
4d24b8
+			continue;
4d24b8
+		if (fscanf(file, "%lu", &ld) != 1 || ld > 10000000)
4d24b8
+		{
4d24b8
+			fclose(file);
4d24b8
+			continue;
4d24b8
+		}
4d24b8
+		fclose(file);
4d24b8
 	}
4d24b8
 
4d24b8
 	closedir(dir);