aboutsummaryrefslogtreecommitdiffstats
path: root/tools/perf
diff options
context:
space:
mode:
authorJiri Olsa <jolsa@kernel.org>2016-08-01 14:02:34 -0400
committerArnaldo Carvalho de Melo <acme@redhat.com>2016-08-02 15:33:28 -0400
commit52c5cc363f2c5f50e88d2d340c039cc72797d69a (patch)
treea5b301c27f2103ec31ce71cfec6ba6c236ee2621 /tools/perf
parent4842576cd857887ddfed58f452af38b9457639d7 (diff)
perf hists: Introduce output_resort_cb method
When dealing with nested hist entries it's helpful to have a way to resort those nested objects. Adding optional callback call into output_resort function and following new interface function: typedef int (*hists__resort_cb_t)(struct hist_entry *he); void hists__output_resort_cb(struct hists *hists, struct ui_progress *prog, hists__resort_cb_t cb); Signed-off-by: Jiri Olsa <jolsa@kernel.org> Cc: David Ahern <dsahern@gmail.com> Cc: Namhyung Kim <namhyung@kernel.org> Cc: Peter Zijlstra <a.p.zijlstra@chello.nl> Link: http://lkml.kernel.org/r/1470074555-24889-7-git-send-email-jolsa@kernel.org Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
Diffstat (limited to 'tools/perf')
-rw-r--r--tools/perf/util/hist.c15
-rw-r--r--tools/perf/util/hist.h4
2 files changed, 16 insertions, 3 deletions
diff --git a/tools/perf/util/hist.c b/tools/perf/util/hist.c
index a18d142cdca3..de15dbcdcecf 100644
--- a/tools/perf/util/hist.c
+++ b/tools/perf/util/hist.c
@@ -1672,7 +1672,7 @@ static void __hists__insert_output_entry(struct rb_root *entries,
1672} 1672}
1673 1673
1674static void output_resort(struct hists *hists, struct ui_progress *prog, 1674static void output_resort(struct hists *hists, struct ui_progress *prog,
1675 bool use_callchain) 1675 bool use_callchain, hists__resort_cb_t cb)
1676{ 1676{
1677 struct rb_root *root; 1677 struct rb_root *root;
1678 struct rb_node *next; 1678 struct rb_node *next;
@@ -1711,6 +1711,9 @@ static void output_resort(struct hists *hists, struct ui_progress *prog,
1711 n = rb_entry(next, struct hist_entry, rb_node_in); 1711 n = rb_entry(next, struct hist_entry, rb_node_in);
1712 next = rb_next(&n->rb_node_in); 1712 next = rb_next(&n->rb_node_in);
1713 1713
1714 if (cb && cb(n))
1715 continue;
1716
1714 __hists__insert_output_entry(&hists->entries, n, min_callchain_hits, use_callchain); 1717 __hists__insert_output_entry(&hists->entries, n, min_callchain_hits, use_callchain);
1715 hists__inc_stats(hists, n); 1718 hists__inc_stats(hists, n);
1716 1719
@@ -1731,12 +1734,18 @@ void perf_evsel__output_resort(struct perf_evsel *evsel, struct ui_progress *pro
1731 else 1734 else
1732 use_callchain = symbol_conf.use_callchain; 1735 use_callchain = symbol_conf.use_callchain;
1733 1736
1734 output_resort(evsel__hists(evsel), prog, use_callchain); 1737 output_resort(evsel__hists(evsel), prog, use_callchain, NULL);
1735} 1738}
1736 1739
1737void hists__output_resort(struct hists *hists, struct ui_progress *prog) 1740void hists__output_resort(struct hists *hists, struct ui_progress *prog)
1738{ 1741{
1739 output_resort(hists, prog, symbol_conf.use_callchain); 1742 output_resort(hists, prog, symbol_conf.use_callchain, NULL);
1743}
1744
1745void hists__output_resort_cb(struct hists *hists, struct ui_progress *prog,
1746 hists__resort_cb_t cb)
1747{
1748 output_resort(hists, prog, symbol_conf.use_callchain, cb);
1740} 1749}
1741 1750
1742static bool can_goto_child(struct hist_entry *he, enum hierarchy_move_dir hmd) 1751static bool can_goto_child(struct hist_entry *he, enum hierarchy_move_dir hmd)
diff --git a/tools/perf/util/hist.h b/tools/perf/util/hist.h
index 49aa4fac148f..0a1edf1ab450 100644
--- a/tools/perf/util/hist.h
+++ b/tools/perf/util/hist.h
@@ -153,8 +153,12 @@ int hist_entry__snprintf_alignment(struct hist_entry *he, struct perf_hpp *hpp,
153 struct perf_hpp_fmt *fmt, int printed); 153 struct perf_hpp_fmt *fmt, int printed);
154void hist_entry__delete(struct hist_entry *he); 154void hist_entry__delete(struct hist_entry *he);
155 155
156typedef int (*hists__resort_cb_t)(struct hist_entry *he);
157
156void perf_evsel__output_resort(struct perf_evsel *evsel, struct ui_progress *prog); 158void perf_evsel__output_resort(struct perf_evsel *evsel, struct ui_progress *prog);
157void hists__output_resort(struct hists *hists, struct ui_progress *prog); 159void hists__output_resort(struct hists *hists, struct ui_progress *prog);
160void hists__output_resort_cb(struct hists *hists, struct ui_progress *prog,
161 hists__resort_cb_t cb);
158int hists__collapse_resort(struct hists *hists, struct ui_progress *prog); 162int hists__collapse_resort(struct hists *hists, struct ui_progress *prog);
159 163
160void hists__decay_entries(struct hists *hists, bool zap_user, bool zap_kernel); 164void hists__decay_entries(struct hists *hists, bool zap_user, bool zap_kernel);