From: tip-bot for Namhyung Kim <tipbot@zytor.com>
To: linux-tip-commits@vger.kernel.org
Cc: namhyung@kernel.org, andi@firstfloor.org,
linux-kernel@vger.kernel.org, dsahern@gmail.com,
eranian@google.com, peterz@infradead.org, mingo@kernel.org,
tglx@linutronix.de, jolsa@kernel.org, hpa@zytor.com,
wangnan0@huawei.com, acme@redhat.com
Subject: [tip:perf/core] perf report: Fix indentation of dynamic entries in hierarchy
Date: Sat, 27 Feb 2016 01:43:21 -0800 [thread overview]
Message-ID: <tip-d3a72fd8187b7fa0014394c9dec95ba349b3301e@git.kernel.org> (raw)
In-Reply-To: <1456512767-1164-2-git-send-email-namhyung@kernel.org>
Commit-ID: d3a72fd8187b7fa0014394c9dec95ba349b3301e
Gitweb: http://git.kernel.org/tip/d3a72fd8187b7fa0014394c9dec95ba349b3301e
Author: Namhyung Kim <namhyung@kernel.org>
AuthorDate: Sat, 27 Feb 2016 03:52:44 +0900
Committer: Arnaldo Carvalho de Melo <acme@redhat.com>
CommitDate: Fri, 26 Feb 2016 18:36:11 -0300
perf report: Fix indentation of dynamic entries in hierarchy
When dynamic entries are used in the hierarchy mode with multiple
events, the output might not be aligned properly. In the hierarchy
mode, the each sort column is indented using total number of sort keys.
So it keeps track of number of sort keys when adding them. However
a dynamic sort key can be added more than once when multiple events have
same field names. This results in unnecessarily long indentation in the
output.
For example perf kmem records following events:
$ perf evlist --trace-fields -i perf.data.kmem
kmem:kmalloc: trace_fields: call_site,ptr,bytes_req,bytes_alloc,gfp_flags
kmem:kmalloc_node: trace_fields: call_site,ptr,bytes_req,bytes_alloc,gfp_flags,node
kmem:kfree: trace_fields: call_site,ptr
kmem:kmem_cache_alloc: trace_fields: call_site,ptr,bytes_req,bytes_alloc,gfp_flags
kmem:kmem_cache_alloc_node: trace_fields: call_site,ptr,bytes_req,bytes_alloc,gfp_flags,node
kmem:kmem_cache_free: trace_fields: call_site,ptr
kmem:mm_page_alloc: trace_fields: page,order,gfp_flags,migratetype
kmem:mm_page_free: trace_fields: page,order
As you can see, many field names shared between kmem events. So adding
'ptr' dynamic sort key alone will set nr_sort_keys to 6. And this adds
many unnecessary spaces between columns.
Before:
$ perf report -i perf.data.kmem --hierarchy -s ptr -g none --stdio
...
# Overhead ptr
# ....................... ...................................
#
99.89% 0xffff8803ffb79720
0.06% 0xffff8803d228a000
0.03% 0xffff8803f7678f00
0.00% 0xffff880401dc5280
0.00% 0xffff880406172380
0.00% 0xffff8803ffac3a00
0.00% 0xffff8803ffac1600
After:
# Overhead ptr
# ........ ....................
#
99.89% 0xffff8803ffb79720
0.06% 0xffff8803d228a000
0.03% 0xffff8803f7678f00
0.00% 0xffff880401dc5280
0.00% 0xffff880406172380
0.00% 0xffff8803ffac3a00
0.00% 0xffff8803ffac1600
Signed-off-by: Namhyung Kim <namhyung@kernel.org>
Tested-by: Arnaldo Carvalho de Melo <acme@redhat.com>
Acked-by: Jiri Olsa <jolsa@kernel.org>
Cc: Andi Kleen <andi@firstfloor.org>
Cc: David Ahern <dsahern@gmail.com>
Cc: Peter Zijlstra <peterz@infradead.org>
Cc: Stephane Eranian <eranian@google.com>
Cc: Wang Nan <wangnan0@huawei.com>
Link: http://lkml.kernel.org/r/1456512767-1164-2-git-send-email-namhyung@kernel.org
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
---
tools/perf/ui/browsers/hists.c | 6 +++---
tools/perf/ui/stdio/hist.c | 6 +++---
tools/perf/util/hist.h | 1 +
tools/perf/util/sort.c | 19 +++++++++++++++++++
4 files changed, 26 insertions(+), 6 deletions(-)
diff --git a/tools/perf/ui/browsers/hists.c b/tools/perf/ui/browsers/hists.c
index 71c6d51..5f74c67 100644
--- a/tools/perf/ui/browsers/hists.c
+++ b/tools/perf/ui/browsers/hists.c
@@ -1547,7 +1547,7 @@ static int hists_browser__scnprintf_hierarchy_headers(struct hist_browser *brows
struct perf_hpp_fmt *fmt;
size_t ret = 0;
int column = 0;
- int nr_sort_keys = hists->hpp_list->nr_sort_keys;
+ int nr_sort_keys = hists->nr_sort_keys;
bool first = true;
ret = scnprintf(buf, size, " ");
@@ -1632,7 +1632,7 @@ static unsigned int hist_browser__refresh(struct ui_browser *browser)
u16 header_offset = 0;
struct rb_node *nd;
struct hist_browser *hb = container_of(browser, struct hist_browser, b);
- int nr_sort = hb->hists->hpp_list->nr_sort_keys;
+ int nr_sort = hb->hists->nr_sort_keys;
if (hb->show_headers) {
hist_browser__show_headers(hb);
@@ -1969,7 +1969,7 @@ static int hist_browser__fprintf(struct hist_browser *browser, FILE *fp)
struct rb_node *nd = hists__filter_entries(rb_first(browser->b.entries),
browser->min_pcnt);
int printed = 0;
- int nr_sort = browser->hists->hpp_list->nr_sort_keys;
+ int nr_sort = browser->hists->nr_sort_keys;
while (nd) {
struct hist_entry *h = rb_entry(nd, struct hist_entry, rb_node);
diff --git a/tools/perf/ui/stdio/hist.c b/tools/perf/ui/stdio/hist.c
index b3bdfcb..5733d6c 100644
--- a/tools/perf/ui/stdio/hist.c
+++ b/tools/perf/ui/stdio/hist.c
@@ -495,7 +495,7 @@ static int hist_entry__fprintf(struct hist_entry *he, size_t size,
size = hpp.size = bfsz;
if (symbol_conf.report_hierarchy) {
- int nr_sort = hists->hpp_list->nr_sort_keys;
+ int nr_sort = hists->nr_sort_keys;
return hist_entry__hierarchy_fprintf(he, &hpp, nr_sort,
hists, fp);
@@ -529,7 +529,7 @@ static int print_hierarchy_header(struct hists *hists, struct perf_hpp *hpp,
unsigned header_width = 0;
struct perf_hpp_fmt *fmt;
- nr_sort = hists->hpp_list->nr_sort_keys;
+ nr_sort = hists->nr_sort_keys;
/* preserve max indent depth for column headers */
print_hierarchy_indent(sep, nr_sort, spaces, fp);
@@ -728,7 +728,7 @@ print_entries:
* display "no entry >= x.xx%" message.
*/
if (!h->leaf && !hist_entry__has_hierarchy_children(h, min_pcnt)) {
- int nr_sort = hists->hpp_list->nr_sort_keys;
+ int nr_sort = hists->nr_sort_keys;
print_hierarchy_indent(sep, nr_sort + h->depth + 1, spaces, fp);
fprintf(fp, "%*sno entry >= %.2f%%\n", indent, "", min_pcnt);
diff --git a/tools/perf/util/hist.h b/tools/perf/util/hist.h
index da3e7b6..da5e505 100644
--- a/tools/perf/util/hist.h
+++ b/tools/perf/util/hist.h
@@ -78,6 +78,7 @@ struct hists {
u16 col_len[HISTC_NR_COLS];
int socket_filter;
struct perf_hpp_list *hpp_list;
+ int nr_sort_keys;
};
struct hist_entry_iter;
diff --git a/tools/perf/util/sort.c b/tools/perf/util/sort.c
index 6bee8bd..2beb7a6 100644
--- a/tools/perf/util/sort.c
+++ b/tools/perf/util/sort.c
@@ -2633,6 +2633,9 @@ out:
int setup_sorting(struct perf_evlist *evlist)
{
int err;
+ struct hists *hists;
+ struct perf_evsel *evsel;
+ struct perf_hpp_fmt *fmt;
err = __setup_sorting(evlist);
if (err < 0)
@@ -2644,6 +2647,22 @@ int setup_sorting(struct perf_evlist *evlist)
return err;
}
+ evlist__for_each(evlist, evsel) {
+ hists = evsel__hists(evsel);
+ hists->nr_sort_keys = perf_hpp_list.nr_sort_keys;
+
+ /*
+ * If dynamic entries were used, it might add multiple
+ * entries to each evsel for a single field name. Set
+ * actual number of sort keys for each hists.
+ */
+ perf_hpp_list__for_each_sort_list(&perf_hpp_list, fmt) {
+ if (perf_hpp__is_dynamic_entry(fmt) &&
+ !perf_hpp__defined_dynamic_entry(fmt, hists))
+ hists->nr_sort_keys--;
+ }
+ }
+
reset_dimensions();
/*
next prev parent reply other threads:[~2016-02-27 9:44 UTC|newest]
Thread overview: 26+ messages / expand[flat|nested] mbox.gz Atom feed top
2016-02-26 18:52 [PATCH 1/5] perf report: Fix comparing of dynamic entries Namhyung Kim
2016-02-26 18:52 ` [PATCH 2/5] perf report: Fix indentation of dynamic entries in hierarchy Namhyung Kim
2016-02-27 9:43 ` tip-bot for Namhyung Kim [this message]
2016-02-26 18:52 ` [PATCH 3/5] perf report: Left align " Namhyung Kim
2016-02-27 9:43 ` [tip:perf/core] " tip-bot for Namhyung Kim
2016-02-26 18:52 ` [PATCH 4/5] perf report: Fix dynamic entry display " Namhyung Kim
2016-02-26 21:43 ` Arnaldo Carvalho de Melo
2016-02-26 21:45 ` Arnaldo Carvalho de Melo
2016-02-26 22:08 ` Arnaldo Carvalho de Melo
2016-02-26 22:24 ` Arnaldo Carvalho de Melo
2016-02-26 22:26 ` Steven Rostedt
2016-02-26 22:37 ` Arnaldo Carvalho de Melo
2016-02-26 23:12 ` Jiri Olsa
2016-02-26 23:13 ` Jiri Olsa
2016-02-26 23:13 ` [PATCH] tools lib traceevent: Add '~' operation within arg_num_eval() Steven Rostedt
2016-02-26 23:39 ` Arnaldo Carvalho de Melo
2016-02-26 23:45 ` David Ahern
2016-03-10 16:16 ` David Ahern
2016-03-10 19:28 ` Arnaldo Carvalho de Melo
2016-03-11 8:47 ` [tip:perf/core] " tip-bot for Steven Rostedt
2016-02-27 9:44 ` [tip:perf/core] perf hists: Fix dynamic entry display in hierarchy tip-bot for Namhyung Kim
2016-02-26 18:52 ` [PATCH 5/5] perf report: Update column width of dynamic entries Namhyung Kim
2016-02-26 22:43 ` Arnaldo Carvalho de Melo
2016-02-27 9:44 ` [tip:perf/core] " tip-bot for Namhyung Kim
2016-02-26 21:23 ` [PATCH 1/5] perf report: Fix comparing " Jiri Olsa
2016-02-27 9:43 ` [tip:perf/core] perf hists: " tip-bot for Namhyung Kim
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=tip-d3a72fd8187b7fa0014394c9dec95ba349b3301e@git.kernel.org \
--to=tipbot@zytor.com \
--cc=acme@redhat.com \
--cc=andi@firstfloor.org \
--cc=dsahern@gmail.com \
--cc=eranian@google.com \
--cc=hpa@zytor.com \
--cc=jolsa@kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-tip-commits@vger.kernel.org \
--cc=mingo@kernel.org \
--cc=namhyung@kernel.org \
--cc=peterz@infradead.org \
--cc=tglx@linutronix.de \
--cc=wangnan0@huawei.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox