Message ID | 7c3808082a40a96e95808864fe814b4e68238a46.1584679387.git.len.brown@intel.com (mailing list archive) |
---|---|
State | Accepted, archived |
Delegated to: | Len Brown |
Headers | show |
Series | [01/10] tools/power turbostat: Support Cometlake | expand |
Hi Len, Antti, I didn't actually try it yet. This reply is just from reading the patches. On 2020.03.19 22:23 Len Brown wrote: > 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> ... > + 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); > + There is a problem here if one has the 'cpuidle_sysfs_switch' in the kernel command line (which I do always), because that (not) variable name changes as a function of the switch [2]. I have: $ grep . /sys/devices/system/cpu/cpuidle/* /sys/devices/system/cpu/cpuidle/available_governors:ladder menu teo /sys/devices/system/cpu/cpuidle/current_driver:intel_idle /sys/devices/system/cpu/cpuidle/current_governor:teo And in grub: GRUB_CMDLINE_LINUX_DEFAULT="ipv6.disable=1 consoleblank=300 intel_pstate=passive cpuidle_sysfs_switch cpuidle.governor=teo" Note that there was talk of getting rid of the command line switch [1 at the end], which would be great. Copied below: On 2019.09.02 14:59 Rafael wrote: > FWIW, I've been thinking about getting rid of the cpuidle_sysfs_switch > command line option and always allowing user space to switch cpuidle > governors at run time. At least I see no reason why that would not > work ATM. [1] https://marc.info/?l=linux-pm&m=156746153919195&w=2 [2] Documentation/admin-guide/pm/cpuidle.rst (search for 'current_governor_ro') ... Doug
Thanks, Doug, for reviewing the patch! I'll send a replacement that is more flexible. cheers, -Len
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",