Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

perf ui/browser/annotate: Use global annotation_options

Now it can use the global options and no need save local browser
options separately.

Reviewed-by: Ian Rogers <irogers@google.com>
Signed-off-by: Namhyung Kim <namhyung@kernel.org>
Cc: Adrian Hunter <adrian.hunter@intel.com>
Cc: Ingo Molnar <mingo@kernel.org>
Cc: Jiri Olsa <jolsa@kernel.org>
Cc: Peter Zijlstra <peterz@infradead.org>
Link: https://lore.kernel.org/r/20231128175441.721579-6-namhyung@kernel.org
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>

authored by

Namhyung Kim and committed by
Arnaldo Carvalho de Melo
22197fb2 41fd3cac

+59 -95
+1 -1
tools/perf/builtin-annotate.c
··· 381 381 /* skip missing symbols */ 382 382 nd = rb_next(nd); 383 383 } else if (use_browser == 1) { 384 - key = hist_entry__tui_annotate(he, evsel, NULL, &annotate_opts); 384 + key = hist_entry__tui_annotate(he, evsel, NULL); 385 385 386 386 switch (key) { 387 387 case -1:
+3 -5
tools/perf/builtin-report.c
··· 540 540 evlist__for_each_entry(evlist, pos) { 541 541 ret = report__browse_block_hists(&rep->block_reports[i++].hist, 542 542 rep->min_percent, pos, 543 - &rep->session->header.env, 544 - &annotate_opts); 543 + &rep->session->header.env); 545 544 if (ret != 0) 546 545 return ret; 547 546 } ··· 572 573 573 574 if (rep->total_cycles_mode) { 574 575 report__browse_block_hists(&rep->block_reports[i++].hist, 575 - rep->min_percent, pos, 576 - NULL, NULL); 576 + rep->min_percent, pos, NULL); 577 577 continue; 578 578 } 579 579 ··· 667 669 } 668 670 669 671 ret = evlist__tui_browse_hists(evlist, help, NULL, rep->min_percent, 670 - &session->header.env, true, &annotate_opts); 672 + &session->header.env, true); 671 673 /* 672 674 * Usually "ret" is the last pressed key, and we only 673 675 * care if the key notifies us to switch data file.
+1 -2
tools/perf/builtin-top.c
··· 646 646 } 647 647 648 648 ret = evlist__tui_browse_hists(top->evlist, help, &hbt, top->min_percent, 649 - &top->session->header.env, !top->record_opts.overwrite, 650 - &annotate_opts); 649 + &top->session->header.env, !top->record_opts.overwrite); 651 650 if (ret == K_RELOAD) { 652 651 top->zero = true; 653 652 goto repeat;
+29 -36
tools/perf/ui/browsers/annotate.c
··· 27 27 struct rb_node *curr_hot; 28 28 struct annotation_line *selection; 29 29 struct arch *arch; 30 - struct annotation_options *opts; 31 30 bool searching_backwards; 32 31 char search_bf[128]; 33 32 }; ··· 96 97 struct annotation_write_ops ops = { 97 98 .first_line = row == 0, 98 99 .current_entry = is_current_entry, 99 - .change_color = (!notes->options->hide_src_code && 100 + .change_color = (!annotate_opts.hide_src_code && 100 101 (!is_current_entry || 101 102 (browser->use_navkeypressed && 102 103 !browser->navkeypressed))), ··· 127 128 128 129 while (pos && pos->al.offset == -1) { 129 130 pos = list_prev_entry(pos, al.node); 130 - if (!ab->opts->hide_src_code) 131 + if (!annotate_opts.hide_src_code) 131 132 diff++; 132 133 } 133 134 ··· 194 195 return; 195 196 } 196 197 197 - if (notes->options->hide_src_code) { 198 + if (annotate_opts.hide_src_code) { 198 199 from = cursor->al.idx_asm; 199 200 to = target->idx_asm; 200 201 } else { ··· 223 224 int ret = ui_browser__list_head_refresh(browser); 224 225 int pcnt_width = annotation__pcnt_width(notes); 225 226 226 - if (notes->options->jump_arrows) 227 + if (annotate_opts.jump_arrows) 227 228 annotate_browser__draw_current_jump(browser); 228 229 229 230 ui_browser__set_color(browser, HE_COLORSET_NORMAL); ··· 257 258 parent = *p; 258 259 l = rb_entry(parent, struct annotation_line, rb_node); 259 260 260 - if (disasm__cmp(al, l, browser->opts->percent_type) < 0) 261 + if (disasm__cmp(al, l, annotate_opts.percent_type) < 0) 261 262 p = &(*p)->rb_left; 262 263 else 263 264 p = &(*p)->rb_right; ··· 293 294 static void annotate_browser__set_rb_top(struct annotate_browser *browser, 294 295 struct rb_node *nd) 295 296 { 296 - struct annotation *notes = browser__annotation(&browser->b); 297 297 struct annotation_line * pos = rb_entry(nd, struct annotation_line, rb_node); 298 298 u32 idx = pos->idx; 299 299 300 - if (notes->options->hide_src_code) 300 + if (annotate_opts.hide_src_code) 301 301 idx = pos->idx_asm; 302 302 annotate_browser__set_top(browser, pos, idx); 303 303 browser->curr_hot = nd; ··· 329 331 double percent; 330 332 331 333 percent = annotation_data__percent(&pos->al.data[i], 332 - browser->opts->percent_type); 334 + annotate_opts.percent_type); 333 335 334 336 if (max_percent < percent) 335 337 max_percent = percent; ··· 378 380 browser->b.seek(&browser->b, offset, SEEK_CUR); 379 381 al = list_entry(browser->b.top, struct annotation_line, node); 380 382 381 - if (notes->options->hide_src_code) { 383 + if (annotate_opts.hide_src_code) { 382 384 if (al->idx_asm < offset) 383 385 offset = al->idx; 384 386 385 387 browser->b.nr_entries = notes->src->nr_entries; 386 - notes->options->hide_src_code = false; 388 + annotate_opts.hide_src_code = false; 387 389 browser->b.seek(&browser->b, -offset, SEEK_CUR); 388 390 browser->b.top_idx = al->idx - offset; 389 391 browser->b.index = al->idx; ··· 401 403 offset = al->idx_asm; 402 404 403 405 browser->b.nr_entries = notes->src->nr_asm_entries; 404 - notes->options->hide_src_code = true; 406 + annotate_opts.hide_src_code = true; 405 407 browser->b.seek(&browser->b, -offset, SEEK_CUR); 406 408 browser->b.top_idx = al->idx_asm - offset; 407 409 browser->b.index = al->idx_asm; ··· 481 483 target_ms.map = ms->map; 482 484 target_ms.sym = dl->ops.target.sym; 483 485 annotation__unlock(notes); 484 - symbol__tui_annotate(&target_ms, evsel, hbt, browser->opts); 485 - sym_title(ms->sym, ms->map, title, sizeof(title), browser->opts->percent_type); 486 + symbol__tui_annotate(&target_ms, evsel, hbt); 487 + sym_title(ms->sym, ms->map, title, sizeof(title), annotate_opts.percent_type); 486 488 ui_browser__show_title(&browser->b, title); 487 489 return true; 488 490 } ··· 657 659 658 660 static int annotate_browser__show(struct ui_browser *browser, char *title, const char *help) 659 661 { 660 - struct annotate_browser *ab = container_of(browser, struct annotate_browser, b); 661 662 struct map_symbol *ms = browser->priv; 662 663 struct symbol *sym = ms->sym; 663 664 char symbol_dso[SYM_TITLE_MAX_SIZE]; ··· 664 667 if (ui_browser__show(browser, title, help) < 0) 665 668 return -1; 666 669 667 - sym_title(sym, ms->map, symbol_dso, sizeof(symbol_dso), ab->opts->percent_type); 670 + sym_title(sym, ms->map, symbol_dso, sizeof(symbol_dso), annotate_opts.percent_type); 668 671 669 672 ui_browser__gotorc_title(browser, 0, 0); 670 673 ui_browser__set_color(browser, HE_COLORSET_ROOT); ··· 806 809 annotate_browser__show(&browser->b, title, help); 807 810 continue; 808 811 case 'k': 809 - notes->options->show_linenr = !notes->options->show_linenr; 812 + annotate_opts.show_linenr = !annotate_opts.show_linenr; 810 813 continue; 811 814 case 'l': 812 815 annotate_browser__show_full_location (&browser->b); ··· 819 822 ui_helpline__puts(help); 820 823 continue; 821 824 case 'o': 822 - notes->options->use_offset = !notes->options->use_offset; 825 + annotate_opts.use_offset = !annotate_opts.use_offset; 823 826 annotation__update_column_widths(notes); 824 827 continue; 825 828 case 'O': 826 - if (++notes->options->offset_level > ANNOTATION__MAX_OFFSET_LEVEL) 827 - notes->options->offset_level = ANNOTATION__MIN_OFFSET_LEVEL; 829 + if (++annotate_opts.offset_level > ANNOTATION__MAX_OFFSET_LEVEL) 830 + annotate_opts.offset_level = ANNOTATION__MIN_OFFSET_LEVEL; 828 831 continue; 829 832 case 'j': 830 - notes->options->jump_arrows = !notes->options->jump_arrows; 833 + annotate_opts.jump_arrows = !annotate_opts.jump_arrows; 831 834 continue; 832 835 case 'J': 833 - notes->options->show_nr_jumps = !notes->options->show_nr_jumps; 836 + annotate_opts.show_nr_jumps = !annotate_opts.show_nr_jumps; 834 837 annotation__update_column_widths(notes); 835 838 continue; 836 839 case '/': ··· 894 897 annotation__update_column_widths(notes); 895 898 continue; 896 899 case 'c': 897 - if (notes->options->show_minmax_cycle) 898 - notes->options->show_minmax_cycle = false; 900 + if (annotate_opts.show_minmax_cycle) 901 + annotate_opts.show_minmax_cycle = false; 899 902 else 900 - notes->options->show_minmax_cycle = true; 903 + annotate_opts.show_minmax_cycle = true; 901 904 annotation__update_column_widths(notes); 902 905 continue; 903 906 case 'p': 904 907 case 'b': 905 - switch_percent_type(browser->opts, key == 'b'); 908 + switch_percent_type(&annotate_opts, key == 'b'); 906 909 hists__scnprintf_title(hists, title, sizeof(title)); 907 910 annotate_browser__show(&browser->b, title, help); 908 911 continue; ··· 929 932 } 930 933 931 934 int map_symbol__tui_annotate(struct map_symbol *ms, struct evsel *evsel, 932 - struct hist_browser_timer *hbt, 933 - struct annotation_options *opts) 935 + struct hist_browser_timer *hbt) 934 936 { 935 - return symbol__tui_annotate(ms, evsel, hbt, opts); 937 + return symbol__tui_annotate(ms, evsel, hbt); 936 938 } 937 939 938 940 int hist_entry__tui_annotate(struct hist_entry *he, struct evsel *evsel, 939 - struct hist_browser_timer *hbt, 940 - struct annotation_options *opts) 941 + struct hist_browser_timer *hbt) 941 942 { 942 943 /* reset abort key so that it can get Ctrl-C as a key */ 943 944 SLang_reset_tty(); 944 945 SLang_init_tty(0, 0, 0); 945 946 946 - return map_symbol__tui_annotate(&he->ms, evsel, hbt, opts); 947 + return map_symbol__tui_annotate(&he->ms, evsel, hbt); 947 948 } 948 949 949 950 int symbol__tui_annotate(struct map_symbol *ms, struct evsel *evsel, 950 - struct hist_browser_timer *hbt, 951 - struct annotation_options *opts) 951 + struct hist_browser_timer *hbt) 952 952 { 953 953 struct symbol *sym = ms->sym; 954 954 struct annotation *notes = symbol__annotation(sym); ··· 959 965 .priv = ms, 960 966 .use_navkeypressed = true, 961 967 }, 962 - .opts = opts, 963 968 }; 964 969 struct dso *dso; 965 970 int ret = -1, err; ··· 989 996 browser.b.entries = &notes->src->source, 990 997 browser.b.width += 18; /* Percentage */ 991 998 992 - if (notes->options->hide_src_code) 999 + if (annotate_opts.hide_src_code) 993 1000 ui_browser__init_asm_mode(&browser.b); 994 1001 995 1002 ret = annotate_browser__run(&browser, evsel, hbt);
+12 -22
tools/perf/ui/browsers/hists.c
··· 2250 2250 static struct hist_browser * 2251 2251 perf_evsel_browser__new(struct evsel *evsel, 2252 2252 struct hist_browser_timer *hbt, 2253 - struct perf_env *env, 2254 - struct annotation_options *annotation_opts) 2253 + struct perf_env *env) 2255 2254 { 2256 2255 struct hist_browser *browser = hist_browser__new(evsel__hists(evsel)); 2257 2256 ··· 2258 2259 browser->hbt = hbt; 2259 2260 browser->env = env; 2260 2261 browser->title = hists_browser__scnprintf_title; 2261 - browser->annotation_opts = annotation_opts; 2262 2262 } 2263 2263 return browser; 2264 2264 } ··· 2430 2432 struct hist_entry *he; 2431 2433 int err; 2432 2434 2433 - if (!browser->annotation_opts->objdump_path && 2434 - perf_env__lookup_objdump(browser->env, &browser->annotation_opts->objdump_path)) 2435 + if (!annotate_opts.objdump_path && 2436 + perf_env__lookup_objdump(browser->env, &annotate_opts.objdump_path)) 2435 2437 return 0; 2436 2438 2437 2439 notes = symbol__annotation(act->ms.sym); ··· 2443 2445 else 2444 2446 evsel = hists_to_evsel(browser->hists); 2445 2447 2446 - err = map_symbol__tui_annotate(&act->ms, evsel, browser->hbt, 2447 - browser->annotation_opts); 2448 + err = map_symbol__tui_annotate(&act->ms, evsel, browser->hbt); 2448 2449 he = hist_browser__selected_entry(browser); 2449 2450 /* 2450 2451 * offer option to annotate the other branch source or target ··· 2940 2943 2941 2944 static int evsel__hists_browse(struct evsel *evsel, int nr_events, const char *helpline, 2942 2945 bool left_exits, struct hist_browser_timer *hbt, float min_pcnt, 2943 - struct perf_env *env, bool warn_lost_event, 2944 - struct annotation_options *annotation_opts) 2946 + struct perf_env *env, bool warn_lost_event) 2945 2947 { 2946 2948 struct hists *hists = evsel__hists(evsel); 2947 - struct hist_browser *browser = perf_evsel_browser__new(evsel, hbt, env, annotation_opts); 2949 + struct hist_browser *browser = perf_evsel_browser__new(evsel, hbt, env); 2948 2950 struct branch_info *bi = NULL; 2949 2951 #define MAX_OPTIONS 16 2950 2952 char *options[MAX_OPTIONS]; ··· 3394 3398 struct evsel_menu { 3395 3399 struct ui_browser b; 3396 3400 struct evsel *selection; 3397 - struct annotation_options *annotation_opts; 3398 3401 bool lost_events, lost_events_warned; 3399 3402 float min_pcnt; 3400 3403 struct perf_env *env; ··· 3494 3499 hbt->timer(hbt->arg); 3495 3500 key = evsel__hists_browse(pos, nr_events, help, true, hbt, 3496 3501 menu->min_pcnt, menu->env, 3497 - warn_lost_event, 3498 - menu->annotation_opts); 3502 + warn_lost_event); 3499 3503 ui_browser__show_title(&menu->b, title); 3500 3504 switch (key) { 3501 3505 case K_TAB: ··· 3551 3557 3552 3558 static int __evlist__tui_browse_hists(struct evlist *evlist, int nr_entries, const char *help, 3553 3559 struct hist_browser_timer *hbt, float min_pcnt, struct perf_env *env, 3554 - bool warn_lost_event, struct annotation_options *annotation_opts) 3560 + bool warn_lost_event) 3555 3561 { 3556 3562 struct evsel *pos; 3557 3563 struct evsel_menu menu = { ··· 3566 3572 }, 3567 3573 .min_pcnt = min_pcnt, 3568 3574 .env = env, 3569 - .annotation_opts = annotation_opts, 3570 3575 }; 3571 3576 3572 3577 ui_helpline__push("Press ESC to exit"); ··· 3600 3607 } 3601 3608 3602 3609 int evlist__tui_browse_hists(struct evlist *evlist, const char *help, struct hist_browser_timer *hbt, 3603 - float min_pcnt, struct perf_env *env, bool warn_lost_event, 3604 - struct annotation_options *annotation_opts) 3610 + float min_pcnt, struct perf_env *env, bool warn_lost_event) 3605 3611 { 3606 3612 int nr_entries = evlist->core.nr_entries; 3607 3613 ··· 3609 3617 struct evsel *first = evlist__first(evlist); 3610 3618 3611 3619 return evsel__hists_browse(first, nr_entries, help, false, hbt, min_pcnt, 3612 - env, warn_lost_event, annotation_opts); 3620 + env, warn_lost_event); 3613 3621 } 3614 3622 } 3615 3623 ··· 3627 3635 } 3628 3636 3629 3637 return __evlist__tui_browse_hists(evlist, nr_entries, help, hbt, min_pcnt, env, 3630 - warn_lost_event, annotation_opts); 3638 + warn_lost_event); 3631 3639 } 3632 3640 3633 3641 static int block_hists_browser__title(struct hist_browser *browser, char *bf, ··· 3646 3654 } 3647 3655 3648 3656 int block_hists_tui_browse(struct block_hist *bh, struct evsel *evsel, 3649 - float min_percent, struct perf_env *env, 3650 - struct annotation_options *annotation_opts) 3657 + float min_percent, struct perf_env *env) 3651 3658 { 3652 3659 struct hists *hists = &bh->block_hists; 3653 3660 struct hist_browser *browser; ··· 3663 3672 browser->title = block_hists_browser__title; 3664 3673 browser->min_pcnt = min_percent; 3665 3674 browser->env = env; 3666 - browser->annotation_opts = annotation_opts; 3667 3675 3668 3676 /* reset abort key so that it can get Ctrl-C as a key */ 3669 3677 SLang_reset_tty();
-2
tools/perf/ui/browsers/hists.h
··· 4 4 5 5 #include "ui/browser.h" 6 6 7 - struct annotation_options; 8 7 struct evsel; 9 8 10 9 struct hist_browser { ··· 14 15 struct hist_browser_timer *hbt; 15 16 struct pstack *pstack; 16 17 struct perf_env *env; 17 - struct annotation_options *annotation_opts; 18 18 struct evsel *block_evsel; 19 19 int print_seq; 20 20 bool show_dso;
+2 -4
tools/perf/util/annotate.h
··· 418 418 419 419 #ifdef HAVE_SLANG_SUPPORT 420 420 int symbol__tui_annotate(struct map_symbol *ms, struct evsel *evsel, 421 - struct hist_browser_timer *hbt, 422 - struct annotation_options *opts); 421 + struct hist_browser_timer *hbt); 423 422 #else 424 423 static inline int symbol__tui_annotate(struct map_symbol *ms __maybe_unused, 425 424 struct evsel *evsel __maybe_unused, 426 - struct hist_browser_timer *hbt __maybe_unused, 427 - struct annotation_options *opts __maybe_unused) 425 + struct hist_browser_timer *hbt __maybe_unused) 428 426 { 429 427 return 0; 430 428 }
+2 -4
tools/perf/util/block-info.c
··· 464 464 } 465 465 466 466 int report__browse_block_hists(struct block_hist *bh, float min_percent, 467 - struct evsel *evsel, struct perf_env *env, 468 - struct annotation_options *annotation_opts) 467 + struct evsel *evsel, struct perf_env *env) 469 468 { 470 469 int ret; 471 470 ··· 476 477 return 0; 477 478 case 1: 478 479 symbol_conf.report_individual_block = true; 479 - ret = block_hists_tui_browse(bh, evsel, min_percent, 480 - env, annotation_opts); 480 + ret = block_hists_tui_browse(bh, evsel, min_percent, env); 481 481 return ret; 482 482 default: 483 483 return -1;
+1 -2
tools/perf/util/block-info.h
··· 78 78 void block_info__free_report(struct block_report *reps, int nr_reps); 79 79 80 80 int report__browse_block_hists(struct block_hist *bh, float min_percent, 81 - struct evsel *evsel, struct perf_env *env, 82 - struct annotation_options *annotation_opts); 81 + struct evsel *evsel, struct perf_env *env); 83 82 84 83 float block_info__total_cycles_percent(struct hist_entry *he); 85 84
+8 -17
tools/perf/util/hist.h
··· 457 457 int refresh; 458 458 }; 459 459 460 - struct annotation_options; 461 460 struct res_sample; 462 461 463 462 enum rstype { ··· 472 473 void attr_to_script(char *buf, struct perf_event_attr *attr); 473 474 474 475 int map_symbol__tui_annotate(struct map_symbol *ms, struct evsel *evsel, 475 - struct hist_browser_timer *hbt, 476 - struct annotation_options *annotation_opts); 476 + struct hist_browser_timer *hbt); 477 477 478 478 int hist_entry__tui_annotate(struct hist_entry *he, struct evsel *evsel, 479 - struct hist_browser_timer *hbt, 480 - struct annotation_options *annotation_opts); 479 + struct hist_browser_timer *hbt); 481 480 482 481 int evlist__tui_browse_hists(struct evlist *evlist, const char *help, struct hist_browser_timer *hbt, 483 - float min_pcnt, struct perf_env *env, bool warn_lost_event, 484 - struct annotation_options *annotation_options); 482 + float min_pcnt, struct perf_env *env, bool warn_lost_event); 485 483 486 484 int script_browse(const char *script_opt, struct evsel *evsel); 487 485 ··· 488 492 void res_sample_init(void); 489 493 490 494 int block_hists_tui_browse(struct block_hist *bh, struct evsel *evsel, 491 - float min_percent, struct perf_env *env, 492 - struct annotation_options *annotation_opts); 495 + float min_percent, struct perf_env *env); 493 496 #else 494 497 static inline 495 498 int evlist__tui_browse_hists(struct evlist *evlist __maybe_unused, ··· 496 501 struct hist_browser_timer *hbt __maybe_unused, 497 502 float min_pcnt __maybe_unused, 498 503 struct perf_env *env __maybe_unused, 499 - bool warn_lost_event __maybe_unused, 500 - struct annotation_options *annotation_options __maybe_unused) 504 + bool warn_lost_event __maybe_unused) 501 505 { 502 506 return 0; 503 507 } 504 508 static inline int map_symbol__tui_annotate(struct map_symbol *ms __maybe_unused, 505 509 struct evsel *evsel __maybe_unused, 506 - struct hist_browser_timer *hbt __maybe_unused, 507 - struct annotation_options *annotation_options __maybe_unused) 510 + struct hist_browser_timer *hbt __maybe_unused) 508 511 { 509 512 return 0; 510 513 } 511 514 512 515 static inline int hist_entry__tui_annotate(struct hist_entry *he __maybe_unused, 513 516 struct evsel *evsel __maybe_unused, 514 - struct hist_browser_timer *hbt __maybe_unused, 515 - struct annotation_options *annotation_opts __maybe_unused) 517 + struct hist_browser_timer *hbt __maybe_unused) 516 518 { 517 519 return 0; 518 520 } ··· 533 541 static inline int block_hists_tui_browse(struct block_hist *bh __maybe_unused, 534 542 struct evsel *evsel __maybe_unused, 535 543 float min_percent __maybe_unused, 536 - struct perf_env *env __maybe_unused, 537 - struct annotation_options *annotation_opts __maybe_unused) 544 + struct perf_env *env __maybe_unused) 538 545 { 539 546 return 0; 540 547 }