]> git.karo-electronics.de Git - linux-beck.git/commitdiff
perf hists: Add more helper functions for the hierarchy mode
authorNamhyung Kim <namhyung@kernel.org>
Fri, 26 Feb 2016 12:13:16 +0000 (21:13 +0900)
committerArnaldo Carvalho de Melo <acme@redhat.com>
Fri, 26 Feb 2016 14:20:35 +0000 (11:20 -0300)
The hists__overhead_width() is to calculate width occupied by the
overhead (and others) columns before the sort columns.

The hist_entry__has_hiearchy_children() is to check whether an entry has
lower entries (children) in the hierarchy to be shown in the output.
This means the children should not be filtered out and above the percent
limit.

These two functions will be used to show information when all children
of an entry is omitted by the percent limit (or filter).

Signed-off-by: Namhyung Kim <namhyung@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/1456488800-28124-1-git-send-email-namhyung@kernel.org
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
tools/perf/ui/hist.c
tools/perf/util/hist.c
tools/perf/util/hist.h

index edbf854e8e1c22898b02d7fbe6f2a20a44b7f66c..7c0585c146e1377fe19f5d278f487cce8e84aad6 100644 (file)
@@ -643,6 +643,28 @@ unsigned int hists__sort_list_width(struct hists *hists)
        return ret;
 }
 
+unsigned int hists__overhead_width(struct hists *hists)
+{
+       struct perf_hpp_fmt *fmt;
+       int ret = 0;
+       bool first = true;
+       struct perf_hpp dummy_hpp;
+
+       hists__for_each_format(hists, fmt) {
+               if (perf_hpp__is_sort_entry(fmt) || perf_hpp__is_dynamic_entry(fmt))
+                       break;
+
+               if (first)
+                       first = false;
+               else
+                       ret += 2;
+
+               ret += fmt->width(fmt, &dummy_hpp, hists_to_evsel(hists));
+       }
+
+       return ret;
+}
+
 void perf_hpp__reset_width(struct perf_hpp_fmt *fmt, struct hists *hists)
 {
        if (perf_hpp__is_sort_entry(fmt))
index 1c530428e087b577f064dcf0ca9b819385403602..e71691977a951f1d2ce7582ffecd5cf10b2ea239 100644 (file)
@@ -1582,6 +1582,31 @@ struct rb_node *rb_hierarchy_prev(struct rb_node *node)
        return &he->rb_node;
 }
 
+bool hist_entry__has_hierarchy_children(struct hist_entry *he, float limit)
+{
+       struct rb_node *node;
+       struct hist_entry *child;
+       float percent;
+
+       if (he->leaf)
+               return false;
+
+       node = rb_first(&he->hroot_out);
+       child = rb_entry(node, struct hist_entry, rb_node);
+
+       while (node && child->filtered) {
+               node = rb_next(node);
+               child = rb_entry(node, struct hist_entry, rb_node);
+       }
+
+       if (node)
+               percent = hist_entry__get_percent_limit(child);
+       else
+               percent = 0;
+
+       return node && percent >= limit;
+}
+
 static void hists__remove_entry_filter(struct hists *hists, struct hist_entry *h,
                                       enum hist_filter filter)
 {
index 722aa447f705504ceabdcc02e9d69153c61ff1db..da3e7b6e4615f0170b9f14ddc97efaa60c0799c1 100644 (file)
@@ -410,6 +410,7 @@ static inline int script_browse(const char *script_opt __maybe_unused)
 #endif
 
 unsigned int hists__sort_list_width(struct hists *hists);
+unsigned int hists__overhead_width(struct hists *hists);
 
 void hist__account_cycles(struct branch_stack *bs, struct addr_location *al,
                          struct perf_sample *sample, bool nonany_branch_mode);
@@ -439,4 +440,6 @@ static inline struct rb_node *rb_hierarchy_next(struct rb_node *node)
 
 #define HIERARCHY_INDENT  3
 
+bool hist_entry__has_hierarchy_children(struct hist_entry *he, float limit);
+
 #endif /* __PERF_HIST_H */