diff options
author | Chen Yu | 2022-04-21 22:38:34 +0800 |
---|---|---|
committer | Len Brown | 2022-07-28 14:23:25 -0400 |
commit | 033312336d67a2ca9b5ff4ad35e5dfd99042d2a3 (patch) | |
tree | 9f02f086015d71a1785153cf8be32e5574253f25 /tools/power | |
parent | fb5e29df8d15a131a02a4e04bbd9df8450eecc7d (diff) |
tools/power turbostat: print the kernel boot commandline
It would be handy to have cmdline in turbostat output. For example,
according to the turbostat output, there are no C-states requested.
In this case the user is very curious if something like
intel_idle.max_cstate=0 was used, or may be idle=none too. It is
also curious whether things like intel_pstate=nohwp were used.
Print the boot command line accordingly:
turbostat version 21.05.04 - Len Brown <lenb@kernel.org>
Kernel command line: BOOT_IMAGE=/boot/vmlinuz-5.16.0+ root=UUID=
b42359ed-1e05-42eb-8757-6bf2a1c19070 ro quiet splash vt.handoff=7
Suggested-by: Artem Bityutskiy <artem.bityutskiy@linux.intel.com>
Signed-off-by: Chen Yu <yu.c.chen@intel.com>
Signed-off-by: Len Brown <len.brown@intel.com>
Diffstat (limited to 'tools/power')
-rw-r--r-- | tools/power/x86/turbostat/turbostat.c | 27 |
1 files changed, 26 insertions, 1 deletions
diff --git a/tools/power/x86/turbostat/turbostat.c b/tools/power/x86/turbostat/turbostat.c index ab45a2e1a70a..318e971c55a1 100644 --- a/tools/power/x86/turbostat/turbostat.c +++ b/tools/power/x86/turbostat/turbostat.c @@ -6132,6 +6132,29 @@ void print_version() fprintf(outf, "turbostat version 2022.04.16 - Len Brown <lenb@kernel.org>\n"); } +#define COMMAND_LINE_SIZE 2048 + +void print_bootcmd(void) +{ + char bootcmd[COMMAND_LINE_SIZE]; + FILE *fp; + int ret; + + memset(bootcmd, 0, COMMAND_LINE_SIZE); + fp = fopen("/proc/cmdline", "r"); + if (!fp) + return; + + ret = fread(bootcmd, sizeof(char), COMMAND_LINE_SIZE - 1, fp); + if (ret) { + bootcmd[ret] = '\0'; + /* the last character is already '\n' */ + fprintf(outf, "Kernel command line: %s", bootcmd); + } + + fclose(fp); +} + int add_counter(unsigned int msr_num, char *path, char *name, unsigned int width, enum counter_scope scope, enum counter_type type, enum counter_format format, int flags) @@ -6603,8 +6626,10 @@ int main(int argc, char **argv) outf = stderr; cmdline(argc, argv); - if (!quiet) + if (!quiet) { print_version(); + print_bootcmd(); + } probe_sysfs(); |