aboutsummaryrefslogtreecommitdiffstats
path: root/tools/perf/ui/browsers/annotate.c
diff options
context:
space:
mode:
authorJiri Olsa <jolsa@kernel.org>2017-10-11 11:01:36 -0400
committerArnaldo Carvalho de Melo <acme@redhat.com>2017-11-13 07:39:59 -0500
commit5b12adc849be011fd6d99a16e39d83afee43c0a0 (patch)
tree91fe654617b92ceed448b5d24e6f681496d05cb7 /tools/perf/ui/browsers/annotate.c
parent82b9d7ff096b7e7ae3efaeb341ee673bb494bb61 (diff)
perf annotate: Move rb_node to struct annotation_line
Move rb_node to struct annotation_line to make struct annotation_line the rb tree node for sorted lines used in both stdio and TUI code. This way we can unite the sorted lines lines codes for both TUI and stdio in the following patches. Signed-off-by: Jiri Olsa <jolsa@kernel.org> Cc: Andi Kleen <andi@firstfloor.org> Cc: David Ahern <dsahern@gmail.com> Cc: Namhyung Kim <namhyung@kernel.org> Cc: Peter Zijlstra <peterz@infradead.org> Link: http://lkml.kernel.org/r/20171011150158.11895-14-jolsa@kernel.org Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
Diffstat (limited to 'tools/perf/ui/browsers/annotate.c')
-rw-r--r--tools/perf/ui/browsers/annotate.c30
1 files changed, 16 insertions, 14 deletions
diff --git a/tools/perf/ui/browsers/annotate.c b/tools/perf/ui/browsers/annotate.c
index 881ad6122057..cfde5a2ca3f4 100644
--- a/tools/perf/ui/browsers/annotate.c
+++ b/tools/perf/ui/browsers/annotate.c
@@ -26,7 +26,6 @@ struct disasm_line_samples {
26#define CYCLES_WIDTH 6 26#define CYCLES_WIDTH 6
27 27
28struct browser_disasm_line { 28struct browser_disasm_line {
29 struct rb_node rb_node;
30 u32 idx; 29 u32 idx;
31 int idx_asm; 30 int idx_asm;
32 int jump_sources; 31 int jump_sources;
@@ -362,9 +361,11 @@ static unsigned int annotate_browser__refresh(struct ui_browser *browser)
362 return ret; 361 return ret;
363} 362}
364 363
365static int disasm__cmp(struct browser_disasm_line *a, 364static int disasm__cmp(struct disasm_line *da,
366 struct browser_disasm_line *b, int nr_pcnt) 365 struct disasm_line *db, int nr_pcnt)
367{ 366{
367 struct browser_disasm_line *a = disasm_line__browser(da);
368 struct browser_disasm_line *b = disasm_line__browser(db);
368 int i; 369 int i;
369 370
370 for (i = 0; i < nr_pcnt; i++) { 371 for (i = 0; i < nr_pcnt; i++) {
@@ -375,24 +376,24 @@ static int disasm__cmp(struct browser_disasm_line *a,
375 return 0; 376 return 0;
376} 377}
377 378
378static void disasm_rb_tree__insert(struct rb_root *root, struct browser_disasm_line *bdl, 379static void disasm_rb_tree__insert(struct rb_root *root, struct disasm_line *dl,
379 int nr_events) 380 int nr_events)
380{ 381{
381 struct rb_node **p = &root->rb_node; 382 struct rb_node **p = &root->rb_node;
382 struct rb_node *parent = NULL; 383 struct rb_node *parent = NULL;
383 struct browser_disasm_line *l; 384 struct disasm_line *l;
384 385
385 while (*p != NULL) { 386 while (*p != NULL) {
386 parent = *p; 387 parent = *p;
387 l = rb_entry(parent, struct browser_disasm_line, rb_node); 388 l = rb_entry(parent, struct disasm_line, al.rb_node);
388 389
389 if (disasm__cmp(bdl, l, nr_events)) 390 if (disasm__cmp(dl, l, nr_events))
390 p = &(*p)->rb_left; 391 p = &(*p)->rb_left;
391 else 392 else
392 p = &(*p)->rb_right; 393 p = &(*p)->rb_right;
393 } 394 }
394 rb_link_node(&bdl->rb_node, parent, p); 395 rb_link_node(&dl->al.rb_node, parent, p);
395 rb_insert_color(&bdl->rb_node, root); 396 rb_insert_color(&dl->al.rb_node, root);
396} 397}
397 398
398static void annotate_browser__set_top(struct annotate_browser *browser, 399static void annotate_browser__set_top(struct annotate_browser *browser,
@@ -425,8 +426,9 @@ static void annotate_browser__set_rb_top(struct annotate_browser *browser,
425 struct disasm_line *pos; 426 struct disasm_line *pos;
426 u32 idx; 427 u32 idx;
427 428
428 bpos = rb_entry(nd, struct browser_disasm_line, rb_node); 429 pos = rb_entry(nd, struct disasm_line, al.rb_node);
429 pos = ((struct disasm_line *)bpos) - 1; 430 bpos = disasm_line__browser(pos);
431
430 idx = bpos->idx; 432 idx = bpos->idx;
431 if (annotate_browser__opts.hide_src_code) 433 if (annotate_browser__opts.hide_src_code)
432 idx = bpos->idx_asm; 434 idx = bpos->idx_asm;
@@ -455,7 +457,7 @@ static void annotate_browser__calc_percent(struct annotate_browser *browser,
455 int i; 457 int i;
456 458
457 if (pos->al.offset == -1) { 459 if (pos->al.offset == -1) {
458 RB_CLEAR_NODE(&bpos->rb_node); 460 RB_CLEAR_NODE(&pos->al.rb_node);
459 continue; 461 continue;
460 } 462 }
461 463
@@ -476,10 +478,10 @@ static void annotate_browser__calc_percent(struct annotate_browser *browser,
476 } 478 }
477 479
478 if (max_percent < 0.01 && pos->al.ipc == 0) { 480 if (max_percent < 0.01 && pos->al.ipc == 0) {
479 RB_CLEAR_NODE(&bpos->rb_node); 481 RB_CLEAR_NODE(&pos->al.rb_node);
480 continue; 482 continue;
481 } 483 }
482 disasm_rb_tree__insert(&browser->entries, bpos, 484 disasm_rb_tree__insert(&browser->entries, pos,
483 browser->nr_events); 485 browser->nr_events);
484 } 486 }
485 pthread_mutex_unlock(&notes->lock); 487 pthread_mutex_unlock(&notes->lock);