diff options
| -rw-r--r-- | tools/perf/builtin-annotate.c | 4 | ||||
| -rw-r--r-- | tools/perf/builtin-diff.c | 10 | ||||
| -rw-r--r-- | tools/perf/builtin-report.c | 8 | ||||
| -rw-r--r-- | tools/perf/util/hist.c | 39 | ||||
| -rw-r--r-- | tools/perf/util/hist.h | 9 |
5 files changed, 38 insertions, 32 deletions
diff --git a/tools/perf/builtin-annotate.c b/tools/perf/builtin-annotate.c index 4b734c731e27..6ad7148451c5 100644 --- a/tools/perf/builtin-annotate.c +++ b/tools/perf/builtin-annotate.c | |||
| @@ -564,8 +564,8 @@ static int __cmd_annotate(void) | |||
| 564 | if (verbose > 2) | 564 | if (verbose > 2) |
| 565 | dsos__fprintf(stdout); | 565 | dsos__fprintf(stdout); |
| 566 | 566 | ||
| 567 | perf_session__collapse_resort(session); | 567 | perf_session__collapse_resort(&session->hists); |
| 568 | perf_session__output_resort(session, session->event_total[0]); | 568 | perf_session__output_resort(&session->hists, session->event_total[0]); |
| 569 | perf_session__find_annotations(session); | 569 | perf_session__find_annotations(session); |
| 570 | out_delete: | 570 | out_delete: |
| 571 | perf_session__delete(session); | 571 | perf_session__delete(session); |
diff --git a/tools/perf/builtin-diff.c b/tools/perf/builtin-diff.c index 20df7352629b..1ea15d8aeed1 100644 --- a/tools/perf/builtin-diff.c +++ b/tools/perf/builtin-diff.c | |||
| @@ -115,7 +115,7 @@ static void perf_session__resort_hist_entries(struct perf_session *self) | |||
| 115 | 115 | ||
| 116 | static void perf_session__set_hist_entries_positions(struct perf_session *self) | 116 | static void perf_session__set_hist_entries_positions(struct perf_session *self) |
| 117 | { | 117 | { |
| 118 | perf_session__output_resort(self, self->events_stats.total); | 118 | perf_session__output_resort(&self->hists, self->events_stats.total); |
| 119 | perf_session__resort_hist_entries(self); | 119 | perf_session__resort_hist_entries(self); |
| 120 | } | 120 | } |
| 121 | 121 | ||
| @@ -167,13 +167,15 @@ static int __cmd_diff(void) | |||
| 167 | goto out_delete; | 167 | goto out_delete; |
| 168 | } | 168 | } |
| 169 | 169 | ||
| 170 | perf_session__output_resort(session[1], session[1]->events_stats.total); | 170 | perf_session__output_resort(&session[1]->hists, |
| 171 | session[1]->events_stats.total); | ||
| 171 | if (show_displacement) | 172 | if (show_displacement) |
| 172 | perf_session__set_hist_entries_positions(session[0]); | 173 | perf_session__set_hist_entries_positions(session[0]); |
| 173 | 174 | ||
| 174 | perf_session__match_hists(session[0], session[1]); | 175 | perf_session__match_hists(session[0], session[1]); |
| 175 | perf_session__fprintf_hists(session[1], session[0], | 176 | perf_session__fprintf_hists(&session[1]->hists, session[0], |
| 176 | show_displacement, stdout); | 177 | show_displacement, stdout, |
| 178 | session[1]->events_stats.total); | ||
| 177 | out_delete: | 179 | out_delete: |
| 178 | for (i = 0; i < 2; ++i) | 180 | for (i = 0; i < 2; ++i) |
| 179 | perf_session__delete(session[i]); | 181 | perf_session__delete(session[i]); |
diff --git a/tools/perf/builtin-report.c b/tools/perf/builtin-report.c index cd16e6a7d6d0..294b4cf105f2 100644 --- a/tools/perf/builtin-report.c +++ b/tools/perf/builtin-report.c | |||
| @@ -225,10 +225,12 @@ static int __cmd_report(void) | |||
| 225 | if (verbose > 2) | 225 | if (verbose > 2) |
| 226 | dsos__fprintf(stdout); | 226 | dsos__fprintf(stdout); |
| 227 | 227 | ||
| 228 | perf_session__collapse_resort(session); | 228 | perf_session__collapse_resort(&session->hists); |
| 229 | perf_session__output_resort(session, session->events_stats.total); | 229 | perf_session__output_resort(&session->hists, |
| 230 | session->events_stats.total); | ||
| 230 | fprintf(stdout, "# Samples: %Ld\n#\n", session->events_stats.total); | 231 | fprintf(stdout, "# Samples: %Ld\n#\n", session->events_stats.total); |
| 231 | perf_session__fprintf_hists(session, NULL, false, stdout); | 232 | perf_session__fprintf_hists(&session->hists, NULL, false, stdout, |
| 233 | session->events_stats.total); | ||
| 232 | if (sort_order == default_sort_order && | 234 | if (sort_order == default_sort_order && |
| 233 | parent_pattern == default_parent_pattern) | 235 | parent_pattern == default_parent_pattern) |
| 234 | fprintf(stdout, "#\n# (For a higher level overview, try: perf report --sort comm,dso)\n#\n"); | 236 | fprintf(stdout, "#\n# (For a higher level overview, try: perf report --sort comm,dso)\n#\n"); |
diff --git a/tools/perf/util/hist.c b/tools/perf/util/hist.c index 55dd9115d1b4..73ebb6fb34ac 100644 --- a/tools/perf/util/hist.c +++ b/tools/perf/util/hist.c | |||
| @@ -130,7 +130,7 @@ static void collapse__insert_entry(struct rb_root *root, struct hist_entry *he) | |||
| 130 | rb_insert_color(&he->rb_node, root); | 130 | rb_insert_color(&he->rb_node, root); |
| 131 | } | 131 | } |
| 132 | 132 | ||
| 133 | void perf_session__collapse_resort(struct perf_session *self) | 133 | void perf_session__collapse_resort(struct rb_root *hists) |
| 134 | { | 134 | { |
| 135 | struct rb_root tmp; | 135 | struct rb_root tmp; |
| 136 | struct rb_node *next; | 136 | struct rb_node *next; |
| @@ -140,17 +140,17 @@ void perf_session__collapse_resort(struct perf_session *self) | |||
| 140 | return; | 140 | return; |
| 141 | 141 | ||
| 142 | tmp = RB_ROOT; | 142 | tmp = RB_ROOT; |
| 143 | next = rb_first(&self->hists); | 143 | next = rb_first(hists); |
| 144 | 144 | ||
| 145 | while (next) { | 145 | while (next) { |
| 146 | n = rb_entry(next, struct hist_entry, rb_node); | 146 | n = rb_entry(next, struct hist_entry, rb_node); |
| 147 | next = rb_next(&n->rb_node); | 147 | next = rb_next(&n->rb_node); |
| 148 | 148 | ||
| 149 | rb_erase(&n->rb_node, &self->hists); | 149 | rb_erase(&n->rb_node, hists); |
| 150 | collapse__insert_entry(&tmp, n); | 150 | collapse__insert_entry(&tmp, n); |
| 151 | } | 151 | } |
| 152 | 152 | ||
| 153 | self->hists = tmp; | 153 | *hists = tmp; |
| 154 | } | 154 | } |
| 155 | 155 | ||
| 156 | /* | 156 | /* |
| @@ -183,7 +183,7 @@ static void perf_session__insert_output_hist_entry(struct rb_root *root, | |||
| 183 | rb_insert_color(&he->rb_node, root); | 183 | rb_insert_color(&he->rb_node, root); |
| 184 | } | 184 | } |
| 185 | 185 | ||
| 186 | void perf_session__output_resort(struct perf_session *self, u64 total_samples) | 186 | void perf_session__output_resort(struct rb_root *hists, u64 total_samples) |
| 187 | { | 187 | { |
| 188 | struct rb_root tmp; | 188 | struct rb_root tmp; |
| 189 | struct rb_node *next; | 189 | struct rb_node *next; |
| @@ -194,18 +194,18 @@ void perf_session__output_resort(struct perf_session *self, u64 total_samples) | |||
| 194 | total_samples * (callchain_param.min_percent / 100); | 194 | total_samples * (callchain_param.min_percent / 100); |
| 195 | 195 | ||
| 196 | tmp = RB_ROOT; | 196 | tmp = RB_ROOT; |
| 197 | next = rb_first(&self->hists); | 197 | next = rb_first(hists); |
| 198 | 198 | ||
| 199 | while (next) { | 199 | while (next) { |
| 200 | n = rb_entry(next, struct hist_entry, rb_node); | 200 | n = rb_entry(next, struct hist_entry, rb_node); |
| 201 | next = rb_next(&n->rb_node); | 201 | next = rb_next(&n->rb_node); |
| 202 | 202 | ||
| 203 | rb_erase(&n->rb_node, &self->hists); | 203 | rb_erase(&n->rb_node, hists); |
| 204 | perf_session__insert_output_hist_entry(&tmp, n, | 204 | perf_session__insert_output_hist_entry(&tmp, n, |
| 205 | min_callchain_hits); | 205 | min_callchain_hits); |
| 206 | } | 206 | } |
| 207 | 207 | ||
| 208 | self->hists = tmp; | 208 | *hists = tmp; |
| 209 | } | 209 | } |
| 210 | 210 | ||
| 211 | static size_t callchain__fprintf_left_margin(FILE *fp, int left_margin) | 211 | 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 | } | 456 | } |
| 457 | 457 | ||
| 458 | static size_t hist_entry__fprintf(struct hist_entry *self, | 458 | static size_t hist_entry__fprintf(struct hist_entry *self, |
| 459 | struct perf_session *session, | ||
| 460 | struct perf_session *pair_session, | 459 | struct perf_session *pair_session, |
| 461 | bool show_displacement, | 460 | bool show_displacement, |
| 462 | long displacement, FILE *fp) | 461 | long displacement, FILE *fp, |
| 462 | u64 session_total) | ||
| 463 | { | 463 | { |
| 464 | struct sort_entry *se; | 464 | struct sort_entry *se; |
| 465 | u64 count, total; | 465 | u64 count, total; |
| @@ -474,7 +474,7 @@ static size_t hist_entry__fprintf(struct hist_entry *self, | |||
| 474 | total = pair_session->events_stats.total; | 474 | total = pair_session->events_stats.total; |
| 475 | } else { | 475 | } else { |
| 476 | count = self->count; | 476 | count = self->count; |
| 477 | total = session->events_stats.total; | 477 | total = session_total; |
| 478 | } | 478 | } |
| 479 | 479 | ||
| 480 | if (total) | 480 | if (total) |
| @@ -496,8 +496,8 @@ static size_t hist_entry__fprintf(struct hist_entry *self, | |||
| 496 | 496 | ||
| 497 | if (total > 0) | 497 | if (total > 0) |
| 498 | old_percent = (count * 100.0) / total; | 498 | old_percent = (count * 100.0) / total; |
| 499 | if (session->events_stats.total > 0) | 499 | if (session_total > 0) |
| 500 | new_percent = (self->count * 100.0) / session->events_stats.total; | 500 | new_percent = (self->count * 100.0) / session_total; |
| 501 | 501 | ||
| 502 | diff = new_percent - old_percent; | 502 | diff = new_percent - old_percent; |
| 503 | 503 | ||
| @@ -544,16 +54 | |||
