Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

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>

authored by

Jiri Olsa and committed by
Arnaldo Carvalho de Melo
52c5cc36 4842576c

+16 -3
+12 -3
tools/perf/util/hist.c
··· 1672 1672 } 1673 1673 1674 1674 static 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 1677 struct rb_root *root; 1678 1678 struct rb_node *next; ··· 1711 1711 n = rb_entry(next, struct hist_entry, rb_node_in); 1712 1712 next = rb_next(&n->rb_node_in); 1713 1713 1714 + if (cb && cb(n)) 1715 + continue; 1716 + 1714 1717 __hists__insert_output_entry(&hists->entries, n, min_callchain_hits, use_callchain); 1715 1718 hists__inc_stats(hists, n); 1716 1719 ··· 1734 1731 else 1735 1732 use_callchain = symbol_conf.use_callchain; 1736 1733 1737 - output_resort(evsel__hists(evsel), prog, use_callchain); 1734 + output_resort(evsel__hists(evsel), prog, use_callchain, NULL); 1738 1735 } 1739 1736 1740 1737 void hists__output_resort(struct hists *hists, struct ui_progress *prog) 1741 1738 { 1742 - output_resort(hists, prog, symbol_conf.use_callchain); 1739 + output_resort(hists, prog, symbol_conf.use_callchain, NULL); 1740 + } 1741 + 1742 + void hists__output_resort_cb(struct hists *hists, struct ui_progress *prog, 1743 + hists__resort_cb_t cb) 1744 + { 1745 + output_resort(hists, prog, symbol_conf.use_callchain, cb); 1743 1746 } 1744 1747 1745 1748 static bool can_goto_child(struct hist_entry *he, enum hierarchy_move_dir hmd)
+4
tools/perf/util/hist.h
··· 153 153 struct perf_hpp_fmt *fmt, int printed); 154 154 void hist_entry__delete(struct hist_entry *he); 155 155 156 + typedef int (*hists__resort_cb_t)(struct hist_entry *he); 157 + 156 158 void perf_evsel__output_resort(struct perf_evsel *evsel, struct ui_progress *prog); 157 159 void hists__output_resort(struct hists *hists, struct ui_progress *prog); 160 + void hists__output_resort_cb(struct hists *hists, struct ui_progress *prog, 161 + hists__resort_cb_t cb); 158 162 int hists__collapse_resort(struct hists *hists, struct ui_progress *prog); 159 163 160 164 void hists__decay_entries(struct hists *hists, bool zap_user, bool zap_kernel);