Skip to content

Commit 96718ad

Browse files
committed
tools/power turbostat: Fix and document --header_iterations
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>
1 parent 8e5c0cc commit 96718ad

2 files changed

Lines changed: 12 additions & 12 deletions

File tree

tools/power/x86/turbostat/turbostat.8

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -111,12 +111,14 @@ The column name "all" can be used to enable all disabled-by-default built-in cou
111111
.PP
112112
\fB--no-perf\fP Disable all the uses of the perf API.
113113
.PP
114-
\fB--force\fPForce turbostat to run on an unsupported platform (minimal defaults).
114+
\fB--force\fP Force turbostat to run on an unsupported platform (minimal defaults).
115115
.PP
116116
\fB--interval seconds\fP overrides the default 5.0 second measurement interval.
117117
.PP
118118
\fB--num_iterations num\fP number of the measurement iterations.
119119
.PP
120+
\fB--header_iterations num\fP print header every num iterations.
121+
.PP
120122
\fB--out output_file\fP turbostat output is written to the specified output_file.
121123
The file is truncated if it already exists, and it is created if it does not exist.
122124
.PP

tools/power/x86/turbostat/turbostat.c

Lines changed: 9 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -11443,7 +11443,7 @@ void cmdline(int argc, char **argv)
1144311443
* Parse some options early, because they may make other options invalid,
1144411444
* like adding the MSR counter with --add and at the same time using --no-msr.
1144511445
*/
11446-
while ((opt = getopt_long_only(argc, argv, "+MPn:", long_options, &option_index)) != -1) {
11446+
while ((opt = getopt_long_only(argc, argv, "+:MP", long_options, &option_index)) != -1) {
1144711447
switch (opt) {
1144811448
case 'M':
1144911449
no_msr = 1;
@@ -11457,7 +11457,7 @@ void cmdline(int argc, char **argv)
1145711457
}
1145811458
optind = 0;
1145911459

11460-
while ((opt = getopt_long_only(argc, argv, "+C:c:Dde:hi:Jn:o:qMST:v", long_options, &option_index)) != -1) {
11460+
while ((opt = getopt_long_only(argc, argv, "+C:c:Dde:hi:Jn:N:o:qMST:v", long_options, &option_index)) != -1) {
1146111461
switch (opt) {
1146211462
case 'a':
1146311463
parse_add_command(optarg);
@@ -11500,7 +11500,6 @@ void cmdline(int argc, char **argv)
1150011500
}
1150111501
break;
1150211502
case 'h':
11503-
default:
1150411503
help();
1150511504
exit(1);
1150611505
case 'i':
@@ -11539,19 +11538,15 @@ void cmdline(int argc, char **argv)
1153911538
num_iterations = strtoul(optarg, NULL, 0);
1154011539
errno = 0;
1154111540

11542-
if (errno || num_iterations == 0) {
11543-
fprintf(outf, "invalid iteration count: %s\n", optarg);
11544-
exit(2);
11545-
}
11541+
if (errno || num_iterations == 0)
11542+
errx(-1, "invalid iteration count: %s", optarg);
1154611543
break;
1154711544
case 'N':
1154811545
header_iterations = strtoul(optarg, NULL, 0);
1154911546
errno = 0;
1155011547

11551-
if (errno || header_iterations == 0) {
11552-
fprintf(outf, "invalid header iteration count: %s\n", optarg);
11553-
exit(2);
11554-
}
11548+
if (errno || header_iterations == 0)
11549+
errx(-1, "invalid header iteration count: %s", optarg);
1155511550
break;
1155611551
case 's':
1155711552
/*
@@ -11574,6 +11569,9 @@ void cmdline(int argc, char **argv)
1157411569
print_version();
1157511570
exit(0);
1157611571
break;
11572+
default:
11573+
help();
11574+
exit(1);
1157711575
}
1157811576
}
1157911577
}

0 commit comments

Comments
 (0)