summaryrefslogtreecommitdiff
path: root/tools/perf/util/hist.c
diff options
context:
space:
mode:
authorNamhyung Kim <namhyung@kernel.org>2016-03-07 19:44:46 (GMT)
committerIngo Molnar <mingo@kernel.org>2016-03-08 09:11:19 (GMT)
commit1b2dbbf41a0f4cf7a5662bccb9a18128d16e5ffb (patch)
tree284079169d6939125553b2946ebd2318019029d8 /tools/perf/util/hist.c
parentc3bc0c436899d01c3a09fddb308d487cc032fbd2 (diff)
downloadlinux-1b2dbbf41a0f4cf7a5662bccb9a18128d16e5ffb.tar.xz
perf hists: Use own hpp_list for hierarchy mode
Now each hists has its own hpp lists in hierarchy. So instead of having a pointer to a single perf_hpp_fmt in a hist entry, make it point the hpp_list for its level. This will be used to support multiple sort keys in a single hierarchy level. Signed-off-by: Namhyung Kim <namhyung@kernel.org> Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com> Cc: Alexander Shishkin <alexander.shishkin@linux.intel.com> Cc: David Ahern <dsahern@gmail.com> Cc: Jiri Olsa <jolsa@kernel.org> Cc: Jiri Olsa <jolsa@redhat.com> Cc: Peter Zijlstra <peterz@infradead.org> Cc: Stephane Eranian <eranian@google.com> Cc: Thomas Gleixner <tglx@linutronix.de> Cc: Wang Nan <wangnan0@huawei.com> Link: http://lkml.kernel.org/r/1457361308-514-3-git-send-email-namhyung@kernel.org Signed-off-by: Ingo Molnar <mingo@kernel.org>
Diffstat (limited to 'tools/perf/util/hist.c')
-rw-r--r--tools/perf/util/hist.c60
1 files changed, 35 insertions, 25 deletions
diff --git a/tools/perf/util/hist.c b/tools/perf/util/hist.c
index fea92fc..29da9e0 100644
--- a/tools/perf/util/hist.c
+++ b/tools/perf/util/hist.c
@@ -1091,18 +1091,25 @@ 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 perf_hpp_list *hpp_list)
{
struct rb_node **p = &root->rb_node;
struct rb_node *parent = NULL;
struct hist_entry *iter, *new;
+ struct perf_hpp_fmt *fmt;
int64_t cmp;
while (*p != NULL) {
parent = *p;
iter = rb_entry(parent, struct hist_entry, rb_node_in);
- cmp = fmt->collapse(fmt, iter, he);
+ cmp = 0;
+ perf_hpp_list__for_each_sort_list(hpp_list, fmt) {
+ cmp = fmt->collapse(fmt, iter, he);
+ if (cmp)
+ break;
+ }
+
if (!cmp) {
he_stat__add_stat(&iter->stat, &he->stat);
return iter;
@@ -1121,24 +1128,26 @@ static struct hist_entry *hierarchy_insert_entry(struct hists *hists,
hists__apply_filters(hists, new);
hists->nr_entries++;
- /* save related format for output */
- new->fmt = fmt;
+ /* save related format list for output */
+ new->hpp_list = hpp_list;
/* some fields are now passed to 'new' */
- if (perf_hpp__is_trace_entry(fmt) || perf_hpp__is_dynamic_entry(fmt))
- he->trace_output = NULL;
- else
- new->trace_output = NULL;
+ perf_hpp_list__for_each_sort_list(hpp_list, fmt) {
+ if (perf_hpp__is_trace_entry(fmt) || perf_hpp__is_dynamic_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_srcline_entry(fmt))
+ he->srcline = NULL;
+ else
+ new->srcline = NULL;
- if (perf_hpp__is_srcfile_entry(fmt))
- he->srcfile = NULL;
- else
- new->srcfile = 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);
@@ -1149,21 +1158,19 @@ static int hists__hierarchy_insert_entry(struct hists *hists,
struct rb_root *root,
struct hist_entry *he)
{
- struct perf_hpp_fmt *fmt;
+ struct perf_hpp_list_node *node;
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))
+ list_for_each_entry(node, &hists->hpp_formats, list) {
+ /* skip period (overhead) and elided columns */
+ if (node->level == 0 || node->skip)
continue;
/* insert copy of 'he' for each fmt into the hierarchy */
- new_he = hierarchy_insert_entry(hists, root, he, fmt);
+ new_he = hierarchy_insert_entry(hists, root, he, &node->hpp);
if (new_he == NULL) {
ret = -1;
break;
@@ -1358,6 +1365,7 @@ static void hierarchy_insert_output_entry(struct rb_root *root,
struct rb_node **p = &root->rb_node;
struct rb_node *parent = NULL;
struct hist_entry *iter;
+ struct perf_hpp_fmt *fmt;
while (*p != NULL) {
parent = *p;
@@ -1373,8 +1381,10 @@ static void hierarchy_insert_output_entry(struct rb_root *root,
rb_insert_color(&he->rb_node, root);
/* update column width of dynamic entry */
- if (perf_hpp__is_dynamic_entry(he->fmt))
- he->fmt->sort(he->fmt, he, NULL);
+ perf_hpp_list__for_each_sort_list(he->hpp_list, fmt) {
+ if (perf_hpp__is_dynamic_entry(fmt))
+ fmt->sort(fmt, he, NULL);
+ }
}
static void hists__hierarchy_output_resort(struct hists *hists,