Skip to content

Commit abdcbdb

Browse files
committed
tools/power turbostat: Print cpuidle information
Print cpuidle driver and governor. Originally-by: Antti Laakso <[email protected]> Signed-off-by: Len Brown <[email protected]>
1 parent fcaa681 commit abdcbdb

File tree

1 file changed

+26
-0
lines changed

1 file changed

+26
-0
lines changed

tools/power/x86/turbostat/turbostat.c

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3503,6 +3503,23 @@ dump_cstate_pstate_config_info(unsigned int family, unsigned int model)
35033503
dump_nhm_cst_cfg();
35043504
}
35053505

3506+
static void dump_sysfs_file(char *path)
3507+
{
3508+
FILE *input;
3509+
char cpuidle_buf[64];
3510+
3511+
input = fopen(path, "r");
3512+
if (input == NULL) {
3513+
if (debug)
3514+
fprintf(outf, "NSFOD %s\n", path);
3515+
return;
3516+
}
3517+
if (!fgets(cpuidle_buf, sizeof(cpuidle_buf), input))
3518+
err(1, "%s: failed to read file", path);
3519+
fclose(input);
3520+
3521+
fprintf(outf, "%s: %s", strrchr(path, '/') + 1, cpuidle_buf);
3522+
}
35063523
static void
35073524
dump_sysfs_cstate_config(void)
35083525
{
@@ -3516,6 +3533,15 @@ dump_sysfs_cstate_config(void)
35163533
if (!DO_BIC(BIC_sysfs))
35173534
return;
35183535

3536+
if (access("/sys/devices/system/cpu/cpuidle", R_OK)) {
3537+
fprintf(outf, "cpuidle not loaded\n");
3538+
return;
3539+
}
3540+
3541+
dump_sysfs_file("/sys/devices/system/cpu/cpuidle/current_driver");
3542+
dump_sysfs_file("/sys/devices/system/cpu/cpuidle/current_governor");
3543+
dump_sysfs_file("/sys/devices/system/cpu/cpuidle/current_governor_ro");
3544+
35193545
for (state = 0; state < 10; ++state) {
35203546

35213547
sprintf(path, "/sys/devices/system/cpu/cpu%d/cpuidle/state%d/name",

0 commit comments

Comments
 (0)