Skip to content
This repository was archived by the owner on Oct 31, 2024. It is now read-only.

Commit 297871c

Browse files
namhyunggregkh
authored andcommitted
perf ui/browser/annotate: Use global annotation_options
[ Upstream commit 22197fb ] 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> Stable-dep-of: 3ef4445 ("perf report: Fix --total-cycles --stdio output error") Signed-off-by: Sasha Levin <sashal@kernel.org>
1 parent 4c857dc commit 297871c

File tree

10 files changed

+59
-95
lines changed

10 files changed

+59
-95
lines changed

tools/perf/builtin-annotate.c

+1-1
Original file line numberDiff line numberDiff line change
@@ -378,7 +378,7 @@ static void hists__find_annotations(struct hists *hists,
378378
/* skip missing symbols */
379379
nd = rb_next(nd);
380380
} else if (use_browser == 1) {
381-
key = hist_entry__tui_annotate(he, evsel, NULL, &annotate_opts);
381+
key = hist_entry__tui_annotate(he, evsel, NULL);
382382

383383
switch (key) {
384384
case -1:

tools/perf/builtin-report.c

+3-5
Original file line numberDiff line numberDiff line change
@@ -540,8 +540,7 @@ static int evlist__tui_block_hists_browse(struct evlist *evlist, struct report *
540540
evlist__for_each_entry(evlist, pos) {
541541
ret = report__browse_block_hists(&rep->block_reports[i++].hist,
542542
rep->min_percent, pos,
543-
&rep->session->header.env,
544-
&annotate_opts);
543+
&rep->session->header.env);
545544
if (ret != 0)
546545
return ret;
547546
}
@@ -573,8 +572,7 @@ static int evlist__tty_browse_hists(struct evlist *evlist, struct report *rep, c
573572

574573
if (rep->total_cycles_mode) {
575574
report__browse_block_hists(&rep->block_reports[i++].hist,
576-
rep->min_percent, pos,
577-
NULL, NULL);
575+
rep->min_percent, pos, NULL);
578576
continue;
579577
}
580578

@@ -669,7 +667,7 @@ static int report__browse_hists(struct report *rep)
669667
}
670668

671669
ret = evlist__tui_browse_hists(evlist, help, NULL, rep->min_percent,
672-
&session->header.env, true, &annotate_opts);
670+
&session->header.env, true);
673671
/*
674672
* Usually "ret" is the last pressed key, and we only
675673
* care if the key notifies us to switch data file.

tools/perf/builtin-top.c

+1-2
Original file line numberDiff line numberDiff line change
@@ -646,8 +646,7 @@ static void *display_thread_tui(void *arg)
646646
}
647647

648648
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);
651650
if (ret == K_RELOAD) {
652651
top->zero = true;
653652
goto repeat;

tools/perf/ui/browsers/annotate.c

+29-36
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,6 @@ struct annotate_browser {
2727
struct rb_node *curr_hot;
2828
struct annotation_line *selection;
2929
struct arch *arch;
30-
struct annotation_options *opts;
3130
bool searching_backwards;
3231
char search_bf[128];
3332
};
@@ -97,7 +96,7 @@ static void annotate_browser__write(struct ui_browser *browser, void *entry, int
9796
struct annotation_write_ops ops = {
9897
.first_line = row == 0,
9998
.current_entry = is_current_entry,
100-
.change_color = (!notes->options->hide_src_code &&
99+
.change_color = (!annotate_opts.hide_src_code &&
101100
(!is_current_entry ||
102101
(browser->use_navkeypressed &&
103102
!browser->navkeypressed))),
@@ -128,7 +127,7 @@ static int is_fused(struct annotate_browser *ab, struct disasm_line *cursor)
128127

129128
while (pos && pos->al.offset == -1) {
130129
pos = list_prev_entry(pos, al.node);
131-
if (!ab->opts->hide_src_code)
130+
if (!annotate_opts.hide_src_code)
132131
diff++;
133132
}
134133

@@ -195,7 +194,7 @@ static void annotate_browser__draw_current_jump(struct ui_browser *browser)
195194
return;
196195
}
197196

198-
if (notes->options->hide_src_code) {
197+
if (annotate_opts.hide_src_code) {
199198
from = cursor->al.idx_asm;
200199
to = target->idx_asm;
201200
} else {
@@ -224,7 +223,7 @@ static unsigned int annotate_browser__refresh(struct ui_browser *browser)
224223
int ret = ui_browser__list_head_refresh(browser);
225224
int pcnt_width = annotation__pcnt_width(notes);
226225

227-
if (notes->options->jump_arrows)
226+
if (annotate_opts.jump_arrows)
228227
annotate_browser__draw_current_jump(browser);
229228

230229
ui_browser__set_color(browser, HE_COLORSET_NORMAL);
@@ -258,7 +257,7 @@ static void disasm_rb_tree__insert(struct annotate_browser *browser,
258257
parent = *p;
259258
l = rb_entry(parent, struct annotation_line, rb_node);
260259

261-
if (disasm__cmp(al, l, browser->opts->percent_type) < 0)
260+
if (disasm__cmp(al, l, annotate_opts.percent_type) < 0)
262261
p = &(*p)->rb_left;
263262
else
264263
p = &(*p)->rb_right;
@@ -294,11 +293,10 @@ static void annotate_browser__set_top(struct annotate_browser *browser,
294293
static void annotate_browser__set_rb_top(struct annotate_browser *browser,
295294
struct rb_node *nd)
296295
{
297-
struct annotation *notes = browser__annotation(&browser->b);
298296
struct annotation_line * pos = rb_entry(nd, struct annotation_line, rb_node);
299297
u32 idx = pos->idx;
300298

301-
if (notes->options->hide_src_code)
299+
if (annotate_opts.hide_src_code)
302300
idx = pos->idx_asm;
303301
annotate_browser__set_top(browser, pos, idx);
304302
browser->curr_hot = nd;
@@ -331,7 +329,7 @@ static void annotate_browser__calc_percent(struct annotate_browser *browser,
331329
double percent;
332330

333331
percent = annotation_data__percent(&pos->al.data[i],
334-
browser->opts->percent_type);
332+
annotate_opts.percent_type);
335333

336334
if (max_percent < percent)
337335
max_percent = percent;
@@ -380,12 +378,12 @@ static bool annotate_browser__toggle_source(struct annotate_browser *browser)
380378
browser->b.seek(&browser->b, offset, SEEK_CUR);
381379
al = list_entry(browser->b.top, struct annotation_line, node);
382380

383-
if (notes->options->hide_src_code) {
381+
if (annotate_opts.hide_src_code) {
384382
if (al->idx_asm < offset)
385383
offset = al->idx;
386384

387385
browser->b.nr_entries = notes->src->nr_entries;
388-
notes->options->hide_src_code = false;
386+
annotate_opts.hide_src_code = false;
389387
browser->b.seek(&browser->b, -offset, SEEK_CUR);
390388
browser->b.top_idx = al->idx - offset;
391389
browser->b.index = al->idx;
@@ -403,7 +401,7 @@ static bool annotate_browser__toggle_source(struct annotate_browser *browser)
403401
offset = al->idx_asm;
404402

405403
browser->b.nr_entries = notes->src->nr_asm_entries;
406-
notes->options->hide_src_code = true;
404+
annotate_opts.hide_src_code = true;
407405
browser->b.seek(&browser->b, -offset, SEEK_CUR);
408406
browser->b.top_idx = al->idx_asm - offset;
409407
browser->b.index = al->idx_asm;
@@ -483,8 +481,8 @@ static bool annotate_browser__callq(struct annotate_browser *browser,
483481
target_ms.map = ms->map;
484482
target_ms.sym = dl->ops.target.sym;
485483
annotation__unlock(notes);
486-
symbol__tui_annotate(&target_ms, evsel, hbt, browser->opts);
487-
sym_title(ms->sym, ms->map, title, sizeof(title), browser->opts->percent_type);
484+
symbol__tui_annotate(&target_ms, evsel, hbt);
485+
sym_title(ms->sym, ms->map, title, sizeof(title), annotate_opts.percent_type);
488486
ui_browser__show_title(&browser->b, title);
489487
return true;
490488
}
@@ -659,15 +657,14 @@ bool annotate_browser__continue_search_reverse(struct annotate_browser *browser,
659657

660658
static int annotate_browser__show(struct ui_browser *browser, char *title, const char *help)
661659
{
662-
struct annotate_browser *ab = container_of(browser, struct annotate_browser, b);
663660
struct map_symbol *ms = browser->priv;
664661
struct symbol *sym = ms->sym;
665662
char symbol_dso[SYM_TITLE_MAX_SIZE];
666663

667664
if (ui_browser__show(browser, title, help) < 0)
668665
return -1;
669666

670-
sym_title(sym, ms->map, symbol_dso, sizeof(symbol_dso), ab->opts->percent_type);
667+
sym_title(sym, ms->map, symbol_dso, sizeof(symbol_dso), annotate_opts.percent_type);
671668

672669
ui_browser__gotorc_title(browser, 0, 0);
673670
ui_browser__set_color(browser, HE_COLORSET_ROOT);
@@ -809,7 +806,7 @@ static int annotate_browser__run(struct annotate_browser *browser,
809806
annotate_browser__show(&browser->b, title, help);
810807
continue;
811808
case 'k':
812-
notes->options->show_linenr = !notes->options->show_linenr;
809+
annotate_opts.show_linenr = !annotate_opts.show_linenr;
813810
continue;
814811
case 'l':
815812
annotate_browser__show_full_location (&browser->b);
@@ -822,18 +819,18 @@ static int annotate_browser__run(struct annotate_browser *browser,
822819
ui_helpline__puts(help);
823820
continue;
824821
case 'o':
825-
notes->options->use_offset = !notes->options->use_offset;
822+
annotate_opts.use_offset = !annotate_opts.use_offset;
826823
annotation__update_column_widths(notes);
827824
continue;
828825
case 'O':
829-
if (++notes->options->offset_level > ANNOTATION__MAX_OFFSET_LEVEL)
830-
notes->options->offset_level = ANNOTATION__MIN_OFFSET_LEVEL;
826+
if (++annotate_opts.offset_level > ANNOTATION__MAX_OFFSET_LEVEL)
827+
annotate_opts.offset_level = ANNOTATION__MIN_OFFSET_LEVEL;
831828
continue;
832829
case 'j':
833-
notes->options->jump_arrows = !notes->options->jump_arrows;
830+
annotate_opts.jump_arrows = !annotate_opts.jump_arrows;
834831
continue;
835832
case 'J':
836-
notes->options->show_nr_jumps = !notes->options->show_nr_jumps;
833+
annotate_opts.show_nr_jumps = !annotate_opts.show_nr_jumps;
837834
annotation__update_column_widths(notes);
838835
continue;
839836
case '/':
@@ -897,15 +894,15 @@ static int annotate_browser__run(struct annotate_browser *browser,
897894
annotation__update_column_widths(notes);
898895
continue;
899896
case 'c':
900-
if (notes->options->show_minmax_cycle)
901-
notes->options->show_minmax_cycle = false;
897+
if (annotate_opts.show_minmax_cycle)
898+
annotate_opts.show_minmax_cycle = false;
902899
else
903-
notes->options->show_minmax_cycle = true;
900+
annotate_opts.show_minmax_cycle = true;
904901
annotation__update_column_widths(notes);
905902
continue;
906903
case 'p':
907904
case 'b':
908-
switch_percent_type(browser->opts, key == 'b');
905+
switch_percent_type(&annotate_opts, key == 'b');
909906
hists__scnprintf_title(hists, title, sizeof(title));
910907
annotate_browser__show(&browser->b, title, help);
911908
continue;
@@ -932,26 +929,23 @@ static int annotate_browser__run(struct annotate_browser *browser,
932929
}
933930

934931
int map_symbol__tui_annotate(struct map_symbol *ms, struct evsel *evsel,
935-
struct hist_browser_timer *hbt,
936-
struct annotation_options *opts)
932+
struct hist_browser_timer *hbt)
937933
{
938-
return symbol__tui_annotate(ms, evsel, hbt, opts);
934+
return symbol__tui_annotate(ms, evsel, hbt);
939935
}
940936

941937
int hist_entry__tui_annotate(struct hist_entry *he, struct evsel *evsel,
942-
struct hist_browser_timer *hbt,
943-
struct annotation_options *opts)
938+
struct hist_browser_timer *hbt)
944939
{
945940
/* reset abort key so that it can get Ctrl-C as a key */
946941
SLang_reset_tty();
947942
SLang_init_tty(0, 0, 0);
948943

949-
return map_symbol__tui_annotate(&he->ms, evsel, hbt, opts);
944+
return map_symbol__tui_annotate(&he->ms, evsel, hbt);
950945
}
951946

952947
int symbol__tui_annotate(struct map_symbol *ms, struct evsel *evsel,
953-
struct hist_browser_timer *hbt,
954-
struct annotation_options *opts)
948+
struct hist_browser_timer *hbt)
955949
{
956950
struct symbol *sym = ms->sym;
957951
struct annotation *notes = symbol__annotation(sym);
@@ -965,7 +959,6 @@ int symbol__tui_annotate(struct map_symbol *ms, struct evsel *evsel,
965959
.priv = ms,
966960
.use_navkeypressed = true,
967961
},
968-
.opts = opts,
969962
};
970963
struct dso *dso;
971964
int ret = -1, err;
@@ -996,7 +989,7 @@ int symbol__tui_annotate(struct map_symbol *ms, struct evsel *evsel,
996989
browser.b.entries = &notes->src->source,
997990
browser.b.width += 18; /* Percentage */
998991

999-
if (notes->options->hide_src_code)
992+
if (annotate_opts.hide_src_code)
1000993
ui_browser__init_asm_mode(&browser.b);
1001994

1002995
ret = annotate_browser__run(&browser, evsel, hbt);

0 commit comments

Comments
 (0)