Skip to content

Commit 52c5cc3

Browse files
olsajiriacmel
authored andcommitted
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>
1 parent 4842576 commit 52c5cc3

File tree

2 files changed

+16
-3
lines changed

2 files changed

+16
-3
lines changed

tools/perf/util/hist.c

Lines changed: 12 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1672,7 +1672,7 @@ static void __hists__insert_output_entry(struct rb_root *entries,
16721672
}
16731673

16741674
static void output_resort(struct hists *hists, struct ui_progress *prog,
1675-
bool use_callchain)
1675+
bool use_callchain, hists__resort_cb_t cb)
16761676
{
16771677
struct rb_root *root;
16781678
struct rb_node *next;
@@ -1711,6 +1711,9 @@ static void output_resort(struct hists *hists, struct ui_progress *prog,
17111711
n = rb_entry(next, struct hist_entry, rb_node_in);
17121712
next = rb_next(&n->rb_node_in);
17131713

1714+
if (cb && cb(n))
1715+
continue;
1716+
17141717
__hists__insert_output_entry(&hists->entries, n, min_callchain_hits, use_callchain);
17151718
hists__inc_stats(hists, n);
17161719

@@ -1731,12 +1734,18 @@ void perf_evsel__output_resort(struct perf_evsel *evsel, struct ui_progress *pro
17311734
else
17321735
use_callchain = symbol_conf.use_callchain;
17331736

1734-
output_resort(evsel__hists(evsel), prog, use_callchain);
1737+
output_resort(evsel__hists(evsel), prog, use_callchain, NULL);
17351738
}
17361739

17371740
void hists__output_resort(struct hists *hists, struct ui_progress *prog)
17381741
{
1739-
output_resort(hists, prog, symbol_conf.use_callchain);
1742+
output_resort(hists, prog, symbol_conf.use_callchain, NULL);
1743+
}
1744+
1745+
void 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);
17401749
}
17411750

17421751
static bool can_goto_child(struct hist_entry *he, enum hierarchy_move_dir hmd)

tools/perf/util/hist.h

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -153,8 +153,12 @@ int hist_entry__snprintf_alignment(struct hist_entry *he, struct perf_hpp *hpp,
153153
struct perf_hpp_fmt *fmt, int printed);
154154
void hist_entry__delete(struct hist_entry *he);
155155

156+
typedef int (*hists__resort_cb_t)(struct hist_entry *he);
157+
156158
void perf_evsel__output_resort(struct perf_evsel *evsel, struct ui_progress *prog);
157159
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);
158162
int hists__collapse_resort(struct hists *hists, struct ui_progress *prog);
159163

160164
void hists__decay_entries(struct hists *hists, bool zap_user, bool zap_kernel);

0 commit comments

Comments
 (0)