Commit eefc465c authored by Eric B Munson's avatar Eric B Munson Committed by Ingo Molnar

perf session: Change perf_session post processing functions to take histogram tree

Now that report can store historgrams for multiple events we
need to be able to do the post processing work for each
histogram. This patch changes the post processing functions so
that they can be called individually for each event's histogram.
Signed-off-by: default avatarEric B Munson <ebmunson@us.ibm.com>
[ Guarantee bisectabilty by fixing up builtin-report.c ]
Signed-off-by: default avatarArnaldo Carvalho de Melo <acme@redhat.com>
Cc: Peter Zijlstra <a.p.zijlstra@chello.nl>
Cc: Paul Mackerras <paulus@samba.org>
LKML-Reference: <1267804269-22660-5-git-send-email-acme@infradead.org>
Signed-off-by: default avatarIngo Molnar <mingo@elte.hu>
parent cb8f0939
...@@ -564,8 +564,8 @@ static int __cmd_annotate(void) ...@@ -564,8 +564,8 @@ static int __cmd_annotate(void)
if (verbose > 2) if (verbose > 2)
dsos__fprintf(stdout); dsos__fprintf(stdout);
perf_session__collapse_resort(session); perf_session__collapse_resort(&session->hists);
perf_session__output_resort(session, session->event_total[0]); perf_session__output_resort(&session->hists, session->event_total[0]);
perf_session__find_annotations(session); perf_session__find_annotations(session);
out_delete: out_delete:
perf_session__delete(session); perf_session__delete(session);
......
...@@ -115,7 +115,7 @@ static void perf_session__resort_hist_entries(struct perf_session *self) ...@@ -115,7 +115,7 @@ static void perf_session__resort_hist_entries(struct perf_session *self)
static void perf_session__set_hist_entries_positions(struct perf_session *self) static void perf_session__set_hist_entries_positions(struct perf_session *self)
{ {
perf_session__output_resort(self, self->events_stats.total); perf_session__output_resort(&self->hists, self->events_stats.total);
perf_session__resort_hist_entries(self); perf_session__resort_hist_entries(self);
} }
...@@ -167,13 +167,15 @@ static int __cmd_diff(void) ...@@ -167,13 +167,15 @@ static int __cmd_diff(void)
goto out_delete; goto out_delete;
} }
perf_session__output_resort(session[1], session[1]->events_stats.total); perf_session__output_resort(&session[1]->hists,
session[1]->events_stats.total);
if (show_displacement) if (show_displacement)
perf_session__set_hist_entries_positions(session[0]); perf_session__set_hist_entries_positions(session[0]);
perf_session__match_hists(session[0], session[1]); perf_session__match_hists(session[0], session[1]);
perf_session__fprintf_hists(session[1], session[0], perf_session__fprintf_hists(&session[1]->hists, session[0],
show_displacement, stdout); show_displacement, stdout,
session[1]->events_stats.total);
out_delete: out_delete:
for (i = 0; i < 2; ++i) for (i = 0; i < 2; ++i)
perf_session__delete(session[i]); perf_session__delete(session[i]);
......
...@@ -225,10 +225,12 @@ static int __cmd_report(void) ...@@ -225,10 +225,12 @@ static int __cmd_report(void)
if (verbose > 2) if (verbose > 2)
dsos__fprintf(stdout); dsos__fprintf(stdout);
perf_session__collapse_resort(session); perf_session__collapse_resort(&session->hists);
perf_session__output_resort(session, session->events_stats.total); perf_session__output_resort(&session->hists,
session->events_stats.total);
fprintf(stdout, "# Samples: %Ld\n#\n", session->events_stats.total); fprintf(stdout, "# Samples: %Ld\n#\n", session->events_stats.total);
perf_session__fprintf_hists(session, NULL, false, stdout); perf_session__fprintf_hists(&session->hists, NULL, false, stdout,
session->events_stats.total);
if (sort_order == default_sort_order && if (sort_order == default_sort_order &&
parent_pattern == default_parent_pattern) parent_pattern == default_parent_pattern)
fprintf(stdout, "#\n# (For a higher level overview, try: perf report --sort comm,dso)\n#\n"); fprintf(stdout, "#\n# (For a higher level overview, try: perf report --sort comm,dso)\n#\n");
......
...@@ -130,7 +130,7 @@ static void collapse__insert_entry(struct rb_root *root, struct hist_entry *he) ...@@ -130,7 +130,7 @@ static void collapse__insert_entry(struct rb_root *root, struct hist_entry *he)
rb_insert_color(&he->rb_node, root); rb_insert_color(&he->rb_node, root);
} }
void perf_session__collapse_resort(struct perf_session *self) void perf_session__collapse_resort(struct rb_root *hists)
{ {
struct rb_root tmp; struct rb_root tmp;
struct rb_node *next; struct rb_node *next;
...@@ -140,17 +140,17 @@ void perf_session__collapse_resort(struct perf_session *self) ...@@ -140,17 +140,17 @@ void perf_session__collapse_resort(struct perf_session *self)
return; return;
tmp = RB_ROOT; tmp = RB_ROOT;
next = rb_first(&self->hists); next = rb_first(hists);
while (next) { while (next) {
n = rb_entry(next, struct hist_entry, rb_node); n = rb_entry(next, struct hist_entry, rb_node);
next = rb_next(&n->rb_node); next = rb_next(&n->rb_node);
rb_erase(&n->rb_node, &self->hists); rb_erase(&n->rb_node, hists);
collapse__insert_entry(&tmp, n); collapse__insert_entry(&tmp, n);
} }
self->hists = tmp; *hists = tmp;
} }
/* /*
...@@ -183,7 +183,7 @@ static void perf_session__insert_output_hist_entry(struct rb_root *root, ...@@ -183,7 +183,7 @@ static void perf_session__insert_output_hist_entry(struct rb_root *root,
rb_insert_color(&he->rb_node, root); rb_insert_color(&he->rb_node, root);
} }
void perf_session__output_resort(struct perf_session *self, u64 total_samples) void perf_session__output_resort(struct rb_root *hists, u64 total_samples)
{ {
struct rb_root tmp; struct rb_root tmp;
struct rb_node *next; struct rb_node *next;
...@@ -194,18 +194,18 @@ void perf_session__output_resort(struct perf_session *self, u64 total_samples) ...@@ -194,18 +194,18 @@ void perf_session__output_resort(struct perf_session *self, u64 total_samples)
total_samples * (callchain_param.min_percent / 100); total_samples * (callchain_param.min_percent / 100);
tmp = RB_ROOT; tmp = RB_ROOT;
next = rb_first(&self->hists); next = rb_first(hists);
while (next) { while (next) {
n = rb_entry(next, struct hist_entry, rb_node); n = rb_entry(next, struct hist_entry, rb_node);
next = rb_next(&n->rb_node); next = rb_next(&n->rb_node);
rb_erase(&n->rb_node, &self->hists); rb_erase(&n->rb_node, hists);
perf_session__insert_output_hist_entry(&tmp, n, perf_session__insert_output_hist_entry(&tmp, n,
min_callchain_hits); min_callchain_hits);
} }
self->hists = tmp; *hists = tmp;
} }
static size_t callchain__fprintf_left_margin(FILE *fp, int left_margin) static size_t callchain__fprintf_left_margin(FILE *fp, int left_margin)
...@@ -456,10 +456,10 @@ static size_t hist_entry_callchain__fprintf(FILE *fp, struct hist_entry *self, ...@@ -456,10 +456,10 @@ static size_t hist_entry_callchain__fprintf(FILE *fp, struct hist_entry *self,
} }
static size_t hist_entry__fprintf(struct hist_entry *self, static size_t hist_entry__fprintf(struct hist_entry *self,
struct perf_session *session,
struct perf_session *pair_session, struct perf_session *pair_session,
bool show_displacement, bool show_displacement,
long displacement, FILE *fp) long displacement, FILE *fp,
u64 session_total)
{ {
struct sort_entry *se; struct sort_entry *se;
u64 count, total; u64 count, total;
...@@ -474,7 +474,7 @@ static size_t hist_entry__fprintf(struct hist_entry *self, ...@@ -474,7 +474,7 @@ static size_t hist_entry__fprintf(struct hist_entry *self,
total = pair_session->events_stats.total; total = pair_session->events_stats.total;
} else { } else {
count = self->count; count = self->count;
total = session->events_stats.total; total = session_total;
} }
if (total) if (total)
...@@ -496,8 +496,8 @@ static size_t hist_entry__fprintf(struct hist_entry *self, ...@@ -496,8 +496,8 @@ static size_t hist_entry__fprintf(struct hist_entry *self,
if (total > 0) if (total > 0)
old_percent = (count * 100.0) / total; old_percent = (count * 100.0) / total;
if (session->events_stats.total > 0) if (session_total > 0)
new_percent = (self->count * 100.0) / session->events_stats.total; new_percent = (self->count * 100.0) / session_total;
diff = new_percent - old_percent; diff = new_percent - old_percent;
...@@ -544,16 +544,17 @@ static size_t hist_entry__fprintf(struct hist_entry *self, ...@@ -544,16 +544,17 @@ static size_t hist_entry__fprintf(struct hist_entry *self,
left_margin -= thread__comm_len(self->thread); left_margin -= thread__comm_len(self->thread);
} }
hist_entry_callchain__fprintf(fp, self, session->events_stats.total, hist_entry_callchain__fprintf(fp, self, session_total,
left_margin); left_margin);
} }
return ret; return ret;
} }
size_t perf_session__fprintf_hists(struct perf_session *self, size_t perf_session__fprintf_hists(struct rb_root *hists,
struct perf_session *pair, struct perf_session *pair,
bool show_displacement, FILE *fp) bool show_displacement, FILE *fp,
u64 session_total)
{ {
struct sort_entry *se; struct sort_entry *se;
struct rb_node *nd; struct rb_node *nd;
...@@ -641,7 +642,7 @@ size_t perf_session__fprintf_hists(struct perf_session *self, ...@@ -641,7 +642,7 @@ size_t perf_session__fprintf_hists(struct perf_session *self,
fprintf(fp, "\n#\n"); fprintf(fp, "\n#\n");
print_entries: print_entries:
for (nd = rb_first(&self->hists); nd; nd = rb_next(nd)) { for (nd = rb_first(hists); nd; nd = rb_next(nd)) {
struct hist_entry *h = rb_entry(nd, struct hist_entry, rb_node); struct hist_entry *h = rb_entry(nd, struct hist_entry, rb_node);
if (show_displacement) { if (show_displacement) {
...@@ -652,8 +653,8 @@ print_entries: ...@@ -652,8 +653,8 @@ print_entries:
displacement = 0; displacement = 0;
++position; ++position;
} }
ret += hist_entry__fprintf(h, self, pair, show_displacement, ret += hist_entry__fprintf(h, pair, show_displacement,
displacement, fp); displacement, fp, session_total);
} }
free(rem_sq_bracket); free(rem_sq_bracket);
......
...@@ -20,9 +20,10 @@ extern int64_t hist_entry__cmp(struct hist_entry *, struct hist_entry *); ...@@ -20,9 +20,10 @@ extern int64_t hist_entry__cmp(struct hist_entry *, struct hist_entry *);
extern int64_t hist_entry__collapse(struct hist_entry *, struct hist_entry *); extern int64_t hist_entry__collapse(struct hist_entry *, struct hist_entry *);
void hist_entry__free(struct hist_entry *); void hist_entry__free(struct hist_entry *);
void perf_session__output_resort(struct perf_session *self, u64 total_samples); void perf_session__output_resort(struct rb_root *hists, u64 total_samples);
void perf_session__collapse_resort(struct perf_session *self); void perf_session__collapse_resort(struct rb_root *hists);
size_t perf_session__fprintf_hists(struct perf_session *self, size_t perf_session__fprintf_hists(struct rb_root *hists,
struct perf_session *pair, struct perf_session *pair,
bool show_displacement, FILE *fp); bool show_displacement, FILE *fp,
u64 session_total);
#endif /* __PERF_HIST_H */ #endif /* __PERF_HIST_H */
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment