Skip to content

Commit dcd1c37

Browse files
intel-hmlenb
authored andcommitted
tools/power turbostat: add format "average" for external attributes
External atributes with format "raw" are not printed in summary lines for nodes/packages (or with option -S). The new format "average" behaves like "raw" but also adds the summary data Signed-off-by: Michael Hebenstreit <[email protected]> Signed-off-by: Len Brown <[email protected]>
1 parent a5015d9 commit dcd1c37

File tree

2 files changed

+22
-11
lines changed

2 files changed

+22
-11
lines changed

tools/power/x86/turbostat/turbostat.8

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -47,10 +47,11 @@ name as necessary to disambiguate it from others is necessary. Note that option
4747
MSRs are read as 64-bits, u32 truncates the displayed value to 32-bits.
4848
default: u64
4949

50-
format: {\fBraw\fP | \fBdelta\fP | \fBpercent\fP}
50+
format: {\fBraw\fP | \fBdelta\fP | \fBpercent\fP | \fBaverage\fP}
5151
'raw' shows the MSR contents in hex.
5252
'delta' shows the difference in values during the measurement interval.
5353
'percent' shows the delta as a percentage of the cycles elapsed.
54+
'average' similar to raw, but also averaged for node/package summaries (or when using -S).
5455
default: delta
5556

5657
name: "name_string"

tools/power/x86/turbostat/turbostat.c

Lines changed: 20 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -2756,7 +2756,7 @@ void print_header(char *delim)
27562756

27572757
for (mp = sys.tp; mp; mp = mp->next) {
27582758

2759-
if (mp->format == FORMAT_RAW) {
2759+
if (mp->format == FORMAT_RAW || mp->format == FORMAT_AVERAGE) {
27602760
if (mp->width == 64)
27612761
outp += sprintf(outp, "%s%18.18s", (printed++ ? delim : ""), mp->name);
27622762
else
@@ -2831,7 +2831,7 @@ void print_header(char *delim)
28312831
}
28322832

28332833
for (mp = sys.cp; mp; mp = mp->next) {
2834-
if (mp->format == FORMAT_RAW) {
2834+
if (mp->format == FORMAT_RAW || mp->format == FORMAT_AVERAGE) {
28352835
if (mp->width == 64)
28362836
outp += sprintf(outp, "%s%18.18s", delim, mp->name);
28372837
else
@@ -2961,7 +2961,7 @@ void print_header(char *delim)
29612961
outp += sprintf(outp, "%sUncMHz", (printed++ ? delim : ""));
29622962

29632963
for (mp = sys.pp; mp; mp = mp->next) {
2964-
if (mp->format == FORMAT_RAW) {
2964+
if (mp->format == FORMAT_RAW || mp->format == FORMAT_AVERAGE) {
29652965
if (mp->width == 64)
29662966
outp += sprintf(outp, "%s%18.18s", delim, mp->name);
29672967
else if (mp->width == 32)
@@ -3282,7 +3282,7 @@ int format_counters(struct thread_data *t, struct core_data *c, struct pkg_data
32823282

32833283
/* Added counters */
32843284
for (i = 0, mp = sys.tp; mp; i++, mp = mp->next) {
3285-
if (mp->format == FORMAT_RAW) {
3285+
if (mp->format == FORMAT_RAW || mp->format == FORMAT_AVERAGE) {
32863286
if (mp->width == 32)
32873287
outp +=
32883288
sprintf(outp, "%s0x%08x", (printed++ ? delim : ""), (unsigned int)t->counter[i]);
@@ -3379,7 +3379,7 @@ int format_counters(struct thread_data *t, struct core_data *c, struct pkg_data
33793379
outp += sprintf(outp, "%s%lld", (printed++ ? delim : ""), c->core_throt_cnt);
33803380

33813381
for (i = 0, mp = sys.cp; mp; i++, mp = mp->next) {
3382-
if (mp->format == FORMAT_RAW) {
3382+
if (mp->format == FORMAT_RAW || mp->format == FORMAT_AVERAGE) {
33833383
if (mp->width == 32)
33843384
outp +=
33853385
sprintf(outp, "%s0x%08x", (printed++ ? delim : ""), (unsigned int)c->counter[i]);
@@ -3578,7 +3578,7 @@ int format_counters(struct thread_data *t, struct core_data *c, struct pkg_data
35783578
outp += sprintf(outp, "%s%d", (printed++ ? delim : ""), p->uncore_mhz);
35793579

35803580
for (i = 0, mp = sys.pp; mp; i++, mp = mp->next) {
3581-
if (mp->format == FORMAT_RAW) {
3581+
if (mp->format == FORMAT_RAW || mp->format == FORMAT_AVERAGE) {
35823582
if (mp->width == 32)
35833583
outp +=
35843584
sprintf(outp, "%s0x%08x", (printed++ ? delim : ""), (unsigned int)p->counter[i]);
@@ -3755,7 +3755,7 @@ int delta_package(struct pkg_data *new, struct pkg_data *old)
37553755
new->rapl_dram_perf_status.raw_value - old->rapl_dram_perf_status.raw_value;
37563756

37573757
for (i = 0, mp = sys.pp; mp; i++, mp = mp->next) {
3758-
if (mp->format == FORMAT_RAW)
3758+
if (mp->format == FORMAT_RAW || mp->format == FORMAT_AVERAGE)
37593759
old->counter[i] = new->counter[i];
37603760
else if (mp->format == FORMAT_AVERAGE)
37613761
old->counter[i] = new->counter[i];
@@ -3799,7 +3799,7 @@ void delta_core(struct core_data *new, struct core_data *old)
37993799
DELTA_WRAP32(new->core_energy.raw_value, old->core_energy.raw_value);
38003800

38013801
for (i = 0, mp = sys.cp; mp; i++, mp = mp->next) {
3802-
if (mp->format == FORMAT_RAW)
3802+
if (mp->format == FORMAT_RAW || mp->format == FORMAT_AVERAGE)
38033803
old->counter[i] = new->counter[i];
38043804
else
38053805
old->counter[i] = new->counter[i] - old->counter[i];
@@ -3913,7 +3913,7 @@ int delta_thread(struct thread_data *new, struct thread_data *old, struct core_d
39133913
old->smi_count = new->smi_count - old->smi_count;
39143914

39153915
for (i = 0, mp = sys.tp; mp; i++, mp = mp->next) {
3916-
if (mp->format == FORMAT_RAW)
3916+
if (mp->format == FORMAT_RAW || mp->format == FORMAT_AVERAGE)
39173917
old->counter[i] = new->counter[i];
39183918
else
39193919
old->counter[i] = new->counter[i] - old->counter[i];
@@ -10419,6 +10419,10 @@ void parse_add_command_msr(char *add_command)
1041910419
format = FORMAT_RAW;
1042010420
goto next;
1042110421
}
10422+
if (!strncmp(add_command, "average", strlen("average"))) {
10423+
format = FORMAT_AVERAGE;
10424+
goto next;
10425+
}
1042210426
if (!strncmp(add_command, "delta", strlen("delta"))) {
1042310427
format = FORMAT_DELTA;
1042410428
goto next;
@@ -10691,13 +10695,19 @@ void parse_add_command_pmt(char *add_command)
1069110695
has_format = true;
1069210696
}
1069310697

10698+
if (strcmp("average", format_name) == 0) {
10699+
format = FORMAT_AVERAGE;
10700+
has_format = true;
10701+
}
10702+
1069410703
if (strcmp("delta", format_name) == 0) {
1069510704
format = FORMAT_DELTA;
1069610705
has_format = true;
1069710706
}
1069810707

1069910708
if (!has_format) {
10700-
fprintf(stderr, "%s: Invalid format %s. Expected raw or delta\n", __func__, format_name);
10709+
fprintf(stderr, "%s: Invalid format %s. Expected raw, average or delta\n",
10710+
__func__, format_name);
1070110711
exit(1);
1070210712
}
1070310713
}

0 commit comments

Comments
 (0)