Skip to content

Commit 1a23ba6

Browse files
committed
tools/power turbostat: Print wide names only for RAW 64-bit columns
Print a wide column header only for the case of a 64-bit RAW counter. It turns out that wide column headers otherwise are more harm than good. Signed-off-by: Len Brown <len.brown@intel.com>
1 parent 2ba8b24 commit 1a23ba6

1 file changed

Lines changed: 21 additions & 19 deletions

File tree

tools/power/x86/turbostat/turbostat.c

Lines changed: 21 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -2723,20 +2723,22 @@ void bic_lookup(cpu_set_t *ret_set, char *name_list, enum show_hide_mode mode)
27232723

27242724
/*
27252725
* print_name()
2726-
* Print column header name for 64-bit counter in 16 columns (at least 8-char plus a tab)
2726+
* Print column header name for raw 64-bit counter in 16 columns (at least 8-char plus a tab)
27272727
* Otherwise, allow the name + tab to fit within 8-coumn tab-stop.
27282728
* In both cases, left justififed, just like other turbostat columns,
27292729
* to allow the column values to consume the tab.
27302730
*
2731-
* Yes, 32-bit counters can overflow 8-columns, but then they are usually 64-bit counters.
2732-
* 64-bit counters can overflow 16-columns, but rarely do.
2731+
* Yes, 32-bit counters can overflow 8-columns, and
2732+
* 64-bit counters can overflow 16-columns, but that is uncommon.
27332733
*/
2734-
static inline int print_name(int width, int *printed, char *delim, char *name)
2734+
static inline int print_name(int width, int *printed, char *delim, char *name, enum counter_type type, enum counter_format format)
27352735
{
2736-
if (width <= 32)
2737-
return (sprintf(outp, "%s%s", (*printed++ ? delim : ""), name));
2738-
else
2736+
UNUSED(type);
2737+
2738+
if (format == FORMAT_RAW && width >= 64)
27392739
return (sprintf(outp, "%s%-8s", (*printed++ ? delim : ""), name));
2740+
else
2741+
return (sprintf(outp, "%s%s", (*printed++ ? delim : ""), name));
27402742
}
27412743
static inline int print_hex_value(int width, int *printed, char *delim, unsigned long long value)
27422744
{
@@ -2819,21 +2821,21 @@ void print_header(char *delim)
28192821
outp += sprintf(outp, "%sLLC%%hit", (printed++ ? delim : ""));
28202822

28212823
for (mp = sys.tp; mp; mp = mp->next)
2822-
outp += print_name(mp->width, &printed, delim, mp->name);
2824+
outp += print_name(mp->width, &printed, delim, mp->name, mp->type, mp->format);
28232825

28242826
for (pp = sys.perf_tp; pp; pp = pp->next)
2825-
outp += print_name(pp->width, &printed, delim, pp->name);
2827+
outp += print_name(pp->width, &printed, delim, pp->name, pp->type, pp->format);
28262828

28272829
ppmt = sys.pmt_tp;
28282830
while (ppmt) {
28292831
switch (ppmt->type) {
28302832
case PMT_TYPE_RAW:
2831-
outp += print_name(pmt_counter_get_width(ppmt), &printed, delim, ppmt->name);
2833+
outp += print_name(pmt_counter_get_width(ppmt), &printed, delim, ppmt->name, COUNTER_ITEMS, ppmt->format);
28322834
break;
28332835

28342836
case PMT_TYPE_XTAL_TIME:
28352837
case PMT_TYPE_TCORE_CLOCK:
2836-
outp += print_name(32, &printed, delim, ppmt->name);
2838+
outp += print_name(32, &printed, delim, ppmt->name, COUNTER_ITEMS, ppmt->format);
28372839
break;
28382840
}
28392841

@@ -2867,22 +2869,22 @@ void print_header(char *delim)
28672869
}
28682870

28692871
for (mp = sys.cp; mp; mp = mp->next)
2870-
outp += print_name(mp->width, &printed, delim, mp->name);
2872+
outp += print_name(mp->width, &printed, delim, mp->name, mp->type, mp->format);
28712873

28722874
for (pp = sys.perf_cp; pp; pp = pp->next)
2873-
outp += print_name(pp->width, &printed, delim, pp->name);
2875+
outp += print_name(pp->width, &printed, delim, pp->name, pp->type, pp->format);
28742876

28752877
ppmt = sys.pmt_cp;
28762878
while (ppmt) {
28772879
switch (ppmt->type) {
28782880
case PMT_TYPE_RAW:
2879-
outp += print_name(pmt_counter_get_width(ppmt), &printed, delim, ppmt->name);
2881+
outp += print_name(pmt_counter_get_width(ppmt), &printed, delim, ppmt->name, COUNTER_ITEMS, ppmt->format);
28802882

28812883
break;
28822884

28832885
case PMT_TYPE_XTAL_TIME:
28842886
case PMT_TYPE_TCORE_CLOCK:
2885-
outp += print_name(32, &printed, delim, ppmt->name);
2887+
outp += print_name(32, &printed, delim, ppmt->name, COUNTER_ITEMS, ppmt->format);
28862888
break;
28872889
}
28882890

@@ -2970,21 +2972,21 @@ void print_header(char *delim)
29702972
outp += sprintf(outp, "%sUncMHz", (printed++ ? delim : ""));
29712973

29722974
for (mp = sys.pp; mp; mp = mp->next)
2973-
outp += print_name(mp->width, &printed, delim, mp->name);
2975+
outp += print_name(mp->width, &printed, delim, mp->name, mp->type, mp->format);
29742976

29752977
for (pp = sys.perf_pp; pp; pp = pp->next)
2976-
outp += print_name(pp->width, &printed, delim, pp->name);
2978+
outp += print_name(pp->width, &printed, delim, pp->name, pp->type, pp->format);
29772979

29782980
ppmt = sys.pmt_pp;
29792981
while (ppmt) {
29802982
switch (ppmt->type) {
29812983
case PMT_TYPE_RAW:
2982-
outp += print_name(pmt_counter_get_width(ppmt), &printed, delim, ppmt->name);
2984+
outp += print_name(pmt_counter_get_width(ppmt), &printed, delim, ppmt->name, COUNTER_ITEMS, ppmt->format);
29832985
break;
29842986

29852987
case PMT_TYPE_XTAL_TIME:
29862988
case PMT_TYPE_TCORE_CLOCK:
2987-
outp += print_name(32, &printed, delim, ppmt->name);
2989+
outp += print_name(32, &printed, delim, ppmt->name, COUNTER_ITEMS, ppmt->format);
29882990
break;
29892991
}
29902992

0 commit comments

Comments
 (0)