diff options
| -rw-r--r-- | tools/perf/builtin-diff.c | 49 | ||||
| -rw-r--r-- | tools/perf/builtin-report.c | 2 | ||||
| -rw-r--r-- | tools/perf/builtin-top.c | 2 | ||||
| -rw-r--r-- | tools/perf/ui/hist.c | 8 | ||||
| -rw-r--r-- | tools/perf/ui/stdio/hist.c | 17 | ||||
| -rw-r--r-- | tools/perf/util/hist.h | 4 | ||||
| -rw-r--r-- | tools/perf/util/sort.h | 2 |
7 files changed, 44 insertions, 40 deletions
diff --git a/tools/perf/builtin-diff.c b/tools/perf/builtin-diff.c index 761f4197a9e2..5cb577a3c5b2 100644 --- a/tools/perf/builtin-diff.c +++ b/tools/perf/builtin-diff.c | |||
| @@ -70,8 +70,8 @@ static struct perf_tool tool = { | |||
| 70 | .ordering_requires_timestamps = true, | 70 | .ordering_requires_timestamps = true, |
| 71 | }; | 71 | }; |
| 72 | 72 | ||
| 73 | static void perf_session__insert_hist_entry_by_name(struct rb_root *root, | 73 | static void insert_hist_entry_by_name(struct rb_root *root, |
| 74 | struct hist_entry *he) | 74 | struct hist_entry *he) |
| 75 | { | 75 | { |
| 76 | struct rb_node **p = &root->rb_node; | 76 | struct rb_node **p = &root->rb_node; |
| 77 | struct rb_node *parent = NULL; | 77 | struct rb_node *parent = NULL; |
| @@ -90,7 +90,7 @@ static void perf_session__insert_hist_entry_by_name(struct rb_root *root, | |||
| 90 | rb_insert_color(&he->rb_node, root); | 90 | rb_insert_color(&he->rb_node, root); |
| 91 | } | 91 | } |
| 92 | 92 | ||
| 93 | static void hists__resort_entries(struct hists *self) | 93 | static void hists__name_resort(struct hists *self, bool sort) |
| 94 | { | 94 | { |
| 95 | unsigned long position = 1; | 95 | unsigned long position = 1; |
| 96 | struct rb_root tmp = RB_ROOT; | 96 | struct rb_root tmp = RB_ROOT; |
| @@ -100,12 +100,16 @@ static void hists__resort_entries(struct hists *self) | |||
| 100 | struct hist_entry *n = rb_entry(next, struct hist_entry, rb_node); | 100 | struct hist_entry *n = rb_entry(next, struct hist_entry, rb_node); |
| 101 | 101 | ||
| 102 | next = rb_next(&n->rb_node); | 102 | next = rb_next(&n->rb_node); |
| 103 | rb_erase(&n->rb_node, &self->entries); | ||
| 104 | n->position = position++; | 103 | n->position = position++; |
| 105 | perf_session__insert_hist_entry_by_name(&tmp, n); | 104 | |
| 105 | if (sort) { | ||
| 106 | rb_erase(&n->rb_node, &self->entries); | ||
| 107 | insert_hist_entry_by_name(&tmp, n); | ||
| 108 | } | ||
| 106 | } | 109 | } |
| 107 | 110 | ||
| 108 | self->entries = tmp; | 111 | if (sort) |
| 112 | self->entries = tmp; | ||
| 109 | } | 113 | } |
| 110 | 114 | ||
| 111 | static struct hist_entry *hists__find_entry(struct hists *self, | 115 | static struct hist_entry *hists__find_entry(struct hists *self, |
| @@ -121,7 +125,7 @@ static struct hist_entry *hists__find_entry(struct hists *self, | |||
| 121 | n = n->rb_left; | 125 | n = n->rb_left; |
| 122 | else if (cmp > 0) | 126 | else if (cmp > 0) |
| 123 | n = n->rb_right; | 127 | n = n->rb_right; |
| 124 | else | 128 | else |
| 125 | return iter; | 129 | return iter; |
| 126 | } | 130 | } |
| 127 | 131 | ||
| @@ -150,6 +154,24 @@ static struct perf_evsel *evsel_match(struct perf_evsel *evsel, | |||
| 150 | return NULL; | 154 | return NULL; |
| 151 | } | 155 | } |
| 152 | 156 | ||
| 157 | static void perf_evlist__resort_hists(struct perf_evlist *evlist, bool name) | ||
| 158 | { | ||
| 159 | struct perf_evsel *evsel; | ||
| 160 | |||
| 161 | list_for_each_entry(evsel, &evlist->entries, node) { | ||
| 162 | struct hists *hists = &evsel->hists; | ||
| 163 | |||
| 164 | hists__output_resort(hists); | ||
| 165 | |||
| 166 | /* | ||
| 167 | * The hists__name_resort only sets possition | ||
| 168 | * if name is false. | ||
| 169 | */ | ||
| 170 | if (name || ((!name) && show_displacement)) | ||
| 171 | hists__name_resort(hists, name); | ||
| 172 | } | ||
| 173 | } | ||
| 174 | |||
| 153 | static int __cmd_diff(void) | 175 | static int __cmd_diff(void) |
| 154 | { | 176 | { |
| 155 | int ret, i; | 177 | int ret, i; |
| @@ -176,15 +198,8 @@ static int __cmd_diff(void) | |||
| 176 | evlist_old = older->evlist; | 198 | evlist_old = older->evlist; |
| 177 | evlist_new = newer->evlist; | 199 | evlist_new = newer->evlist; |
| 178 | 200 | ||
| 179 | list_for_each_entry(evsel, &evlist_new->entries, node) | 201 | perf_evlist__resort_hists(evlist_old, true); |
| 180 | hists__output_resort(&evsel->hists); | 202 | perf_evlist__resort_hists(evlist_new, false); |
| 181 | |||
| 182 | list_for_each_entry(evsel, &evlist_old->entries, node) { | ||
| 183 | hists__output_resort(&evsel->hists); | ||
| 184 | |||
| 185 | if (show_displacement) | ||
| 186 | hists__resort_entries(&evsel->hists); | ||
| 187 | } | ||
| 188 | 203 | ||
| 189 | list_for_each_entry(evsel, &evlist_new->entries, node) { | 204 | list_for_each_entry(evsel, &evlist_new->entries, node) { |
| 190 | struct perf_evsel *evsel_old; | 205 | struct perf_evsel *evsel_old; |
| @@ -200,7 +215,7 @@ static int __cmd_diff(void) | |||
| 200 | 215 | ||
| 201 | hists__match(&evsel_old->hists, &evsel->hists); | 216 | hists__match(&evsel_old->hists, &evsel->hists); |
| 202 | hists__fprintf(&evsel->hists, &evsel_old->hists, | 217 | hists__fprintf(&evsel->hists, &evsel_old->hists, |
| 203 | show_displacement, true, 0, 0, stdout); | 218 | true, 0, 0, stdout); |
| 204 | } | 219 | } |
| 205 | 220 | ||
| 206 | out_delete: | 221 | out_delete: |
diff --git a/tools/perf/builtin-report.c b/tools/perf/builtin-report.c index 1da243dfbc3e..6748cac919d1 100644 --- a/tools/perf/builtin-report.c +++ b/tools/perf/builtin-report.c | |||
| @@ -320,7 +320,7 @@ static int perf_evlist__tty_browse_hists(struct perf_evlist *evlist, | |||
| 320 | const char *evname = perf_evsel__name(pos); | 320 | const char *evname = perf_evsel__name(pos); |
| 321 | 321 | ||
| 322 | hists__fprintf_nr_sample_events(hists, evname, stdout); | 322 | hists__fprintf_nr_sample_events(hists, evname, stdout); |
| 323 | hists__fprintf(hists, NULL, false, true, 0, 0, stdout); | 323 | hists__fprintf(hists, NULL, true, 0, 0, stdout); |
| 324 | fprintf(stdout, "\n\n"); | 324 | fprintf(stdout, "\n\n"); |
| 325 | } | 325 | } |
| 326 | 326 | ||
diff --git a/tools/perf/builtin-top.c b/tools/perf/builtin-top.c index f0c1c4f4692d..357115874b77 100644 --- a/tools/perf/builtin-top.c +++ b/tools/perf/builtin-top.c | |||
| @@ -316,7 +316,7 @@ static void perf_top__print_sym_table(struct perf_top *top) | |||
| 316 | hists__output_recalc_col_len(&top->sym_evsel->hists, | 316 | hists__output_recalc_col_len(&top->sym_evsel->hists, |
| 317 | top->winsize.ws_row - 3); | 317 | top->winsize.ws_row - 3); |
| 318 | putchar('\n'); | 318 | putchar('\n'); |
| 319 | hists__fprintf(&top->sym_evsel->hists, NULL, false, false, | 319 | hists__fprintf(&top->sym_evsel->hists, NULL, false, |
| 320 | top->winsize.ws_row - 4 - printed, win_width, stdout); | 320 | top->winsize.ws_row - 4 - printed, win_width, stdout); |
| 321 | } | 321 | } |
| 322 | 322 | ||
diff --git a/tools/perf/ui/hist.c b/tools/perf/ui/hist.c index e3f8cd46e7d7..55b9ca8f084c 100644 --- a/tools/perf/ui/hist.c +++ b/tools/perf/ui/hist.c | |||
| @@ -244,13 +244,15 @@ static int hpp__width_displ(struct perf_hpp *hpp __maybe_unused) | |||
| 244 | } | 244 | } |
| 245 | 245 | ||
| 246 | static int hpp__entry_displ(struct perf_hpp *hpp, | 246 | static int hpp__entry_displ(struct perf_hpp *hpp, |
| 247 | struct hist_entry *he __maybe_unused) | 247 | struct hist_entry *he) |
| 248 | { | 248 | { |
| 249 | struct hist_entry *pair = he->pair; | ||
| 250 | long displacement = pair ? pair->position - he->position : 0; | ||
| 249 | const char *fmt = symbol_conf.field_sep ? "%s" : "%6.6s"; | 251 | const char *fmt = symbol_conf.field_sep ? "%s" : "%6.6s"; |
| 250 | char buf[32] = " "; | 252 | char buf[32] = " "; |
| 251 | 253 | ||
| 252 | if (hpp->displacement) | 254 | if (displacement) |
| 253 | scnprintf(buf, sizeof(buf), "%+4ld", hpp->displacement); | 255 | scnprintf(buf, sizeof(buf), "%+4ld", displacement); |
| 254 | 256 | ||
| 255 | return scnprintf(hpp->buf, hpp->size, fmt, buf); | 257 | return scnprintf(hpp->buf, hpp->size, fmt, buf); |
| 256 | } | 258 | } |
diff --git a/tools/perf/ui/stdio/hist.c b/tools/perf/ui/stdio/hist.c index 882461a42830..d7405f064e88 100644 --- a/tools/perf/ui/stdio/hist.c +++ b/tools/perf/ui/stdio/hist.c | |||
| @@ -308,7 +308,7 @@ static size_t hist_entry__callchain_fprintf(struct hist_entry *he, | |||
| 308 | 308 | ||
| 309 | static int hist_entry__fprintf(struct hist_entry *he, size_t size, | 309 | static int hist_entry__fprintf(struct hist_entry *he, size_t size, |
| 310 | struct hists *hists, struct hists *pair_hists, | 310 | struct hists *hists, struct hists *pair_hists, |
| 311 | long displacement, u64 total_period, FILE *fp) | 311 | u64 total_period, FILE *fp) |
| 312 | { | 312 | { |
| 313 | char bf[512]; | 313 | char bf[512]; |
| 314 | int ret; | 314 | int ret; |
| @@ -316,7 +316,6 @@ static int hist_entry__fprintf(struct hist_entry *he, size_t size, | |||
| 316 | .buf = bf, | 316 | .buf = bf, |
| 317 | .size = size, | 317 | .size = size, |
| 318 | .total_period = total_period, | 318 | .total_period = total_period, |
| 319 | .displacement = displacement, | ||
| 320 | .ptr = pair_hists, | 319 | .ptr = pair_hists, |
| 321 | }; | 320 | }; |
| 322 | bool color = !symbol_conf.field_sep; | 321 | bool color = !symbol_conf.field_sep; |
| @@ -337,15 +336,13 @@ static int hist_entry__fprintf(struct hist_entry *he, size_t size, | |||
| 337 | } | 336 | } |
| 338 | 337 | ||
| 339 | size_t hists__fprintf(struct hists *hists, struct hists *pair, | 338 | size_t hists__fprintf(struct hists *hists, struct hists *pair, |
| 340 | bool show_displacement, bool show_header, int max_rows, | 339 | bool show_header, int max_rows, |
| 341 | int max_cols, FILE *fp) | 340 | int max_cols, FILE *fp) |
| 342 | { | 341 | { |
| 343 | struct sort_entry *se; | 342 | struct sort_entry *se; |
| 344 | struct rb_node *nd; | 343 | struct rb_node *nd; |
| 345 | size_t ret = 0; | 344 | size_t ret = 0; |
| 346 | u64 total_period; | 345 | u64 total_period; |
| 347 | unsigned long position = 1; | ||
| 348 | long displacement = 0; | ||
| 349 | unsigned int width; | 346 | unsigned int width; |
| 350 | const char *sep = symbol_conf.field_sep; | 347 | const char *sep = symbol_conf.field_sep; |
| 351 | const char *col_width = symbol_conf.col_width_list_str; | 348 | const char *col_width = symbol_conf.col_width_list_str; |
| @@ -449,15 +446,7 @@ print_entries: | |||
| 449 | if (h->filtered) | 446 | if (h->filtered) |
| 450 | continue; | 447 | continue; |
| 451 | 448 | ||
| 452 | if (show_displacement) { | 449 | ret += hist_entry__fprintf(h, max_cols, hists, pair, |
| 453 | if (h->pair != NULL) | ||
| 454 | displacement = ((long)h->pair->position - | ||
| 455 | (long)position); | ||
| 456 | else | ||
| 457 | displacement = 0; | ||
| 458 | ++position; | ||
| 459 | } | ||
| 460 | ret += hist_entry__fprintf(h, max_cols, hists, pair, displacement, | ||
| 461 | total_period, fp); | 450 | total_period, fp); |
| 462 | 451 | ||
| 463 | if (max_rows && ++nr_rows >= max_rows) | 452 | if (max_rows && ++nr_rows >= max_rows) |
diff --git a/tools/perf/util/hist.h b/tools/perf/util/hist.h index 6ca74079d5c9..efb8fc8a4d24 100644 --- a/tools/perf/util/hist.h +++ b/tools/perf/util/hist.h | |||
| @@ -99,8 +99,7 @@ void hists__inc_nr_events(struct hists *self, u32 type); | |||
| 99 | size_t hists__fprintf_nr_events(struct hists *self, FILE *fp); | 99 | size_t hists__fprintf_nr_events(struct hists *self, FILE *fp); |
| 100 | 100 | ||
| 101 | size_t hists__fprintf(struct hists *self, struct hists *pair, | 101 | size_t hists__fprintf(struct hists *self, struct hists *pair, |
| 102 | bool show_displacement, bool show_header, | 102 | bool show_header, int max_rows, int max_cols, FILE *fp); |
| 103 | int max_rows, int max_cols, FILE *fp); | ||
| 104 | 103 | ||
| 105 | int hist_entry__inc_addr_samples(struct hist_entry *self, int evidx, u64 addr); | 104 | int hist_entry__inc_addr_samples(struct hist_entry *self, int evidx, u64 addr); |
| 106 | int hist_entry__annotate(struct hist_entry *self, size_t privsize); | 105 | int hist_entry__annotate(struct hist_entry *self, size_t privsize); |
| @@ -120,7 +119,6 @@ struct perf_hpp { | |||
| 120 | size_t size; | 119 | size_t size; |
| 121 | u64 total_period; | 120 | u64 total_period; |
| 122 | const char *sep; | 121 | const char *sep; |
| 123 | long displacement; | ||
| 124 | void *ptr; | 122 | void *ptr; |
| 125 | }; | 123 | }; |
| 126 | 124 | ||
diff --git a/tools/perf/util/sort.h b/tools/perf/util/sort.h index eb3959b8e9d9..f070b523c81a 100644 --- a/tools/perf/util/sort.h +++ b/tools/perf/util/sort.h | |||
| @@ -73,8 +73,8 @@ struct hist_entry { | |||
| 73 | u8 filtered; | 73 | u8 filtered; |
| 74 | char *srcline; | 74 | char *srcline; |
| 75 | struct symbol *parent; | 75 | struct symbol *parent; |
| 76 | unsigned long position; | ||
| 76 | union { | 77 | union { |
| 77 | unsigned long position; | ||
| 78 | struct hist_entry *pair; | 78 | struct hist_entry *pair; |
| 79 | struct rb_root sorted_chain; | 79 | struct rb_root sorted_chain; |
| 80 | }; | 80 | }; |
