Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > linux.kernel > #1335448
| From | Namhyung Kim <namhyung@kernel.org> |
|---|---|
| Newsgroups | linux.kernel |
| Subject | [PATCH v6 09/25] perf hists: Basic support of hierarchical report view |
| Date | 2016-02-16 15:20 +0100 |
| Message-ID | <r2ODW-vy-63@gated-at.bofh.it> (permalink) |
| References | <r2ODT-vy-3@gated-at.bofh.it> |
| Organization | linux.* mail to news gateway |
In the hierarchical view, entries will be grouped and sorted on the
first key, and then second key, and so on. Add he->hroot_{in,out} field
to keep lower level entries. Actually this can be shared with callchain
sorted_root since the hroots are only used by non-leaf entries and
callchain is only used by leaf entries.
It also adds 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).
Acked-by: Pekka Enberg <penberg@kernel.org>
Signed-off-by: Namhyung Kim <namhyung@kernel.org>
---
tools/perf/util/hist.c | 97 ++++++++++++++++++++++++++++++++++++++++++++++++
tools/perf/util/sort.h | 13 ++++++-
tools/perf/util/symbol.h | 3 +-
3 files changed, 111 insertions(+), 2 deletions(-)
diff --git a/tools/perf/util/hist.c b/tools/perf/util/hist.c
index 827c6cbcd05d..6b45fe021485 100644
--- a/tools/perf/util/hist.c
+++ b/tools/perf/util/hist.c
@@ -1046,6 +1046,99 @@ 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;
+
+ /* it's now passed to 'new' */
+ he->trace_output = 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;
+
+ /* 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)
{
@@ -1054,6 +1147,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);
@@ -1084,6 +1180,7 @@ int hists__collapse_insert_entry(struct hists *hists, struct rb_root *root,
p = &(*p)->rb_right;
}
hists->nr_entries++;
+ he->leaf = true;
rb_link_node(&he->rb_node_in, parent, p);
rb_insert_color(&he->rb_node_in, root);
diff --git a/tools/perf/util/sort.h b/tools/perf/util/sort.h
index 89a1273fd2da..0cdfd0cfe783 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 ccd1caa40e11..a937053a0ae0 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,
--
2.7.1
Back to linux.kernel | Previous | Next — Previous in thread | Next in thread | Find similar | Unroll thread
[PATCHSET 00/25] perf tools: Add support for hierachy view (v6) Namhyung Kim <namhyung@kernel.org> - 2016-02-16 15:20 +0100
[PATCH v6 23/25] perf report: Add --hierarchy option Namhyung Kim <namhyung@kernel.org> - 2016-02-16 15:20 +0100
[PATCH v6 24/25] perf hists: Support decaying in hierarchy mode Namhyung Kim <namhyung@kernel.org> - 2016-02-16 15:20 +0100
[PATCH v6 14/25] perf hists: Resort after filtering hierarchy Namhyung Kim <namhyung@kernel.org> - 2016-02-16 15:20 +0100
[PATCH v6 05/25] perf callchain: Check return value of split_add_child() Namhyung Kim <namhyung@kernel.org> - 2016-02-16 15:20 +0100
[tip:perf/core] perf callchain: Check return value of split_add_child() tip-bot for Namhyung Kim <tipbot@zytor.com> - 2016-02-20 12:50 +0100
[PATCH v6 13/25] perf hists: Support filtering in hierarchy mode Namhyung Kim <namhyung@kernel.org> - 2016-02-16 15:20 +0100
[PATCH v6 04/25] perf callchain: Add enum match_result for match_chain() Namhyung Kim <namhyung@kernel.org> - 2016-02-16 15:20 +0100
[tip:perf/core] perf callchain: Add enum match_result for match_chain() tip-bot for Namhyung Kim <tipbot@zytor.com> - 2016-02-20 12:50 +0100
[PATCH v6 21/25] perf hists browser: Align column header in hierarchy mode Namhyung Kim <namhyung@kernel.org> - 2016-02-16 15:20 +0100
[PATCH v6 03/25] perf callchain: Check return value of fill_node() Namhyung Kim <namhyung@kernel.org> - 2016-02-16 15:20 +0100
[tip:perf/core] perf callchain: Check return value of fill_node() tip-bot for Namhyung Kim <tipbot@zytor.com> - 2016-02-20 12:50 +0100
[PATCH v6 02/25] perf callchain: Check return value of add_child() Namhyung Kim <namhyung@kernel.org> - 2016-02-16 15:20 +0100
[tip:perf/core] perf callchain: Check return value of add_child() tip-bot for Namhyung Kim <tipbot@zytor.com> - 2016-02-20 12:50 +0100
[PATCH v6 25/25] perf top: Add --hierarchy option Namhyung Kim <namhyung@kernel.org> - 2016-02-16 15:20 +0100
Re: [PATCH v6 25/25] perf top: Add --hierarchy option Jiri Olsa <jolsa@redhat.com> - 2016-02-21 00:20 +0100
Re: [PATCH v6 25/25] perf top: Add --hierarchy option Namhyung Kim <namhyung@kernel.org> - 2016-02-21 19:20 +0100
[PATCH v6 16/25] perf ui/stdio: Implement hierarchy output mode Namhyung Kim <namhyung@kernel.org> - 2016-02-16 15:20 +0100
Re: [PATCH v6 16/25] perf ui/stdio: Implement hierarchy output mode Jiri Olsa <jolsa@redhat.com> - 2016-02-21 00:20 +0100
Re: [PATCH v6 16/25] perf ui/stdio: Implement hierarchy output mode Namhyung Kim <namhyung@kernel.org> - 2016-02-21 19:10 +0100
[PATCH v6 09/25] perf hists: Basic support of hierarchical report view Namhyung Kim <namhyung@kernel.org> - 2016-02-16 15:20 +0100
Re: [PATCH v6 09/25] perf hists: Basic support of hierarchical report view Jiri Olsa <jolsa@redhat.com> - 2016-02-21 00:20 +0100
Re: [PATCH v6 09/25] perf hists: Basic support of hierarchical report view Namhyung Kim <namhyung@kernel.org> - 2016-02-21 21:00 +0100
[PATCH v6 20/25] perf hists browser: Implement hierarchy output Namhyung Kim <namhyung@kernel.org> - 2016-02-16 15:20 +0100
Re: [PATCH v6 20/25] perf hists browser: Implement hierarchy output Jiri Olsa <jolsa@redhat.com> - 2016-02-21 00:20 +0100
[PATCH v6 19/25] perf hists browser: Support collapsing/expanding whole entries in hierarchy Namhyung Kim <namhyung@kernel.org> - 2016-02-16 15:20 +0100
[PATCH v6 08/25] perf report: Check error during report__collapse_hists() Namhyung Kim <namhyung@kernel.org> - 2016-02-16 15:20 +0100
[tip:perf/core] perf report: Check error during report__collapse_hists() tip-bot for Namhyung Kim <tipbot@zytor.com> - 2016-02-20 12:50 +0100
csiph-web