diff options
Diffstat (limited to 'tools/perf/ui/browsers/annotate.c')
| -rw-r--r-- | tools/perf/ui/browsers/annotate.c | 16 |
1 files changed, 10 insertions, 6 deletions
diff --git a/tools/perf/ui/browsers/annotate.c b/tools/perf/ui/browsers/annotate.c index 1d00e5ec7906..82e16bf84466 100644 --- a/tools/perf/ui/browsers/annotate.c +++ b/tools/perf/ui/browsers/annotate.c | |||
| @@ -224,20 +224,24 @@ static unsigned int annotate_browser__refresh(struct ui_browser *browser) | |||
| 224 | return ret; | 224 | return ret; |
| 225 | } | 225 | } |
| 226 | 226 | ||
| 227 | static int disasm__cmp(struct annotation_line *a, struct annotation_line *b) | 227 | static double disasm__cmp(struct annotation_line *a, struct annotation_line *b, |
| 228 | int percent_type) | ||
| 228 | { | 229 | { |
| 229 | int i; | 230 | int i; |
| 230 | 231 | ||
| 231 | for (i = 0; i < a->data_nr; i++) { | 232 | for (i = 0; i < a->data_nr; i++) { |
| 232 | if (a->data[i].percent == b->data[i].percent) | 233 | if (a->data[i].percent[percent_type] == b->data[i].percent[percent_type]) |
| 233 | continue; | 234 | continue; |
| 234 | return a->data[i].percent < b->data[i].percent; | 235 | return a->data[i].percent[percent_type] - |
| 236 | b->data[i].percent[percent_type]; | ||
| 235 | } | 237 | } |
| 236 | return 0; | 238 | return 0; |
| 237 | } | 239 | } |
| 238 | 240 | ||
| 239 | static void disasm_rb_tree__insert(struct rb_root *root, struct annotation_line *al) | 241 | static void disasm_rb_tree__insert(struct annotate_browser *browser, |
| 242 | struct annotation_line *al) | ||
| 240 | { | 243 | { |
| 244 | struct rb_root *root = &browser->entries; | ||
| 241 | struct rb_node **p = &root->rb_node; | 245 | struct rb_node **p = &root->rb_node; |
| 242 | struct rb_node *parent = NULL; | 246 | struct rb_node *parent = NULL; |
| 243 | struct annotation_line *l; | 247 | struct annotation_line *l; |
| @@ -246,7 +250,7 @@ static void disasm_rb_tree__insert(struct rb_root *root, struct annotation_line | |||
| 246 | parent = *p; | 250 | parent = *p; |
| 247 | l = rb_entry(parent, struct annotation_line, rb_node); | 251 | l = rb_entry(parent, struct annotation_line, rb_node); |
| 248 | 252 | ||
| 249 | if (disasm__cmp(al, l)) | 253 | if (disasm__cmp(al, l, browser->opts->percent_type) < 0) |
| 250 | p = &(*p)->rb_left; | 254 | p = &(*p)->rb_left; |
| 251 | else | 255 | else |
| 252 | p = &(*p)->rb_right; | 256 | p = &(*p)->rb_right; |
| @@ -329,7 +333,7 @@ static void annotate_browser__calc_percent(struct annotate_browser *browser, | |||
| 329 | RB_CLEAR_NODE(&pos->al.rb_node); | 333 | RB_CLEAR_NODE(&pos->al.rb_node); |
| 330 | continue; | 334 | continue; |
| 331 | } | 335 | } |
| 332 | disasm_rb_tree__insert(&browser->entries, &pos->al); | 336 | disasm_rb_tree__insert(browser, &pos->al); |
| 333 | } | 337 | } |
| 334 | pthread_mutex_unlock(¬es->lock); | 338 | pthread_mutex_unlock(¬es->lock); |
| 335 | 339 | ||
