]> git.ipfire.org Git - thirdparty/kernel/stable.git/commitdiff
tools/power turbostat: Fix and document --header_iterations
authorLen Brown <len.brown@intel.com>
Fri, 13 Feb 2026 19:26:12 +0000 (13:26 -0600)
committerLen Brown <len.brown@intel.com>
Fri, 13 Feb 2026 20:03:17 +0000 (14:03 -0600)
The "header_iterations" option is commonly used to de-clutter
the screen of redundant header label rows in an interactive session:
Eg. every 10 rows:

$ sudo turbostat --header_iterations 10 -S -q -i 1

But --header_iterations was missing from turbostat.8

Also turbostat help advertised the "-N" short option
that did not actually work:

$ turbostat --help
  -N, --header_iterations num
print header every num iterations

Repair "-N"
Document "--header_iterations" on turbostat.8

Signed-off-by: Len Brown <len.brown@intel.com>
tools/power/x86/turbostat/turbostat.8
tools/power/x86/turbostat/turbostat.c

index b4ef0420021975a6f6913fea02bdd2ff326dbf40..344ede2f8546c6d3bc9d88668d6e36689adde5f3 100644 (file)
@@ -111,12 +111,14 @@ The column name "all" can be used to enable all disabled-by-default built-in cou
 .PP
 \fB--no-perf\fP Disable all the uses of the perf API.
 .PP
-\fB--force\fPForce turbostat to run on an unsupported platform (minimal defaults).
+\fB--force\fP Force turbostat to run on an unsupported platform (minimal defaults).
 .PP
 \fB--interval seconds\fP overrides the default 5.0 second measurement interval.
 .PP
 \fB--num_iterations num\fP number of the measurement iterations.
 .PP
+\fB--header_iterations num\fP print header every num iterations.
+.PP
 \fB--out output_file\fP turbostat output is written to the specified output_file.
 The file is truncated if it already exists, and it is created if it does not exist.
 .PP
index b8cbbff95e845ef839b249339736b3e7d62b0c7e..1ce175841583a368281ec35516068932c08ac5e8 100644 (file)
@@ -11443,7 +11443,7 @@ void cmdline(int argc, char **argv)
         * Parse some options early, because they may make other options invalid,
         * like adding the MSR counter with --add and at the same time using --no-msr.
         */
-       while ((opt = getopt_long_only(argc, argv, "+MPn:", long_options, &option_index)) != -1) {
+       while ((opt = getopt_long_only(argc, argv, "+:MP", long_options, &option_index)) != -1) {
                switch (opt) {
                case 'M':
                        no_msr = 1;
@@ -11457,7 +11457,7 @@ void cmdline(int argc, char **argv)
        }
        optind = 0;
 
-       while ((opt = getopt_long_only(argc, argv, "+C:c:Dde:hi:Jn:o:qMST:v", long_options, &option_index)) != -1) {
+       while ((opt = getopt_long_only(argc, argv, "+C:c:Dde:hi:Jn:N:o:qMST:v", long_options, &option_index)) != -1) {
                switch (opt) {
                case 'a':
                        parse_add_command(optarg);
@@ -11500,7 +11500,6 @@ void cmdline(int argc, char **argv)
                        }
                        break;
                case 'h':
-               default:
                        help();
                        exit(1);
                case 'i':
@@ -11539,19 +11538,15 @@ void cmdline(int argc, char **argv)
                        num_iterations = strtoul(optarg, NULL, 0);
                        errno = 0;
 
-                       if (errno || num_iterations == 0) {
-                               fprintf(outf, "invalid iteration count: %s\n", optarg);
-                               exit(2);
-                       }
+                       if (errno || num_iterations == 0)
+                               errx(-1, "invalid iteration count: %s", optarg);
                        break;
                case 'N':
                        header_iterations = strtoul(optarg, NULL, 0);
                        errno = 0;
 
-                       if (errno || header_iterations == 0) {
-                               fprintf(outf, "invalid header iteration count: %s\n", optarg);
-                               exit(2);
-                       }
+                       if (errno || header_iterations == 0)
+                               errx(-1, "invalid header iteration count: %s", optarg);
                        break;
                case 's':
                        /*
@@ -11574,6 +11569,9 @@ void cmdline(int argc, char **argv)
                        print_version();
                        exit(0);
                        break;
+               default:
+                       help();
+                       exit(1);
                }
        }
 }