aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJoe Konno <joe.konno@intel.com>2016-06-13 09:00:34 -0700
committerNivedita Swaminathan <nivedita.swaminathan@intel.com>2016-07-21 15:12:34 -0700
commitb0503dc123532e81a1633f7318dc7a30da03e7ce (patch)
tree5425aded3e823df13d897a2ba9da168f4a0647d2
parent6a0b4d08b55df62826092d2f49785d177f90a4a5 (diff)
downloadpowertop-2.0-b0503dc123532e81a1633f7318dc7a30da03e7ce.tar.gz
intel_cpus: no pstate Idle pct with intel_pstate
Do not display "percent Idle" in the Frequency Stats tab when the intel_pstate kernel driver is loaded. This is because Idle time is inferred through kernel PM trace events, which may be insufficient for proper computation in certain scenarios. Therefore, best to display no data than potentially inaccurate data. End-users are encouraged to use the Idle Stats tab in the UI or report to analyze their system's idle time. When the intel_pstate kernel driver is loaded, the Frequency Stats tab will only present the end-user with the average frequency of each logical core. Signed-off-by: Joe Konno <joe.konno@intel.com>
-rw-r--r--src/cpu/intel_cpus.cpp50
-rw-r--r--src/cpu/intel_cpus.h2
2 files changed, 45 insertions, 7 deletions
diff --git a/src/cpu/intel_cpus.cpp b/src/cpu/intel_cpus.cpp
index 8151292..330050e 100644
--- a/src/cpu/intel_cpus.cpp
+++ b/src/cpu/intel_cpus.cpp
@@ -70,6 +70,8 @@ static int intel_cpu_models[] = {
0 /* last entry must be zero */
};
+static int intel_pstate_driver_loaded = -1;
+
int is_supported_intel_cpu(int model)
{
int i;
@@ -81,6 +83,34 @@ int is_supported_intel_cpu(int model)
return 0;
}
+int is_intel_pstate_driver_loaded()
+{
+ const string filename("/sys/devices/system/cpu/cpu0/cpufreq/scaling_driver");
+ const string intel_pstate("intel_pstate");
+ char line[32] = { '\0' };
+ ifstream file;
+
+ if (intel_pstate_driver_loaded > -1)
+ return intel_pstate_driver_loaded;
+
+ file.open(filename, ios::in);
+
+ if (!file)
+ return -1;
+
+ file.getline(line, sizeof(line)-1);
+ file.close();
+
+ const string scaling_driver(line);
+ if (scaling_driver == intel_pstate) {
+ intel_pstate_driver_loaded = 1;
+ } else {
+ intel_pstate_driver_loaded = 0;
+ }
+
+ return intel_pstate_driver_loaded;
+}
+
static uint64_t get_msr(int cpu, uint64_t offset)
{
ssize_t retval;
@@ -267,10 +297,11 @@ void nhm_core::measurement_end(void)
char * nhm_core::fill_pstate_line(int line_nr, char *buffer)
{
+ const int intel_pstate = is_intel_pstate_driver_loaded();
buffer[0] = 0;
unsigned int i;
- if (total_stamp ==0) {
+ if (!intel_pstate && total_stamp ==0) {
for (i = 0; i < pstates.size(); i++)
total_stamp += pstates[i]->time_after;
if (total_stamp == 0)
@@ -282,10 +313,11 @@ char * nhm_core::fill_pstate_line(int line_nr, char *buffer)
return buffer;
}
- if (line_nr >= (int)pstates.size() || line_nr < 0)
+ if (intel_pstate > 0 || line_nr >= (int)pstates.size() || line_nr < 0)
return buffer;
sprintf(buffer," %5.1f%% ", percentage(1.0* (pstates[line_nr]->time_after) / total_stamp));
+
return buffer;
}
@@ -342,10 +374,11 @@ nhm_package::nhm_package(int model)
char * nhm_package::fill_pstate_line(int line_nr, char *buffer)
{
+ const int intel_pstate = is_intel_pstate_driver_loaded();
buffer[0] = 0;
unsigned int i;
- if (total_stamp ==0) {
+ if (!intel_pstate && total_stamp ==0) {
for (i = 0; i < pstates.size(); i++)
total_stamp += pstates[i]->time_after;
if (total_stamp == 0)
@@ -358,10 +391,11 @@ char * nhm_package::fill_pstate_line(int line_nr, char *buffer)
return buffer;
}
- if (line_nr >= (int)pstates.size() || line_nr < 0)
+ if (intel_pstate > 0 || line_nr >= (int)pstates.size() || line_nr < 0)
return buffer;
sprintf(buffer," %5.1f%% ", percentage(1.0* (pstates[line_nr]->time_after) / total_stamp));
+
return buffer;
}
@@ -581,7 +615,9 @@ char * nhm_cpu::fill_pstate_name(int line_nr, char *buffer)
char * nhm_cpu::fill_pstate_line(int line_nr, char *buffer)
{
- if (total_stamp ==0) {
+ const int intel_pstate = is_intel_pstate_driver_loaded();
+
+ if (!intel_pstate && total_stamp ==0) {
unsigned int i;
for (i = 0; i < pstates.size(); i++)
total_stamp += pstates[i]->time_after;
@@ -600,12 +636,12 @@ char * nhm_cpu::fill_pstate_line(int line_nr, char *buffer)
hz_to_human(F, buffer, 1);
return buffer;
}
- if (line_nr >= (int)pstates.size() || line_nr < 0)
+ if (intel_pstate > 0 || line_nr >= (int)pstates.size() || line_nr < 0)
return buffer;
sprintf(buffer," %5.1f%% ", percentage(1.0* (pstates[line_nr]->time_after) / total_stamp));
- return buffer;
+ return buffer;
}
diff --git a/src/cpu/intel_cpus.h b/src/cpu/intel_cpus.h
index 0331069..d20db9a 100644
--- a/src/cpu/intel_cpus.h
+++ b/src/cpu/intel_cpus.h
@@ -175,4 +175,6 @@ public:
int is_supported_intel_cpu(int model);
int byt_has_ahci();
+int is_intel_pstate_driver_loaded();
+
#endif