perf hists: Update the column width for the "srcline" sort key

This change “perf hists: Update the column width for the “srcline” sort key” in Linux kernel is authored by Arnaldo Carvalho de Melo <acme [at]> on Mon Aug 10 16:53:54 2015 -0300.

perf hists: Update the column width for the "srcline" sort key

When we introduce a new sort key, we need to update the
hists__calc_col_len() function accordingly, otherwise the width
will be limited to strlen(header).

We can't update it when obtaining a line value for a column (for
instance, in sort__srcline_cmp()), because we reset it all when doing a
resort (see hists__output_recalc_col_len()), so we need to, from what is
in the hist_entry fields, set each of the column widths.

Cc: Namhyung Kim <>
Cc: Andi Kleen <>
Cc: Jiri Olsa <>
Fixes: 409a8be61560 ("perf tools: Add sort by src line/number")
Signed-off-by: Arnaldo Carvalho de Melo <>

This Linux change may have been applied to various maintained Linux releases and you can find Linux releases including commit e8e6d37.

There are 3 lines of Linux source code added/deleted in this change. Code changes to Linux kernel are as follows.

 tools/perf/util/hist.c | 3 +++
 1 file changed, 3 insertions(+)

diff --git a/tools/perf/util/hist.c b/tools/perf/util/hist.c
index 2fe6ea3..608c0a7 100644
--- a/tools/perf/util/hist.c
+++ b/tools/perf/util/hist.c
@@ -151,6 +151,9 @@ void hists__calc_col_len(struct hists *hists, struct hist_entry *h)
 	hists__new_col_len(hists, HISTC_LOCAL_WEIGHT, 12);
 	hists__new_col_len(hists, HISTC_GLOBAL_WEIGHT, 12);
+	if (h->srcline)
+		hists__new_col_len(hists, HISTC_SRCLINE, strlen(h->srcline));
 	if (h->transaction)
 		hists__new_col_len(hists, HISTC_TRANSACTION,

The commit for this change in Linux stable tree is e8e6d37 (patch).

Leave a Reply

Your email address will not be published. Required fields are marked *