[09/10] tools/power turbostat: Print cpuidle information

Message ID 7c3808082a40a96e95808864fe814b4e68238a46.1584679387.git.len.brown@intel.com
State New
Headers show
Series
  • Untitled series #38478
Related show

Commit Message

Len Brown March 20, 2020, 5:22 a.m.
From: Antti Laakso <antti.laakso@linux.intel.com>

Print cpuidle driver and governor.

Signed-off-by: Antti Laakso <antti.laakso@linux.intel.com>
Signed-off-by: Len Brown <len.brown@intel.com>
---
 tools/power/x86/turbostat/turbostat.c | 30 +++++++++++++++++++++++++++
 1 file changed, 30 insertions(+)

Patch

diff --git a/tools/power/x86/turbostat/turbostat.c b/tools/power/x86/turbostat/turbostat.c
index 77f89371ec5f..c9e299e99c2f 100644
--- a/tools/power/x86/turbostat/turbostat.c
+++ b/tools/power/x86/turbostat/turbostat.c
@@ -3509,6 +3509,7 @@  dump_sysfs_cstate_config(void)
 	char path[64];
 	char name_buf[16];
 	char desc[64];
+	char cpuidle_buf[64];
 	FILE *input;
 	int state;
 	char *sp;
@@ -3516,6 +3517,35 @@  dump_sysfs_cstate_config(void)
 	if (!DO_BIC(BIC_sysfs))
 		return;
 
+	if (access("/sys/devices/system/cpu/cpuidle", R_OK)) {
+		fprintf(outf, "cpuidle not loaded\n");
+		return;
+	}
+
+	sprintf(path, "/sys/devices/system/cpu/cpuidle/current_driver");
+	input = fopen(path, "r");
+	if (input == NULL) {
+		fprintf(outf, "NSFOD %s\n", path);
+		return;
+	}
+	if (!fgets(cpuidle_buf, sizeof(cpuidle_buf), input))
+		err(1, "%s: failed to read file", path);
+	fclose(input);
+
+	fprintf(outf, "cpuidle driver: %s", cpuidle_buf);
+
+	sprintf(path, "/sys/devices/system/cpu/cpuidle/current_governor_ro");
+	input = fopen(path, "r");
+	if (input == NULL) {
+		fprintf(outf, "NSFOD %s\n", path);
+		return;
+	}
+	if (!fgets(cpuidle_buf, sizeof(cpuidle_buf), input))
+		err(1, "%s: failed to read file", path);
+	fclose(input);
+
+	fprintf(outf, "cpuidle governor: %s", cpuidle_buf);
+
 	for (state = 0; state < 10; ++state) {
 
 		sprintf(path, "/sys/devices/system/cpu/cpu%d/cpuidle/state%d/name",