perf tools: Honor column width setting
Namhyung Kim
maintainercover perf tools: Honor column width setting
Hello,
This patchset is to control perf report/top output column width by -w/--column-widths option so that it can fit into the terminal size. The -w option is there for perf report but it ignored by recent output field changed due to some reason. This patchset fixes it and supports perf top also.
This is sometimes useful if your terminal is small and there's some C++ applications which have amazingly long symbol names. Without this patchset user might not see those symbols on TUI, since it maps left/right arrow keys to other functions.
The -w option sets column width starting from the first column (overhead or optional overhead_children column unless -F option is given). It doesn't make sense to limit those overhead columns so it's not a hard-limit for them. But it *is* a hard-limit for other columns such as comm, dso, symbol, and so on. One can use 0 not to limit/force a width for those columns.
For example:
$ perf report --stdio -s comm,dso
...
# Overhead Command Shared Object
# ........ ............... .....................................................
#
71.08% gnome-shell perf-1497.map
9.23% gnome-shell swrast_dri.so
3.99% Xorg [unknown]
3.18% Xorg [kernel.kallsyms]
2.93% gnome-shell [kernel.kallsyms]
2.41% swapper [kernel.kallsyms]
1.55% synergys libpthread-2.15.so
1.08% synergys synergys
0.68% systemd-journal [kernel.kallsyms]
0.59% synergys libstdc++.so.6.0.17
0.58% gnome-shell libc-2.15.so
0.54% kworker/0:2 [kernel.kallsyms]
0.20% systemd-journal [unknown]
0.19% gnome-shell libclutter-1.0.so.0.1000.8.#prelink#.1kh1we (deleted)
0.18% firefox libxul.so (deleted)
0.17% gnome-shell libcogl.so.9.1.1.#prelink#.ZL3fn1 (deleted)
0.14% firefox [kernel.kallsyms]
0.14% gnome-shell libgobject-2.0.so.0.3200.4
0.13% gnome-shell libpthread-2.15.so
0.11% synergys [kernel.kallsyms]
0.10% perf [kernel.kallsyms] $ perf report --stdio -s comm,dso -w 0,10,20 # 0 means no limit
...
# Overhead Command Shared Object
# ........ .......... ....................
#
71.08% gnome-shel perf-1497.map
9.23% gnome-shel swrast_dri.so
3.99% Xorg [unknown]
3.18% Xorg [kernel.kallsyms]
2.93% gnome-shel [kernel.kallsyms]
2.41% swapper [kernel.kallsyms]
1.55% synergys libpthread-2.15.so
1.08% synergys synergys
0.68% systemd-jo [kernel.kallsyms]
0.59% synergys libstdc++.so.6.0.17
0.58% gnome-shel libc-2.15.so
0.54% kworker/0: [kernel.kallsyms]
0.20% systemd-jo [unknown]
0.19% gnome-shel libclutter-1.0.so.0.
0.18% firefox libxul.so (deleted)
0.17% gnome-shel libcogl.so.9.1.1.#pr
0.14% firefox [kernel.kallsyms]
0.14% gnome-shel libgobject-2.0.so.0.
0.13% gnome-shel libpthread-2.15.so
0.11% synergys [kernel.kallsyms]
0.10% perf [kernel.kallsyms] You can also get this from 'perf/width-v1' branch on my tree
git://git.kernel.org/pub/scm/linux/kernel/git/namhyung/linux-perf.git
Thanks,
Namhyung
Namhyung Kim (6):
perf tools: Left-align output contents
perf tools: Make __hpp__fmt() receive an additional len argument perf tools: Save column length in perf_hpp_fmt
perf report: Honor column width setting
perf top: Add -w option for setting column width
perf tools: Add name field into perf_hpp_fmt
tools/perf/Documentation/perf-report.txt | 2 +- tools/perf/Documentation/perf-top.txt | 6 + tools/perf/builtin-top.c | 3 + tools/perf/ui/browsers/hists.c | 31 ++-- tools/perf/ui/gtk/hists.c | 18 +- tools/perf/ui/hist.c | 275 +++++++++++++++++++------------ tools/perf/ui/stdio/hist.c | 4 +- tools/perf/util/color.c | 16 ++ tools/perf/util/color.h | 1 + tools/perf/util/hist.h | 17 +- tools/perf/util/sort.c | 51 +++--- 11 files changed, 274 insertions(+), 150 deletions(-)
Signature · 1 line
2.0.0
Namhyung Kim
maintainerPATCH 1/6 perf tools: Left-align output contents
Now perf left-aligns column headers but the contents does not. It should have same alignment.
--- tools/perf/util/sort.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-)
tools/perf/util/sort.c +3 -3
@@ -70,7 +70,7 @@ static int hist_entry__thread_snprintf(struct hist_entry *he, char *bf, size_t size, unsigned int width) {const char *comm =thread__comm_str (he->thread); -return repsep_snprintf (bf, size,"%*s:%5d" , width -6 , +return repsep_snprintf (bf, size,"%-*s:%5d" , width -6 , comm ?:"" , he->thread->tid); }
@@ -106,7 +106,7 @@ sort__comm_sort(struct hist_entry *left, struct hist_entry *right)static int hist_entry__comm_snprintf (struct hist_entry *he,char *bf,size_t size,unsigned int width) { -return repsep_snprintf (bf, size,"%*s" , width,comm__str (he->comm)); +return repsep_snprintf (bf, size,"%-*s" , width,comm__str (he->comm)); }struct sort_entry sort_comm = {
@@ -305,7 +305,7 @@ static int hist_entry__srcline_snprintf(struct hist_entry *he, char *bf, size_t size, unsigned int width __maybe_unused) { -return repsep_snprintf (bf, size,"%s" , he->srcline); +return repsep_snprintf (bf, size,"%-s" , he->srcline); }struct sort_entry sort_srcline = {
Signature · 1 line
2.0.0
Namhyung Kim
maintainerPATCH 2/6 perf tools: Make __hpp__fmt() receive an additional len argument
In reply to Namhyung KimSo that it can properly handle alignment requirements later. To do that, add percent_color_len_snprintf() fucntion to help coloring of overhead columns.
--- tools/perf/ui/browsers/hists.c | 14 ++++++++------ tools/perf/ui/gtk/hists.c | 8 +++++--- tools/perf/ui/hist.c | 43 +++++++++++++++++++++--------------------- tools/perf/util/color.c | 16 ++++++++++++++++ tools/perf/util/color.h | 1 + tools/perf/util/hist.h | 4 ++-- 6 files changed, 54 insertions(+), 32 deletions(-)
tools/perf/ui/browsers/hists.c +8 -6
@@ -653,17 +653,18 @@ struct hpp_arg {static int __hpp__slsmg_color_printf (struct perf_hpp *hpp,const char *fmt, ...) {struct hpp_arg *arg = hpp->ptr; -int ret; +int ret, len;va_list args;double percent;va_start (args, fmt); + len =va_arg (args, int); percent =va_arg (args, double);va_end (args);ui_browser__set_percent_color (arg->b, percent, arg->current_entry); - ret =scnprintf (hpp->buf, hpp->size, fmt, percent); + ret =scnprintf (hpp->buf, hpp->size, fmt, len, percent);slsmg_printf ("%s" , hpp->buf);advance_hpp (hpp, ret);
@@ -681,7 +682,7 @@ hist_browser__hpp_color_##_type(struct perf_hpp_fmt *fmt __maybe_unused,\struct perf_hpp *hpp, \ struct hist_entry *he) \ { \ - return __hpp__fmt(hpp, he, __hpp_get_##_field, " %6.2f%%", \ + return __hpp__fmt(hpp, he, __hpp_get_##_field, " %*.2f%%", 6, \__hpp__slsmg_color_printf ,true ); \ }
@@ -697,13 +698,14 @@ hist_browser__hpp_color_##_type(struct perf_hpp_fmt *fmt __maybe_unused,\ struct hist_entry *he) \ { \if (!symbol_conf.cumulate_callchain) { \ -int ret =scnprintf (hpp->buf, hpp->size,"%8s" ,"N/A" ); \ +int ret =scnprintf (hpp->buf, hpp->size, \ +"%*s" ,8 ,"N/A" ); \slsmg_printf ("%s" , hpp->buf); \ \return ret; \ } \ - return __hpp__fmt(hpp, he, __hpp_get_acc_##_field, " %6.2f%%", \ - __hpp__slsmg_color_printf, true); \ + return __hpp__fmt(hpp, he, __hpp_get_acc_##_field, " %*.2f%%", \ +6 , __hpp__slsmg_color_printf, true); \ }__HPP_COLOR_PERCENT_FN (overhead, period)
tools/perf/ui/gtk/hists.c +5 -3
@@ -11,6 +11,7 @@static int __percent_color_snprintf (struct perf_hpp *hpp,const char *fmt, ...) {int ret =0 ; +int len;va_list args;double percent;const char *markup;
@@ -18,6 +19,7 @@ static int __percent_color_snprintf(struct perf_hpp *hpp, const char *fmt, ...)size_t size = hpp->size;va_start (args, fmt); + len =va_arg (args, int); percent =va_arg (args, double);va_end (args);
@@ -25,7 +27,7 @@ static int __percent_color_snprintf(struct perf_hpp *hpp, const char *fmt, ...)if (markup) ret +=scnprintf (buf, size, markup); - ret +=scnprintf (buf + ret, size - ret, fmt, percent); + ret +=scnprintf (buf + ret, size - ret, fmt, len, percent);if (markup) ret +=scnprintf (buf + ret, size - ret,"</span>" );
@@ -43,7 +45,7 @@ static int perf_gtk__hpp_color_##_type(struct perf_hpp_fmt *fmt __maybe_unused,struct perf_hpp *hpp, \ struct hist_entry *he) \ { \ - return __hpp__fmt(hpp, he, he_get_##_field, " %6.2f%%", \ + return __hpp__fmt(hpp, he, he_get_##_field, " %*.2f%%", 6, \__percent_color_snprintf ,true ); \ }
@@ -57,7 +59,7 @@ static int perf_gtk__hpp_color_##_type(struct perf_hpp_fmt *fmt __maybe_unused,struct perf_hpp *hpp, \ struct hist_entry *he) \ { \ - return __hpp__fmt_acc(hpp, he, he_get_acc_##_field, " %6.2f%%", \ + return __hpp__fmt_acc(hpp, he, he_get_acc_##_field, " %*.2f%%", 6, \__percent_color_snprintf ,true ); \ }
tools/perf/ui/hist.c +22 -21
130 lines not on this page · raw message
tools/perf/util/color.c +16 -0
@@ -335,3 +335,19 @@ int percent_color_snprintf(char *bf, size_t size, const char *fmt, ...)va_end (args);return value_color_snprintf (bf, size, fmt, percent); } + +int percent_color_len_snprintf (char *bf,size_t size,const char *fmt, ...) +{ +va_list args; +int len; +double percent; +const char *color; + +va_start (args, fmt); + len =va_arg (args, int); + percent =va_arg (args, double); +va_end (args); + + color =get_percent_color (percent); +return color_snprintf (bf, size, color, fmt, len, percent); +}
tools/perf/util/color.h +1 -0
@@ -41,6 +41,7 @@ int color_fprintf_ln(FILE *fp, const char *color, const char *fmt, ...);int color_fwrite_lines (FILE *fp,const char *color,size_t count,const char *buf);int value_color_snprintf (char *bf,size_t size,const char *fmt,double value);int percent_color_snprintf (char *bf,size_t size,const char *fmt, ...); +int percent_color_len_snprintf (char *bf,size_t size,const char *fmt, ...);int percent_color_fprintf (FILE *fp,const char *fmt,double percent);const char *get_percent_color (double percent);
tools/perf/util/hist.h +2 -2
@@ -267,10 +267,10 @@ typedef int (*hpp_callback_fn)(struct perf_hpp *hpp, bool front);typedef int (*hpp_snprint_fn )(struct perf_hpp *hpp,const char *fmt, ...);int __hpp__fmt (struct perf_hpp *hpp,struct hist_entry *he, -hpp_field_fn get_field,const char *fmt, +hpp_field_fn get_field,const char *fmt,int len,hpp_snprint_fn print_fn,bool fmt_percent);int __hpp__fmt_acc (struct perf_hpp *hpp,struct hist_entry *he, -hpp_field_fn get_field,const char *fmt, +hpp_field_fn get_field,const char *fmt,int len,hpp_snprint_fn print_fn,bool fmt_percent);static inline void advance_hpp (struct perf_hpp *hpp,int inc)
Signature · 1 line
2.0.0
Namhyung Kim
maintainerPATCH 3/6 perf tools: Save column length in perf_hpp_fmt
In reply to Namhyung KimSave column length in the hpp format and pass it to print functions. This is a preparation for users to control column width in the output.
--- tools/perf/ui/browsers/hists.c | 2 +- tools/perf/ui/hist.c | 135 +++++++++++++++++++++++++++-------------- tools/perf/util/hist.h | 2 + tools/perf/util/sort.c | 3 +- 4 files changed, 94 insertions(+), 48 deletions(-)
tools/perf/ui/browsers/hists.c +1 -1
@@ -849,7 +849,7 @@ static int hists__scnprintf_headers(char *buf, size_t size, struct hists *hists)if (perf_hpp__should_skip (fmt))continue ; -/* We need to add the length of the columns header. */ +/* We need to ensure length of the columns header. */ perf_hpp__reset_width (fmt, hists); ret = fmt->header (fmt, &dummy_hpp,hists_to_evsel (hists));
tools/perf/ui/hist.c +89 -46
226 lines not on this page · raw message
tools/perf/util/hist.h +2 -0
@@ -207,6 +207,7 @@ struct perf_hpp_fmt {struct list_head list;struct list_head sort_list;bool elide; +int len; };extern struct list_head perf_hpp__list;
@@ -261,6 +262,7 @@ static inline bool perf_hpp__should_skip(struct perf_hpp_fmt *format) }void perf_hpp__reset_width (struct perf_hpp_fmt *fmt,struct hists *hists); +void perf_hpp__reset_sort_width (struct perf_hpp_fmt *fmt,struct hists *hists);typedef u64 (*hpp_field_fn )(struct hist_entry *he);typedef int (*hpp_callback_fn )(struct perf_hpp *hpp,bool front);
tools/perf/util/sort.c +2 -1
@@ -1194,7 +1194,7 @@ bool perf_hpp__same_sort_entry(struct perf_hpp_fmt *a, struct perf_hpp_fmt *b)return hse_a->se == hse_b->se; } -void perf_hpp__reset_width (struct perf_hpp_fmt *fmt,struct hists *hists) +void perf_hpp__reset_sort_width (struct perf_hpp_fmt *fmt,struct hists *hists) {struct hpp_sort_entry *hse;
@@ -1265,6 +1265,7 @@ __sort_dimension__alloc_hpp(struct sort_dimension *sd)INIT_LIST_HEAD (&hse->hpp.list);INIT_LIST_HEAD (&hse->hpp.sort_list); hse->hpp.elide = false; + hse->hpp.len =0 ;return hse; }
Signature · 1 line
2.0.0
Re: [PATCH 3/6] perf tools: Save column length in perf_hpp_fmt
Quoted 2 lines · Namhyung Kim
Save column length in the hpp format and pass it to print functions. This is a preparation for users to control column width in the output.
SNIP
Quoted 18 lines
tools/perf/ui/hist.c +18
-0+ +void perf_hpp__reset_width (struct perf_hpp_fmt *fmt,struct hists *hists) +{ +int idx; + +if (perf_hpp__is_sort_entry (fmt)) +return perf_hpp__reset_sort_width (fmt, hists); + +for (idx =0 ; idx <PERF_HPP__MAX_INDEX ; idx++) { +if (fmt == &perf_hpp__format[idx]) +break ; + } + +if (idx ==PERF_HPP__MAX_INDEX ) +return ; + +switch (idx) { +case PERF_HPP__OVERHEAD :
tools/perf/ui/hist.c unsigned int hists__sort_list_width(struct hists *hists) · line 658
Quoted 10 lines
tools/perf/ui/hist.c +10
-0+case PERF_HPP__OVERHEAD_SYS : +case PERF_HPP__OVERHEAD_US : +case PERF_HPP__OVERHEAD_ACC : + fmt->len =8 ; +break ; + +case PERF_HPP__OVERHEAD_GUEST_SYS : +case PERF_HPP__OVERHEAD_GUEST_US : + fmt->len =9 ; +break ;
just curious.. why is it 9 for guest %, while we use 8 for host? I understand that was the current state
jirka
Namhyung Kim
maintainerRe: [PATCH 3/6] perf tools: Save column length in perf_hpp_fmt
Quoted 29 lines · Jiri Olsa
Quoted 2 lines · Namhyung Kim
Save column length in the hpp format and pass it to print functions. This is a preparation for users to control column width in the output.
SNIP
Quoted 23 lines
tools/perf/ui/hist.c +23
-0+ +void perf_hpp__reset_width (struct perf_hpp_fmt *fmt,struct hists *hists) +{ +int idx; + +if (perf_hpp__is_sort_entry (fmt)) +return perf_hpp__reset_sort_width (fmt, hists); + +for (idx =0 ; idx <PERF_HPP__MAX_INDEX ; idx++) { +if (fmt == &perf_hpp__format[idx]) +break ; + } + +if (idx ==PERF_HPP__MAX_INDEX ) +return ; + +switch (idx) { +case PERF_HPP__OVERHEAD : +case PERF_HPP__OVERHEAD_SYS : +case PERF_HPP__OVERHEAD_US : +case PERF_HPP__OVERHEAD_ACC : + fmt->len =8 ; +break ;
Quoted 8 lines
tools/perf/ui/hist.c unsigned int hists__sort_list_width(struct hists *hists) · line 658
Quoted 5 lines
tools/perf/ui/hist.c +5
-0+ +case PERF_HPP__OVERHEAD_GUEST_SYS : +case PERF_HPP__OVERHEAD_GUEST_US : + fmt->len =9 ; +break ;just curious.. why is it 9 for guest %, while we use 8 for host? I understand that was the current state
It's the strlen of header - "guest sys". :)
Thanks,
Namhyung
Re: [PATCH 3/6] perf tools: Save column length in perf_hpp_fmt
Quoted 39 lines · Namhyung Kim
Quoted 29 lines · Jiri Olsa
Quoted 2 lines · Namhyung Kim
Save column length in the hpp format and pass it to print functions. This is a preparation for users to control column width in the output.
SNIP
Quoted 23 lines
tools/perf/ui/hist.c +23
-0+ +void perf_hpp__reset_width (struct perf_hpp_fmt *fmt,struct hists *hists) +{ +int idx; + +if (perf_hpp__is_sort_entry (fmt)) +return perf_hpp__reset_sort_width (fmt, hists); + +for (idx =0 ; idx <PERF_HPP__MAX_INDEX ; idx++) { +if (fmt == &perf_hpp__format[idx]) +break ; + } + +if (idx ==PERF_HPP__MAX_INDEX ) +return ; + +switch (idx) { +case PERF_HPP__OVERHEAD : +case PERF_HPP__OVERHEAD_SYS : +case PERF_HPP__OVERHEAD_US : +case PERF_HPP__OVERHEAD_ACC : + fmt->len =8 ; +break ;Quoted 8 lines
tools/perf/ui/hist.c unsigned int hists__sort_list_width(struct hists *hists) · line 658
Quoted 5 lines
tools/perf/ui/hist.c +5
-0+ +case PERF_HPP__OVERHEAD_GUEST_SYS : +case PERF_HPP__OVERHEAD_GUEST_US : + fmt->len =9 ; +break ;just curious.. why is it 9 for guest %, while we use 8 for host? I understand that was the current state
Quoted 1 line
It's the strlen of header - "guest sys". :)
argh.. I did not think of header, just value ;-)
thanks,
jirka
Namhyung Kim
maintainerPATCH 4/6 perf report: Honor column width setting
In reply to Namhyung KimSet column width and do not change it if user gives -w/--column-widths option. It'll truncate longer symbols than the width if exists.
--- tools/perf/ui/browsers/hists.c | 23 ++++++++---- tools/perf/ui/gtk/hists.c | 10 ++--- tools/perf/ui/hist.c | 84 +++++++++++++++++++++++++++++------------- tools/perf/ui/stdio/hist.c | 4 +- tools/perf/util/hist.h | 14 ++++--- tools/perf/util/sort.c | 44 +++++++++++++--------- 6 files changed, 116 insertions(+), 63 deletions(-)
tools/perf/ui/browsers/hists.c +15 -8
@@ -678,12 +678,12 @@ static u64 __hpp_get_##_field(struct hist_entry *he) \ } \ \static int \ -hist_browser__hpp_color_##_type(struct perf_hpp_fmt *fmt __maybe_unused,\ +hist_browser__hpp_color_##_type(struct perf_hpp_fmt *fmt, \struct perf_hpp *hpp, \struct hist_entry *he) \ { \ - return __hpp__fmt(hpp, he, __hpp_get_##_field, " %*.2f%%", 6, \ - __hpp__slsmg_color_printf, true); \ + return hpp__fmt(fmt, hpp, he, __hpp_get_##_field, " %*.2f%%", \ + __hpp__slsmg_color_printf, true); \ }#define __HPP_COLOR_ACC_PERCENT_FN (_type, _field) \
@@ -693,19 +693,20 @@ static u64 __hpp_get_acc_##_field(struct hist_entry *he) \ } \ \static int \ -hist_browser__hpp_color_##_type(struct perf_hpp_fmt *fmt __maybe_unused,\ +hist_browser__hpp_color_##_type(struct perf_hpp_fmt *fmt, \struct perf_hpp *hpp, \struct hist_entry *he) \ { \if (!symbol_conf.cumulate_callchain) { \ +int len = fmt->user_len ?: fmt->len; \int ret =scnprintf (hpp->buf, hpp->size, \ -"%*s" ,8 ,"N/A" ); \ +"%*s" , len,"N/A" ); \slsmg_printf ("%s" , hpp->buf); \ \return ret; \ } \ - return __hpp__fmt(hpp, he, __hpp_get_acc_##_field, " %*.2f%%", \ -6 , __hpp__slsmg_color_printf, true); \ + return hpp__fmt(fmt, hpp, he, __hpp_get_acc_##_field, \ +" %*.2f%%" , __hpp__slsmg_color_printf, true); \ }__HPP_COLOR_PERCENT_FN (overhead, period)
@@ -797,8 +798,11 @@ static int hist_browser__show_entry(struct hist_browser *browser,if (fmt->color) { width -= fmt->color (fmt, &hpp, entry); }else { - width -= fmt->entry (fmt, &hpp, entry); +int ret = fmt->entry (fmt, &hpp, entry); + s[ret] ='\0' ;slsmg_printf ("%s" , s); + + width -= ret; } }
@@ -1549,6 +1553,9 @@ static int perf_evsel__hists_browse(struct perf_evsel *evsel, int nr_events,memset (options,0 ,sizeof (options)); +if (symbol_conf.col_width_list_str) +perf_hpp__set_user_width (symbol_conf.col_width_list_str); +while (1 ) {const struct thread *thread =NULL ;const struct dso *dso =NULL ;
tools/perf/ui/gtk/hists.c +5 -5
@@ -41,12 +41,12 @@ static u64 he_get_##_field(struct hist_entry *he) \return he->stat._field; \ } \ \ -static int perf_gtk__hpp_color_##_type(struct perf_hpp_fmt *fmt __maybe_unused, \ +static int perf_gtk__hpp_color_##_type(struct perf_hpp_fmt *fmt, \struct perf_hpp *hpp, \struct hist_entry *he) \ { \ - return __hpp__fmt(hpp, he, he_get_##_field, " %*.2f%%", 6, \ - __percent_color_snprintf, true); \ + return hpp__fmt(fmt, hpp, he, he_get_##_field, " %*.2f%%", \ + __percent_color_snprintf, true); \ }#define __HPP_COLOR_ACC_PERCENT_FN (_type, _field) \
@@ -59,8 +59,8 @@ static int perf_gtk__hpp_color_##_type(struct perf_hpp_fmt *fmt __maybe_unused,struct perf_hpp *hpp, \ struct hist_entry *he) \ { \ - return __hpp__fmt_acc(hpp, he, he_get_acc_##_field, " %*.2f%%", 6, \ -__percent_color_snprintf ,true ); \ + return hpp__fmt_acc(fmt, hpp, he, he_get_acc_##_field, " %*.2f%%", \ +__percent_color_snprintf ,true ); \ }__HPP_COLOR_PERCENT_FN (overhead, period)
tools/perf/ui/hist.c +58 -26
141 lines not on this page · raw message
tools/perf/ui/stdio/hist.c +3 -1
@@ -395,10 +395,12 @@ size_t hists__fprintf(struct hists *hists, bool show_header, int max_rows,init_rem_hits (); -perf_hpp__for_each_format (fmt)perf_hpp__reset_width (fmt, hists); +if (symbol_conf.col_width_list_str) +perf_hpp__set_user_width (symbol_conf.col_width_list_str); +if (!show_header) goto print_entries;
tools/perf/util/hist.h +8 -6
@@ -208,6 +208,7 @@ struct perf_hpp_fmt {struct list_head sort_list;bool elide;int len; +int user_len; };extern struct list_head perf_hpp__list;
@@ -263,17 +264,18 @@ static inline bool perf_hpp__should_skip(struct perf_hpp_fmt *format)void perf_hpp__reset_width (struct perf_hpp_fmt *fmt,struct hists *hists);void perf_hpp__reset_sort_width (struct perf_hpp_fmt *fmt,struct hists *hists); +void perf_hpp__set_user_width (const char *width_list_str);typedef u64 (*hpp_field_fn )(struct hist_entry *he);typedef int (*hpp_callback_fn )(struct perf_hpp *hpp,bool front);typedef int (*hpp_snprint_fn )(struct perf_hpp *hpp,const char *fmt, ...); -int __hpp__fmt (struct perf_hpp *hpp,struct hist_entry *he, -hpp_field_fn get_field,const char *fmt,int len, -hpp_snprint_fn print_fn,bool fmt_percent); -int __hpp__fmt_acc (struct perf_hpp *hpp,struct hist_entry *he, -hpp_field_fn get_field,const char *fmt,int len, -hpp_snprint_fn print_fn,bool fmt_percent); +int hpp__fmt (struct perf_hpp_fmt *fmt,struct perf_hpp *hpp, +struct hist_entry *he,hpp_field_fn get_field, +const char *fmtstr,hpp_snprint_fn print_fn,bool fmt_percent); +int hpp__fmt_acc (struct perf_hpp_fmt *fmt,struct perf_hpp *hpp, +struct hist_entry *he,hpp_field_fn get_field, +const char *fmtstr,hpp_snprint_fn print_fn,bool fmt_percent);static inline void advance_hpp (struct perf_hpp *hpp,int inc) {
tools/perf/util/sort.c +27 -17
127 lines not on this page · raw message
Signature · 1 line
2.0.0
Re: [PATCH 4/6] perf report: Honor column width setting
Quoted 2 lines · Namhyung Kim
Set column width and do not change it if user gives -w/--column-widths option. It'll truncate longer symbols than the width if exists.
SNIP
Quoted 8 lines
static inline void
advance_hpp(struct perf_hpp *hpp, int inc){tools/perf/util/sort.c +0
-0
tools/perf/util/sort.c static int hist_entry__thread_snprintf(struct hist_entry *he, char *bf, · line 76
Quoted 8 lines
tools/perf/util/sort.c +3
-1@@ -70,7 +70,9 @@ static int hist_entry__thread_snprintf(struct hist_entry *he, char *bf, size_t size, unsigned int width) {const char *comm =thread__comm_str (he->thread); -return repsep_snprintf (bf, size,"%-*s:%5d" , width -6 , + + width =max (7U , width) -6 ; +return repsep_snprintf (bf, size,"%-*.*s:%5d" , width, width, comm ?:"" , he->thread->tid);
I couldn't found what your format string:
"%-*.*s:%5d", width, width
is supposed to do... it gives me the same result as for:
"%-*s:%5d", width
you use it on more places so I guess it's not a typo ;-)
thanks,
jirka
Namhyung Kim
maintainerRe: [PATCH 4/6] perf report: Honor column width setting
Quoted 26 lines · Jiri Olsa
Quoted 2 lines · Namhyung Kim
Set column width and do not change it if user gives -w/--column-widths option. It'll truncate longer symbols than the width if exists.
SNIP
Quoted 8 lines
static inline void
advance_hpp(struct perf_hpp *hpp, int inc){tools/perf/util/sort.c +0
-0tools/perf/util/sort.c static int hist_entry__thread_snprintf(struct hist_entry *he, char *bf, · line 76
Quoted 8 lines
tools/perf/util/sort.c +3
-1@@ -70,7 +70,9 @@ static int hist_entry__thread_snprintf(struct hist_entry *he, char *bf, size_t size, unsigned int width) {const char *comm =thread__comm_str (he->thread); -return repsep_snprintf (bf, size,"%-*s:%5d" , width -6 , + + width =max (7U , width) -6 ; +return repsep_snprintf (bf, size,"%-*.*s:%5d" , width, width, comm ?:"" , he->thread->tid);I couldn't found what your format string:
"%-*.*s:%5d", width, width
Quoted 4 lines
is supposed to do... it gives me the same result as for:
"%-*s:%5d", widthyou use it on more places so I guess it's not a typo ;-)
Yep, it's NOT a typo. The second * is necessary for limiting maximum length of printed string - without it we cannot control column alignment of long symbols.
Thanks,
Namhyung
Re: [PATCH 4/6] perf report: Honor column width setting
In reply to Namhyung KimQuoted 2 lines · Namhyung Kim
Set column width and do not change it if user gives -w/--column-widths option. It'll truncate longer symbols than the width if exists.
SNIP
tools/perf/util/sort.c static int hist_entry__thread_snprintf(struct hist_entry *he, char *bf, · line 77
Quoted 12 lines
tools/perf/util/sort.c +3
-1@@ -70,7 +70,9 @@ static int hist_entry__thread_snprintf(struct hist_entry *he, char *bf, size_t size, unsigned int width) {const char *comm =thread__comm_str (he->thread); -return repsep_snprintf (bf, size,"%-*s:%5d" , width -6 , + + width =max (7U , width) -6 ; +return repsep_snprintf (bf, size,"%-*.*s:%5d" , width, width, comm ?:"" , he->thread->tid); }
also we now print out all sort headers left alligned, which is wrong for sort_thread header: "Command: Pid' that mirrors value strings with ':' being aligned
maybe something like in attached patch..?
thanks,
jirka
---
tools/perf/util/sort.c +6 -1
@@ -78,6 +78,7 @@ static int hist_entry__thread_snprintf(struct hist_entry *he, char *bf,struct sort_entry sort_thread = { .se_header ="Command: Pid" , + .se_header_right= true, .se_cmp = sort__thread_cmp, .se_snprintf = hist_entry__thread_snprintf, .se_width_idx =HISTC_THREAD ,
@@ -1212,13 +1213,17 @@ static int __sort__hpp_header(struct perf_hpp_fmt *fmt, struct perf_hpp *hpp, {struct hpp_sort_entry *hse;size_t len = fmt->user_len; +const char *fmt_str ="%-*.*s" ; hse = container_of(fmt, struct hpp_sort_entry, hpp);if (!len) len =hists__col_len (&evsel->hists, hse->se->se_width_idx); -return scnprintf (hpp->buf, hpp->size,"%-*.*s" , len, len, hse->se->se_header); +if (hse->se->se_header_right) + fmt_str ="%*.*s" ; + +return scnprintf (hpp->buf, hpp->size, fmt_str, len, len, hse->se->se_header); } static int __sort__hpp_width(struct perf_hpp_fmt *fmt,
tools/perf/util/sort.h +1 -0
@@ -197,6 +197,7 @@ struct sort_entry {struct list_head list;const char *se_header; +bool se_header_right;int64_t (*se_cmp)(struct hist_entry *,struct hist_entry *);int64_t (*se_collapse)(struct hist_entry *,struct hist_entry *);
Arnaldo Carvalho de Melo
maintainerRe: [PATCH 4/6] perf report: Honor column width setting
Em Thu, Jul 24, 2014 at 02:57:51PM +0200, Jiri Olsa escreveu:
Quoted 35 lines · Namhyung Kim
Quoted 2 lines
Set column width and do not change it if user gives -w/--column-widths option. It'll truncate longer symbols than the width if exists.
SNIP
tools/perf/util/sort.c static int hist_entry__thread_snprintf(struct hist_entry *he, char *bf, · line 77
Quoted 12 lines
tools/perf/util/sort.c +3
-1@@ -70,7 +70,9 @@ static int hist_entry__thread_snprintf(struct hist_entry *he, char *bf, size_t size, unsigned int width) {const char *comm =thread__comm_str (he->thread); -return repsep_snprintf (bf, size,"%-*s:%5d" , width -6 , + + width =max (7U , width) -6 ; +return repsep_snprintf (bf, size,"%-*.*s:%5d" , width, width, comm ?:"" , he->thread->tid); }also we now print out all sort headers left alligned, which is wrong for
sort_threadheader: "Command: Pid' that mirrors value strings with ':' being alignedmaybe something like in attached patch..?
thanks,
jirka---
tools/perf/util/sort.c +0
-0
tools/perf/util/sort.c static int hist_entry__thread_snprintf(struct hist_entry *he, char *bf, · line 81
Quoted 4 lines
tools/perf/util/sort.c +1
-0@@ -78,6 +78,7 @@ static int hist_entry__thread_snprintf(struct hist_entry *he, char *bf,struct sort_entry sort_thread = { .se_header ="Command: Pid" , + .se_header_right= true,
Is this just for the header? Perhaps its more clearly named .se_right_justify?
Quoted 34 lines
tools/perf/util/sort.c +5
-1.se_cmp = sort__thread_cmp, .se_snprintf = hist_entry__thread_snprintf, .se_width_idx = HISTC_THREAD,@@ -1212,13 +1213,17 @@ static int __sort__hpp_header(struct perf_hpp_fmt *fmt, struct perf_hpp *hpp, {struct hpp_sort_entry *hse;size_t len = fmt->user_len; +const char *fmt_str ="%-*.*s" ; hse = container_of(fmt, struct hpp_sort_entry, hpp);if (!len) len =hists__col_len (&evsel->hists, hse->se->se_width_idx); -return scnprintf (hpp->buf, hpp->size,"%-*.*s" , len, len, hse->se->se_header); +if (hse->se->se_header_right) + fmt_str ="%*.*s" ; + +return scnprintf (hpp->buf, hpp->size, fmt_str, len, len, hse->se->se_header); } static int __sort__hpp_width(struct perf_hpp_fmt *fmt,tools/perf/util/sort.h +1
-0@@ -197,6 +197,7 @@ struct sort_entry {struct list_head list;const char *se_header; +bool se_header_right;int64_t (*se_cmp)(struct hist_entry *,struct hist_entry *);int64_t (*se_collapse)(struct hist_entry *,struct hist_entry *);
Re: [PATCH 4/6] perf report: Honor column width setting
Quoted 37 lines · Arnaldo Carvalho de Melo
Em Thu, Jul 24, 2014 at 02:57:51PM +0200, Jiri Olsa escreveu:
Quoted 36 lines · Namhyung Kim
Quoted 2 lines
Set column width and do not change it if user gives -w/--column-widths option. It'll truncate longer symbols than the width if exists.
SNIP
tools/perf/util/sort.c static int hist_entry__thread_snprintf(struct hist_entry *he, char *bf, · line 77
Quoted 12 lines
tools/perf/util/sort.c +3
-1@@ -70,7 +70,9 @@ static int hist_entry__thread_snprintf(struct hist_entry *he, char *bf, size_t size, unsigned int width) {const char *comm =thread__comm_str (he->thread); -return repsep_snprintf (bf, size,"%-*s:%5d" , width -6 , + + width =max (7U , width) -6 ; +return repsep_snprintf (bf, size,"%-*.*s:%5d" , width, width, comm ?:"" , he->thread->tid); }also we now print out all sort headers left alligned, which is wrong for
sort_threadheader: "Command: Pid' that mirrors value strings with ':' being alignedmaybe something like in attached patch..?
thanks,
jirka---
tools/perf/util/sort.c +0
-0@@ -78,6 +78,7 @@ static int hist_entry__thread_snprintf(struct hist_entry *he, char *bf,
Quoted 5 lines
tools/perf/util/sort.c static int hist_entry__thread_snprintf(struct hist_entry *he, char *bf, · line 81
Quoted 3 lines
tools/perf/util/sort.c +1
-0struct sort_entry sort_thread = { .se_header ="Command: Pid" , + .se_header_right= true,Is this just for the header? Perhaps its more clearly named .se_right_justify?
yep, it's just for header.. let's see Namhyung might have better idea how to handle this problem
jirka
Namhyung Kim
maintainerRe: [PATCH 4/6] perf report: Honor column width setting
Hi guys,
Quoted 38 lines · Jiri Olsa
Quoted 37 lines · Arnaldo Carvalho de Melo
Em Thu, Jul 24, 2014 at 02:57:51PM +0200, Jiri Olsa escreveu:
Quoted 36 lines · Namhyung Kim
Quoted 2 lines
Set column width and do not change it if user gives -w/--column-widths option. It'll truncate longer symbols than the width if exists.
SNIP
tools/perf/util/sort.c static int hist_entry__thread_snprintf(struct hist_entry *he, char *bf, · line 77
Quoted 12 lines
tools/perf/util/sort.c +3
-1@@ -70,7 +70,9 @@ static int hist_entry__thread_snprintf(struct hist_entry *he, char *bf, size_t size, unsigned int width) {const char *comm =thread__comm_str (he->thread); -return repsep_snprintf (bf, size,"%-*s:%5d" , width -6 , + + width =max (7U , width) -6 ; +return repsep_snprintf (bf, size,"%-*.*s:%5d" , width, width, comm ?:"" , he->thread->tid); }also we now print out all sort headers left alligned, which is wrong for
sort_threadheader: "Command: Pid' that mirrors value strings with ':' being alignedmaybe something like in attached patch..?
thanks,
jirka---
tools/perf/util/sort.c +0
-0@@ -78,6 +78,7 @@ static int hist_entry__thread_snprintf(struct hist_entry *he, char *bf,
Quoted 8 lines
Quoted 5 lines
tools/perf/util/sort.c static int hist_entry__thread_snprintf(struct hist_entry *he, char *bf, · line 81
Quoted 3 lines
tools/perf/util/sort.c +1
-0struct sort_entry sort_thread = { .se_header ="Command: Pid" , + .se_header_right= true,Is this just for the header? Perhaps its more clearly named .se_right_justify?
yep, it's just for header.. let's see Namhyung might have better idea how to handle this problem
I think it still needs to be left-aligned. So I'd rather change the order - i.e. "Pid: Command". Is it okay for you?
Thanks,
Namhyung
Re: [PATCH 4/6] perf report: Honor column width setting
Quoted 47 lines · Namhyung Kim
Hi guys,
Quoted 44 lines · Jiri Olsa
Quoted 42 lines · Arnaldo Carvalho de Melo
Em Thu, Jul 24, 2014 at 02:57:51PM +0200, Jiri Olsa escreveu:
Quoted 35 lines · Namhyung Kim
Quoted 2 lines
Set column width and do not change it if user gives -w/--column-widths option. It'll truncate longer symbols than the width if exists.
SNIP
tools/perf/util/sort.c static int hist_entry__thread_snprintf(struct hist_entry *he, char *bf, · line 77
Quoted 12 lines
tools/perf/util/sort.c +3
-1@@ -70,7 +70,9 @@ static int hist_entry__thread_snprintf(struct hist_entry *he, char *bf, size_t size, unsigned int width) {const char *comm =thread__comm_str (he->thread); -return repsep_snprintf (bf, size,"%-*s:%5d" , width -6 , + + width =max (7U , width) -6 ; +return repsep_snprintf (bf, size,"%-*.*s:%5d" , width, width, comm ?:"" , he->thread->tid); }also we now print out all sort headers left alligned, which is wrong for
sort_threadheader: "Command: Pid' that mirrors value strings with ':' being alignedmaybe something like in attached patch..?
thanks,
jirka---
tools/perf/util/sort.c +0
-0tools/perf/util/sort.c static int hist_entry__thread_snprintf(struct hist_entry *he, char *bf, · line 81
Quoted 4 lines
tools/perf/util/sort.c +1
-0@@ -78,6 +78,7 @@ static int hist_entry__thread_snprintf(struct hist_entry *he, char *bf,struct sort_entry sort_thread = { .se_header ="Command: Pid" , + .se_header_right= true,Is this just for the header? Perhaps its more clearly named .se_right_justify?
Quoted 5 lines
Quoted 2 lines
yep, it's just for header.. let's see Namhyung might have better idea how to handle this problem
I think it still needs to be left-aligned. So I'd rather change the order - i.e. "Pid: Command". Is it okay for you?
yes, jirka
Arnaldo Carvalho de Melo
maintainerRe: [PATCH 4/6] perf report: Honor column width setting
Em Thu, Jul 24, 2014 at 05:58:44PM +0200, Jiri Olsa escreveu:
Quoted 8 lines · Namhyung Kim
Quoted 6 lines · Jiri Olsa
Quoted 5 lines · Arnaldo Carvalho de Melo
Quoted 4 lines
Em Thu, Jul 24, 2014 at 02:57:51PM +0200, Jiri Olsa escreveu:
Quoted 3 lines
struct
sort_entrysort_thread= {
.se_header = "Command: Pid",
+ .se_header_right= true,
Quoted 6 lines
Quoted 6 lines
Quoted 4 lines
Quoted 1 line
Is this just for the header? Perhaps its more clearly named .se_right_justify?
yep, it's just for header.. let's see Namhyung might have better idea how to handle this problem
I think it still needs to be left-aligned. So I'd rather change the
Good, I like simpler fixes :)
Quoted 3 lines
Quoted 1 line
order - i.e. "Pid: Command". Is it okay for you?
yes, jirka
Yes, its is more usual to have pid+command anyway, just run 'ps' :-)
- Arnaldo
Namhyung Kim
maintainerPATCH 5/6 perf top: Add -w option for setting column width
In reply to Namhyung KimAdd -w/--column-widths option like perf report does so that users are able to see symbols even with some very long C++ library/functions. It can be a list separated by comma for each column.
$ perf top -w 0,20,30
The value of 0 means there's no limit.
--- tools/perf/Documentation/perf-report.txt | 2 +- tools/perf/Documentation/perf-top.txt | 6 ++++++ tools/perf/builtin-top.c | 3 +++ 3 files changed, 10 insertions(+), 1 deletion(-)
tools/perf/Documentation/perf-report.txt +1 -1
@@ -147,7 +147,7 @@ OPTIONS -w:: --column-widths=<width[,width...]>:: Force each column width to the provided list, for large terminal - readability. + readability. 0 means no limit (default behavior). -t:: --field-separator=::
tools/perf/Documentation/perf-top.txt +6 -0
@@ -193,6 +193,12 @@ Default is to monitor all CPUS. sum of shown entries will be always 100%. "absolute" means it retains the original value before and after the filter is applied. +-w:: +--column-widths=<width[,width...]>:: + Force each column width to the provided list, for large terminal + readability. 0 means no limit (default behavior). + + INTERACTIVE PROMPTING KEYS --------------------------
tools/perf/builtin-top.c +3 -0
@@ -1131,6 +1131,9 @@ int cmd_top(int argc, const char **argv, const char *prefix __maybe_unused) "Don't show entries under that percent", parse_percent_limit),OPT_CALLBACK (0 ,"percentage" ,NULL ,"relative|absolute" ,"How to display percentage of filtered entries" , parse_filter_percentage), +OPT_STRING ('w' ,"column-widths" , &symbol_conf.col_width_list_str, +"width[,width...]" , +"don't try to adjust column width, use these fixed values" ),OPT_END () }; const char * const top_usage[] = {
Signature · 1 line
2.0.0
Namhyung Kim
maintainerPATCH 6/6 perf tools: Add name field into perf_hpp_fmt
In reply to Namhyung KimIt makes the code a bit simpler and easier to debug IMHO.
I guess it can also remove similar code in perf diff, but let's keep it for a future work. :)
--- tools/perf/ui/gtk/hists.c | 4 +- tools/perf/ui/hist.c | 109 ++++++++++++++++++++++------------------------ tools/perf/util/hist.h | 1 + tools/perf/util/sort.c | 6 +-- 4 files changed, 57 insertions(+), 63 deletions(-)
tools/perf/ui/gtk/hists.c +1 -3
@@ -207,10 +207,8 @@ static void perf_gtk__show_hists(GtkWidget *window, struct hists *hists,if (perf_hpp__is_sort_entry (fmt)) sym_col = col_idx; - fmt->header (fmt, &hpp,hists_to_evsel (hists)); -gtk_tree_view_insert_column_with_attributes (GTK_TREE_VIEW (view), --1 ,ltrim (s), +-1 , fmt->name, renderer,"markup" , col_idx++,NULL ); }
tools/perf/ui/hist.c +52 -57
182 lines not on this page · raw message
tools/perf/util/hist.h +1 -0
@@ -192,6 +192,7 @@ struct perf_hpp { };struct perf_hpp_fmt { +const char *name;int (*header)(struct perf_hpp_fmt *fmt,struct perf_hpp *hpp,struct perf_evsel *evsel); int (*width)(struct perf_hpp_fmt *fmt, struct perf_hpp *hpp,
tools/perf/util/sort.c +3 -3
@@ -1203,8 +1203,7 @@ void perf_hpp__reset_sort_width(struct perf_hpp_fmt *fmt, struct hists *hists)return ; hse = container_of(fmt, struct hpp_sort_entry, hpp); -hists__new_col_len (hists, hse->se->se_width_idx, -strlen (hse->se->se_header)); +hists__new_col_len (hists, hse->se->se_width_idx,strlen (fmt->name)); } static int __sort__hpp_header(struct perf_hpp_fmt *fmt, struct perf_hpp *hpp,
@@ -1218,7 +1217,7 @@ static int __sort__hpp_header(struct perf_hpp_fmt *fmt, struct perf_hpp *hpp,if (!len) len =hists__col_len (&evsel->hists, hse->se->se_width_idx); -return scnprintf (hpp->buf, hpp->size,"%-*.*s" , len, len, hse->se->se_header); +return scnprintf (hpp->buf, hpp->size,"%-*.*s" , len, len, fmt->name); } static int __sort__hpp_width(struct perf_hpp_fmt *fmt,
@@ -1262,6 +1261,7 @@ __sort_dimension__alloc_hpp(struct sort_dimension *sd) } hse->se = sd->entry; + hse->hpp.name = sd->entry->se_header; hse->hpp.header = __sort__hpp_header; hse->hpp.width = __sort__hpp_width; hse->hpp.entry = __sort__hpp_entry;
Signature · 1 line
2.0.0
Quoted 13 lines · Namhyung Kim
Hello,
This patchset is to control perf report/top output column width by -w/--column-widths option so that it can fit into the terminal size. The -w option is there for perf report but it ignored by recent output field changed due to some reason. This patchset fixes it and supports perf top also.
This is sometimes useful if your terminal is small and there's some C++ applications which have amazingly long symbol names. Without this patchset user might not see those symbols on TUI, since it maps left/right arrow keys to other functions.
Quoted 6 lines
The -w option sets column width starting from the first column (overhead or optional
overhead_childrencolumn unless -F option is given). It doesn't make sense to limit those overhead columns so it's not a hard-limit for them. But it *is* a hard-limit for other columns such as comm, dso, symbol, and so on. One can use 0 not to limit/force a width for those columns.
hi,
I've got broken TUI output for "perf report --group"
Samples: 17 of event 'anon group { cycles, instructions }', Event count (approx.): 9145256
56.44% 31.59% ls libc-2.17.so [.] __strcoll_l
39.94% 0.00% ls ld-2.17.so [.] _dl_new_object
3.48% 0.00% ls [kernel.kallsyms] [k] setup_arg_pages 0.14% 0.33% ls [kernel.kallsyms] [k] native_write_msr_safe 0.00% 30.17% ls [kernel.kallsyms] [k] security_inode_permission 0.00% 29.78% ls ls [.] indent
0.00% 8.12% ls [kernel.kallsyms] [k] __slab_alloc
I have 'show-headers' set to false in ~/.perfconfig and the output got fixed after displaying headers by pressing 'H'
jirka
Namhyung Kim
maintainerHi Jiri,
Quoted 27 lines · Jiri Olsa
Quoted 13 lines · Namhyung Kim
Hello,
This patchset is to control perf report/top output column width by -w/--column-widths option so that it can fit into the terminal size. The -w option is there for perf report but it ignored by recent output field changed due to some reason. This patchset fixes it and supports perf top also.
This is sometimes useful if your terminal is small and there's some C++ applications which have amazingly long symbol names. Without this patchset user might not see those symbols on TUI, since it maps left/right arrow keys to other functions.
Quoted 6 lines
The -w option sets column width starting from the first column (overhead or optional
overhead_childrencolumn unless -F option is given). It doesn't make sense to limit those overhead columns so it's not a hard-limit for them. But it *is* a hard-limit for other columns such as comm, dso, symbol, and so on. One can use 0 not to limit/force a width for those columns.hi,
I've got broken TUI output for "perf report --group"Samples: 17 of event 'anon group { cycles, instructions }', Event count (approx.): 9145256
56.44% 31.59% ls libc-2.17.so [.]__strcoll_l
39.94% 0.00% ls ld-2.17.so [.]_dl_new_object
Quoted 8 lines
3.48% 0.00% ls [kernel.kallsyms] [k] setup_arg_pages 0.14% 0.33% ls [kernel.kallsyms] [k] native_write_msr_safe 0.00% 30.17% ls [kernel.kallsyms] [k] security_inode_permission 0.00% 29.78% ls ls [.] indent0.00% 8.12% ls [kernel.kallsyms] [k]
__slab_allocI have 'show-headers' set to false in ~/.perfconfig and the output got fixed after displaying headers by pressing 'H'
Argh, you're right. It should be fixed with this patch:
Thanks,
Namhyung
Quoted 1 line
From
a8fffc7802402d5ddd03e02956304199fa20fae9Mon Sep 17 00:00:00 2001
From: Namhyung Kim <[email protected]>
Date: Wed, 23 Jul 2014 16:20:45 +0900
Subject: [PATCH] perf tools: Fix column alignment when headers aren't shown on
TUI
If user sets ui.show-headers config option to false, it didn't calculate default column width so it broke the alignment. This is because it does the calculation just before showing headers.
Move it to the beginning of the hist browser so that it can be called regardless of the config option.
--- tools/perf/ui/browsers/hists.c | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-)
tools/perf/ui/browsers/hists.c +4 -3
@@ -853,9 +853,6 @@ static int hists__scnprintf_headers(char *buf, size_t size, struct hists *hists)if (perf_hpp__should_skip (fmt))continue ; -/* We need to ensure length of the columns header. */ -perf_hpp__reset_width (fmt, hists); - ret = fmt->header (fmt, &dummy_hpp,hists_to_evsel (hists));if (advance_hpp_check (&dummy_hpp, ret))break ;
@@ -1504,6 +1501,7 @@ static int perf_evsel__hists_browse(struct perf_evsel *evsel, int nr_events,char buf[64 ];char script_opt[64 ];int delay_secs = hbt ? hbt->refresh :0 ; +struct perf_hpp_fmt *fmt;#define HIST_BROWSER_HELP_COMMON \ "h/?/F1 Show this window\n" \
@@ -1553,6 +1551,9 @@ static int perf_evsel__hists_browse(struct perf_evsel *evsel, int nr_events,memset (options,0 ,sizeof (options)); +perf_hpp__for_each_format (fmt) +perf_hpp__reset_width (fmt, hists); +if (symbol_conf.col_width_list_str)perf_hpp__set_user_width (symbol_conf.col_width_list_str);
Signature · 1 line
2.0.0
Quoted 36 lines · Namhyung Kim
Hi Jiri,
Quoted 33 lines · Jiri Olsa
Quoted 13 lines · Namhyung Kim
Hello,
This patchset is to control perf report/top output column width by -w/--column-widths option so that it can fit into the terminal size. The -w option is there for perf report but it ignored by recent output field changed due to some reason. This patchset fixes it and supports perf top also.
This is sometimes useful if your terminal is small and there's some C++ applications which have amazingly long symbol names. Without this patchset user might not see those symbols on TUI, since it maps left/right arrow keys to other functions.
Quoted 6 lines
The -w option sets column width starting from the first column (overhead or optional
overhead_childrencolumn unless -F option is given). It doesn't make sense to limit those overhead columns so it's not a hard-limit for them. But it *is* a hard-limit for other columns such as comm, dso, symbol, and so on. One can use 0 not to limit/force a width for those columns.hi,
I've got broken TUI output for "perf report --group"Samples: 17 of event 'anon group { cycles, instructions }', Event count (approx.): 9145256
56.44% 31.59% ls libc-2.17.so [.]__strcoll_l
39.94% 0.00% ls ld-2.17.so [.]_dl_new_object3.48% 0.00% ls [kernel.kallsyms] [k] setup_arg_pages 0.14% 0.33% ls [kernel.kallsyms] [k] native_write_msr_safe 0.00% 30.17% ls [kernel.kallsyms] [k] security_inode_permission 0.00% 29.78% ls ls [.] indent0.00% 8.12% ls [kernel.kallsyms] [k]
__slab_alloc
Quoted 4 lines
Quoted 2 lines
I have 'show-headers' set to false in ~/.perfconfig and the output got fixed after displaying headers by pressing 'H'
Argh, you're right. It should be fixed with this patch:
yep, that fixed that for me
thanks,
jirka
Arnaldo Carvalho de Melo
maintainerEm Wed, Jul 09, 2014 at 02:28:08PM +0900, Namhyung Kim escreveu:
Quoted 13 lines
Hello,
This patchset is to control perf report/top output column width by -w/--column-widths option so that it can fit into the terminal size. The -w option is there for perf report but it ignored by recent output field changed due to some reason. This patchset fixes it and supports perf top also.
This is sometimes useful if your terminal is small and there's some C++ applications which have amazingly long symbol names. Without this patchset user might not see those symbols on TUI, since it maps left/right arrow keys to other functions.
Quoted 6 lines
The -w option sets column width starting from the first column (overhead or optional
overhead_childrencolumn unless -F option is given). It doesn't make sense to limit those overhead columns so it's not a hard-limit for them. But it *is* a hard-limit for other columns such as comm, dso, symbol, and so on. One can use 0 not to limit/force a width for those columns.
Due to the issues pointed out, will wait for a v2 patchset, ok?
- Arnaldo
Namhyung Kim
maintainerQuoted 14 lines · Arnaldo Carvalho de Melo
Em Wed, Jul 09, 2014 at 02:28:08PM +0900, Namhyung Kim escreveu:
Quoted 13 lines
Hello,
This patchset is to control perf report/top output column width by -w/--column-widths option so that it can fit into the terminal size. The -w option is there for perf report but it ignored by recent output field changed due to some reason. This patchset fixes it and supports perf top also.
This is sometimes useful if your terminal is small and there's some C++ applications which have amazingly long symbol names. Without this patchset user might not see those symbols on TUI, since it maps left/right arrow keys to other functions.
Quoted 8 lines
Quoted 6 lines
The -w option sets column width starting from the first column (overhead or optional
overhead_childrencolumn unless -F option is given). It doesn't make sense to limit those overhead columns so it's not a hard-limit for them. But it *is* a hard-limit for other columns such as comm, dso, symbol, and so on. One can use 0 not to limit/force a width for those columns.Due to the issues pointed out, will wait for a v2 patchset, ok?
Okay. Will send v2 tomorrow.
Thanks,
Namhyung