From: tip-bot for Namhyung Kim <tipbot@zytor.com>
To: linux-tip-commits@vger.kernel.org
Cc: eranian@google.com, namhyung@kernel.org, peterz@infradead.org,
dsahern@gmail.com, andi@firstfloor.org, acme@redhat.com,
mingo@kernel.org, linux-kernel@vger.kernel.org,
wangnan0@huawei.com, jolsa@kernel.org, hpa@zytor.com,
tglx@linutronix.de, penberg@kernel.org
Subject: [tip:perf/core] perf hists: Basic support of hierarchical report view
Date: Wed, 24 Feb 2016 23:41:06 -0800 [thread overview]
Message-ID: <tip-aef810ec4e6b638facb6c81803c019906f34f014@git.kernel.org> (raw)
In-Reply-To: <1456326830-30456-3-git-send-email-namhyung@kernel.org>
Commit-ID: aef810ec4e6b638facb6c81803c019906f34f014
Gitweb: http://git.kernel.org/tip/aef810ec4e6b638facb6c81803c019906f34f014
Author: Namhyung Kim <namhyung@kernel.org>
AuthorDate: Thu, 25 Feb 2016 00:13:34 +0900
Committer: Arnaldo Carvalho de Melo <acme@redhat.com>
CommitDate: Wed, 24 Feb 2016 13:35:44 -0300
perf hists: Basic support of hierarchical report view
In the hierarchical view, entries will be grouped and sorted on the
first key, and then on the second key, and so on. Add the
he->hroot_{in,out} fields to keep the lower level entries. Actually this
can share space, in a union, with callchain's 'sorted_root' since the
hroots are only used by non-leaf entries and callchain is only used by
leaf entries.
It also adds the 'parent_he' and 'depth' fields which can be used by browsers.
This patch only implements collapsing part which creates internal
entries for each sort key. These need to be sorted by output_sort stage
and to be displayed properly in the later patch(es).
Signed-off-by: Namhyung Kim <namhyung@kernel.org>
Acked-by: Pekka Enberg <penberg@kernel.org>
Cc: Andi Kleen <andi@firstfloor.org>
Cc: David Ahern <dsahern@gmail.com>
Cc: Jiri Olsa <jolsa@kernel.org>
Cc: Peter Zijlstra <peterz@infradead.org>
Cc: Stephane Eranian <eranian@google.com>
Cc: Wang Nan <wangnan0@huawei.com>
Link: http://lkml.kernel.org/r/1456326830-30456-3-git-send-email-namhyung@kernel.org
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
---
tools/perf/util/hist.c | 114 +++++++++++++++++++++++++++++++++++++++++++++++
tools/perf/util/sort.h | 13 +++++-
tools/perf/util/symbol.h | 3 +-
3 files changed, 128 insertions(+), 2 deletions(-)
diff --git a/tools/perf/util/hist.c b/tools/perf/util/hist.c
index 017eb5c..8814524 100644
--- a/tools/perf/util/hist.c
+++ b/tools/perf/util/hist.c
@@ -396,6 +396,9 @@ static struct hist_entry *hist_entry__new(struct hist_entry *template,
}
INIT_LIST_HEAD(&he->pairs.node);
thread__get(he->thread);
+
+ if (!symbol_conf.report_hierarchy)
+ he->leaf = true;
}
return he;
@@ -1049,6 +1052,114 @@ int hist_entry__snprintf_alignment(struct hist_entry *he, struct perf_hpp *hpp,
* collapse the histogram
*/
+static void hists__apply_filters(struct hists *hists, struct hist_entry *he);
+
+static struct hist_entry *hierarchy_insert_entry(struct hists *hists,
+ struct rb_root *root,
+ struct hist_entry *he,
+ struct perf_hpp_fmt *fmt)
+{
+ struct rb_node **p = &root->rb_node;
+ struct rb_node *parent = NULL;
+ struct hist_entry *iter, *new;
+ int64_t cmp;
+
+ while (*p != NULL) {
+ parent = *p;
+ iter = rb_entry(parent, struct hist_entry, rb_node_in);
+
+ cmp = fmt->collapse(fmt, iter, he);
+ if (!cmp) {
+ he_stat__add_stat(&iter->stat, &he->stat);
+ return iter;
+ }
+
+ if (cmp < 0)
+ p = &parent->rb_left;
+ else
+ p = &parent->rb_right;
+ }
+
+ new = hist_entry__new(he, true);
+ if (new == NULL)
+ return NULL;
+
+ hists__apply_filters(hists, new);
+ hists->nr_entries++;
+
+ /* save related format for output */
+ new->fmt = fmt;
+
+ /* some fields are now passed to 'new' */
+ if (perf_hpp__is_trace_entry(fmt))
+ he->trace_output = NULL;
+ else
+ new->trace_output = NULL;
+
+ if (perf_hpp__is_srcline_entry(fmt))
+ he->srcline = NULL;
+ else
+ new->srcline = NULL;
+
+ if (perf_hpp__is_srcfile_entry(fmt))
+ he->srcfile = NULL;
+ else
+ new->srcfile = NULL;
+
+ rb_link_node(&new->rb_node_in, parent, p);
+ rb_insert_color(&new->rb_node_in, root);
+ return new;
+}
+
+static int hists__hierarchy_insert_entry(struct hists *hists,
+ struct rb_root *root,
+ struct hist_entry *he)
+{
+ struct perf_hpp_fmt *fmt;
+ struct hist_entry *new_he = NULL;
+ struct hist_entry *parent = NULL;
+ int depth = 0;
+ int ret = 0;
+
+ hists__for_each_sort_list(hists, fmt) {
+ if (!perf_hpp__is_sort_entry(fmt) &&
+ !perf_hpp__is_dynamic_entry(fmt))
+ continue;
+ if (perf_hpp__should_skip(fmt, hists))
+ continue;
+
+ /* insert copy of 'he' for each fmt into the hierarchy */
+ new_he = hierarchy_insert_entry(hists, root, he, fmt);
+ if (new_he == NULL) {
+ ret = -1;
+ break;
+ }
+
+ root = &new_he->hroot_in;
+ new_he->parent_he = parent;
+ new_he->depth = depth++;
+ parent = new_he;
+ }
+
+ if (new_he) {
+ new_he->leaf = true;
+
+ if (symbol_conf.use_callchain) {
+ callchain_cursor_reset(&callchain_cursor);
+ if (callchain_merge(&callchain_cursor,
+ new_he->callchain,
+ he->callchain) < 0)
+ ret = -1;
+ }
+ }
+
+ /* 'he' is no longer used */
+ hist_entry__delete(he);
+
+ /* return 0 (or -1) since it already applied filters */
+ return ret;
+}
+
int hists__collapse_insert_entry(struct hists *hists, struct rb_root *root,
struct hist_entry *he)
{
@@ -1057,6 +1168,9 @@ int hists__collapse_insert_entry(struct hists *hists, struct rb_root *root,
struct hist_entry *iter;
int64_t cmp;
+ if (symbol_conf.report_hierarchy)
+ return hists__hierarchy_insert_entry(hists, root, he);
+
while (*p != NULL) {
parent = *p;
iter = rb_entry(parent, struct hist_entry, rb_node_in);
diff --git a/tools/perf/util/sort.h b/tools/perf/util/sort.h
index 5b9c624..10315e0 100644
--- a/tools/perf/util/sort.h
+++ b/tools/perf/util/sort.h
@@ -96,9 +96,11 @@ struct hist_entry {
s32 socket;
s32 cpu;
u8 cpumode;
+ u8 depth;
/* We are added by hists__add_dummy_entry. */
bool dummy;
+ bool leaf;
char level;
u8 filtered;
@@ -120,13 +122,22 @@ struct hist_entry {
char *srcline;
char *srcfile;
struct symbol *parent;
- struct rb_root sorted_chain;
struct branch_info *branch_info;
struct hists *hists;
struct mem_info *mem_info;
void *raw_data;
u32 raw_size;
void *trace_output;
+ struct perf_hpp_fmt *fmt;
+ struct hist_entry *parent_he;
+ union {
+ /* this is for hierarchical entry structure */
+ struct {
+ struct rb_root hroot_in;
+ struct rb_root hroot_out;
+ }; /* non-leaf entries */
+ struct rb_root sorted_chain; /* leaf entry has callchains */
+ };
struct callchain_root callchain[0]; /* must be last member */
};
diff --git a/tools/perf/util/symbol.h b/tools/perf/util/symbol.h
index ccd1caa..a937053 100644
--- a/tools/perf/util/symbol.h
+++ b/tools/perf/util/symbol.h
@@ -110,7 +110,8 @@ struct symbol_conf {
has_filter,
show_ref_callgraph,
hide_unresolved,
- raw_trace;
+ raw_trace,
+ report_hierarchy;
const char *vmlinux_name,
*kallsyms_name,
*source_prefix,
next prev parent reply other threads:[~2016-02-25 7:42 UTC|newest]
Thread overview: 44+ messages / expand[flat|nested] mbox.gz Atom feed top
2016-02-24 15:13 [PATCHSET 00/18] perf tools: Add support for hierachy view (v7) Namhyung Kim
2016-02-24 15:13 ` [PATCH v7 01/18] perf tools: Add helper functions for some sort keys Namhyung Kim
2016-02-25 7:40 ` [tip:perf/core] " tip-bot for Namhyung Kim
2016-02-24 15:13 ` [PATCH v7 02/18] perf hists: Basic support of hierarchical report view Namhyung Kim
2016-02-25 7:41 ` tip-bot for Namhyung Kim [this message]
2016-02-24 15:13 ` [PATCH v7 03/18] perf hists: Resort hist entries with hierarchy Namhyung Kim
2016-02-25 7:41 ` [tip:perf/core] " tip-bot for Namhyung Kim
2016-02-24 15:13 ` [PATCH v7 04/18] perf hists: Add helper functions for hierarchy mode Namhyung Kim
2016-02-25 7:41 ` [tip:perf/core] " tip-bot for Namhyung Kim
2016-02-24 15:13 ` [PATCH v7 05/18] perf hists: Introduce hist_entry__filter() Namhyung Kim
2016-02-24 23:22 ` Arnaldo Carvalho de Melo
2016-02-25 2:02 ` Namhyung Kim
2016-02-25 7:42 ` [tip:perf/core] " tip-bot for Namhyung Kim
2016-02-24 15:13 ` [PATCH v7 06/18] perf hists: Support filtering in hierarchy mode Namhyung Kim
2016-02-25 7:42 ` [tip:perf/core] " tip-bot for Namhyung Kim
2016-02-24 15:13 ` [PATCH v7 07/18] perf hists: Resort after filtering hierarchy Namhyung Kim
2016-02-25 7:42 ` [tip:perf/core] " tip-bot for Namhyung Kim
2016-02-24 15:13 ` [PATCH v7 08/18] perf hists: Count number of sort keys Namhyung Kim
2016-02-25 7:43 ` [tip:perf/core] " tip-bot for Namhyung Kim
2016-02-24 15:13 ` [PATCH v7 09/18] perf ui/stdio: Implement hierarchy output mode Namhyung Kim
2016-02-25 7:43 ` [tip:perf/core] " tip-bot for Namhyung Kim
2016-02-24 15:13 ` [PATCH v7 10/18] perf ui/stdio: Align column header for hierarchy output Namhyung Kim
2016-02-25 7:43 ` [tip:perf/core] " tip-bot for Namhyung Kim
2016-02-24 15:13 ` [PATCH v7 11/18] perf hists browser: Count number of hierarchy entries Namhyung Kim
2016-02-25 7:44 ` [tip:perf/core] " tip-bot for Namhyung Kim
2016-02-24 15:13 ` [PATCH v7 12/18] perf hists browser: Support collapsing/expanding whole entries in hierarchy Namhyung Kim
2016-02-25 7:44 ` [tip:perf/core] " tip-bot for Namhyung Kim
2016-02-24 15:13 ` [PATCH v7 13/18] perf hists browser: Implement hierarchy output Namhyung Kim
2016-02-25 7:44 ` [tip:perf/core] " tip-bot for Namhyung Kim
2016-02-24 15:13 ` [PATCH v7 14/18] perf hists browser: Align column header in hierarchy mode Namhyung Kim
2016-02-25 7:45 ` [tip:perf/core] " tip-bot for Namhyung Kim
2016-02-24 15:13 ` [PATCH v7 15/18] perf ui/gtk: Implement hierarchy output mode Namhyung Kim
2016-02-25 7:45 ` [tip:perf/core] " tip-bot for Namhyung Kim
2016-02-24 15:13 ` [PATCH v7 16/18] perf report: Add --hierarchy option Namhyung Kim
2016-02-25 7:45 ` [tip:perf/core] " tip-bot for Namhyung Kim
2016-02-24 15:13 ` [PATCH v7 17/18] perf hists: Support decaying in hierarchy mode Namhyung Kim
2016-02-25 7:46 ` [tip:perf/core] " tip-bot for Namhyung Kim
2016-02-24 15:13 ` [PATCH v7 18/18] perf top: Add --hierarchy option Namhyung Kim
2016-02-25 7:46 ` [tip:perf/core] " tip-bot for Namhyung Kim
2016-02-24 20:06 ` [PATCHSET 00/18] perf tools: Add support for hierachy view (v7) Arnaldo Carvalho de Melo
2016-02-24 23:29 ` Arnaldo Carvalho de Melo
2016-02-25 2:14 ` Namhyung Kim
2016-02-25 1:22 ` Arnaldo Carvalho de Melo
2016-02-25 2:27 ` 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-aef810ec4e6b638facb6c81803c019906f34f014@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=penberg@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