Skip to content

Commit b0aeb45

Browse files
author
Ingo Molnar
committed
Merge tag 'perf-core-for-mingo-5.5-20191112' of git://git.kernel.org/pub/scm/linux/kernel/git/acme/linux into perf/core
Pull perf/core improvements and fixes from Arnaldo Carvalho de Melo: perf record: Ravi Bangoria: - Provide an option to print perf_event_open args and syscall return value. This was already possible using -v, but then lots of other debug info would be output as well, provide a way to show just the syscall args and return value, e.g.: # perf --debug perf-event-open=1 record perf_event_attr: size 112 { sample_period, sample_freq } 4000 sample_type IP|TID|TIME|PERIOD read_format ID disabled 1 inherit 1 <SNIP> ksymbol 1 bpf_event 1 ------------------------------------------------------------ sys_perf_event_open: pid 4308 cpu 0 group_fd -1 flags 0x8 = 4 core: - Remove map->groups, we can get that information in other ways, reduces the size of a key data structure and paves the way to have it shared by multiple threads. - Use 'struct map_symbol' in more places, where we already were using a 'struct map' + 'struct symbol', this helps passing that usual pair of information across callchain, browser code, etc. - Add 'struct map_groups' (where the map_symbol->map is) to 'struct map_symbol', to ease annotation code, for instance, where we call from functions in one map we're browsing to functions in another DSO, mapped in another 'struct map'. event parsing: Ian Rogers: - Use YYABORT to clear stack after failure, plugging leaks Signed-off-by: Arnaldo Carvalho de Melo <[email protected]> Signed-off-by: Ingo Molnar <[email protected]>
2 parents 295c52e + e1e9b78 commit b0aeb45

39 files changed

+347
-358
lines changed

tools/perf/Documentation/perf.txt

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,8 @@ OPTIONS
2424
data-convert - data convert command debug messages
2525
stderr - write debug output (option -v) to stderr
2626
in browser mode
27+
perf-event-open - Print perf_event_open() arguments and
28+
return value
2729

2830
--buildid-dir::
2931
Setup buildid cache directory. It has higher priority than

tools/perf/arch/s390/annotate/instructions.c

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ static int s390_call__parse(struct arch *arch, struct ins_operands *ops,
77
char *endptr, *tok, *name;
88
struct map *map = ms->map;
99
struct addr_map_symbol target = {
10-
.map = map,
10+
.ms = { .map = map, },
1111
};
1212

1313
tok = strchr(ops->raw, ',');
@@ -38,9 +38,9 @@ static int s390_call__parse(struct arch *arch, struct ins_operands *ops,
3838
return -1;
3939
target.addr = map__objdump_2mem(map, ops->target.addr);
4040

41-
if (map_groups__find_ams(&target) == 0 &&
42-
map__rip_2objdump(target.map, map->map_ip(target.map, target.addr)) == ops->target.addr)
43-
ops->target.sym = target.sym;
41+
if (map_groups__find_ams(ms->mg, &target) == 0 &&
42+
map__rip_2objdump(target.ms.map, map->map_ip(target.ms.map, target.addr)) == ops->target.addr)
43+
ops->target.sym = target.ms.sym;
4444

4545
return 0;
4646
}

tools/perf/builtin-annotate.c

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -83,7 +83,7 @@ static void process_basic_block(struct addr_map_symbol *start,
8383
struct addr_map_symbol *end,
8484
struct branch_flags *flags)
8585
{
86-
struct symbol *sym = start->sym;
86+
struct symbol *sym = start->ms.sym;
8787
struct annotation *notes = sym ? symbol__annotation(sym) : NULL;
8888
struct block_range_iter iter;
8989
struct block_range *entry;
@@ -301,9 +301,9 @@ static int hist_entry__tty_annotate(struct hist_entry *he,
301301
struct perf_annotate *ann)
302302
{
303303
if (!ann->use_stdio2)
304-
return symbol__tty_annotate(he->ms.sym, he->ms.map, evsel, &ann->opts);
304+
return symbol__tty_annotate(&he->ms, evsel, &ann->opts);
305305

306-
return symbol__tty_annotate2(he->ms.sym, he->ms.map, evsel, &ann->opts);
306+
return symbol__tty_annotate2(&he->ms, evsel, &ann->opts);
307307
}
308308

309309
static void hists__find_annotations(struct hists *hists,

tools/perf/builtin-kmem.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -412,8 +412,8 @@ static u64 find_callsite(struct evsel *evsel, struct perf_sample *sample)
412412
sizeof(key), callcmp);
413413
if (!caller) {
414414
/* found */
415-
if (node->map)
416-
addr = map__unmap_ip(node->map, node->ip);
415+
if (node->ms.map)
416+
addr = map__unmap_ip(node->ms.map, node->ip);
417417
else
418418
addr = node->ip;
419419

tools/perf/builtin-report.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -680,7 +680,7 @@ static int hists__resort_cb(struct hist_entry *he, void *arg)
680680
if (rep->symbol_ipc && sym && !sym->annotate2) {
681681
struct evsel *evsel = hists_to_evsel(he->hists);
682682

683-
symbol__annotate2(sym, he->ms.map, evsel,
683+
symbol__annotate2(&he->ms, evsel,
684684
&annotation__default_options, NULL);
685685
}
686686

tools/perf/builtin-sched.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2172,7 +2172,7 @@ static void save_task_callchain(struct perf_sched *sched,
21722172
if (node == NULL)
21732173
break;
21742174

2175-
sym = node->sym;
2175+
sym = node->ms.sym;
21762176
if (sym) {
21772177
if (!strcmp(sym->name, "schedule") ||
21782178
!strcmp(sym->name, "__schedule") ||

tools/perf/builtin-top.c

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -143,12 +143,12 @@ static int perf_top__parse_source(struct perf_top *top, struct hist_entry *he)
143143
return err;
144144
}
145145

146-
err = symbol__annotate(sym, map, evsel, 0, &top->annotation_opts, NULL);
146+
err = symbol__annotate(&he->ms, evsel, 0, &top->annotation_opts, NULL);
147147
if (err == 0) {
148148
top->sym_filter_entry = he;
149149
} else {
150150
char msg[BUFSIZ];
151-
symbol__strerror_disassemble(sym, map, err, msg, sizeof(msg));
151+
symbol__strerror_disassemble(&he->ms, err, msg, sizeof(msg));
152152
pr_err("Couldn't annotate %s: %s\n", sym->name, msg);
153153
}
154154

@@ -257,7 +257,7 @@ static void perf_top__show_details(struct perf_top *top)
257257
printf("Showing %s for %s\n", perf_evsel__name(top->sym_evsel), symbol->name);
258258
printf(" Events Pcnt (>=%d%%)\n", top->annotation_opts.min_pcnt);
259259

260-
more = symbol__annotate_printf(symbol, he->ms.map, top->sym_evsel, &top->annotation_opts);
260+
more = symbol__annotate_printf(&he->ms, top->sym_evsel, &top->annotation_opts);
261261

262262
if (top->evlist->enabled) {
263263
if (top->zero)

tools/perf/tests/dwarf-unwind.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,7 @@ int test_dwarf_unwind__krava_1(struct thread *thread);
5959
static int unwind_entry(struct unwind_entry *entry, void *arg)
6060
{
6161
unsigned long *cnt = (unsigned long *) arg;
62-
char *symbol = entry->sym ? entry->sym->name : NULL;
62+
char *symbol = entry->ms.sym ? entry->ms.sym->name : NULL;
6363
static const char *funcs[MAX_STACK] = {
6464
"test__arch_unwind_sample",
6565
"test_dwarf_unwind__thread",

tools/perf/ui/browsers/annotate.c

Lines changed: 12 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -410,7 +410,7 @@ static bool annotate_browser__callq(struct annotate_browser *browser,
410410
struct evsel *evsel,
411411
struct hist_browser_timer *hbt)
412412
{
413-
struct map_symbol *ms = browser->b.priv;
413+
struct map_symbol *ms = browser->b.priv, target_ms;
414414
struct disasm_line *dl = disasm_line(browser->selection);
415415
struct annotation *notes;
416416
char title[SYM_TITLE_MAX_SIZE];
@@ -430,8 +430,11 @@ static bool annotate_browser__callq(struct annotate_browser *browser,
430430
return true;
431431
}
432432

433+
target_ms.mg = ms->mg;
434+
target_ms.map = ms->map;
435+
target_ms.sym = dl->ops.target.sym;
433436
pthread_mutex_unlock(&notes->lock);
434-
symbol__tui_annotate(dl->ops.target.sym, ms->map, evsel, hbt, browser->opts);
437+
symbol__tui_annotate(&target_ms, evsel, hbt, browser->opts);
435438
sym_title(ms->sym, ms->map, title, sizeof(title), browser->opts->percent_type);
436439
ui_browser__show_title(&browser->b, title);
437440
return true;
@@ -874,7 +877,7 @@ int map_symbol__tui_annotate(struct map_symbol *ms, struct evsel *evsel,
874877
struct hist_browser_timer *hbt,
875878
struct annotation_options *opts)
876879
{
877-
return symbol__tui_annotate(ms->sym, ms->map, evsel, hbt, opts);
880+
return symbol__tui_annotate(ms, evsel, hbt, opts);
878881
}
879882

880883
int hist_entry__tui_annotate(struct hist_entry *he, struct evsel *evsel,
@@ -888,24 +891,20 @@ int hist_entry__tui_annotate(struct hist_entry *he, struct evsel *evsel,
888891
return map_symbol__tui_annotate(&he->ms, evsel, hbt, opts);
889892
}
890893

891-
int symbol__tui_annotate(struct symbol *sym, struct map *map,
892-
struct evsel *evsel,
894+
int symbol__tui_annotate(struct map_symbol *ms, struct evsel *evsel,
893895
struct hist_browser_timer *hbt,
894896
struct annotation_options *opts)
895897
{
898+
struct symbol *sym = ms->sym;
896899
struct annotation *notes = symbol__annotation(sym);
897-
struct map_symbol ms = {
898-
.map = map,
899-
.sym = sym,
900-
};
901900
struct annotate_browser browser = {
902901
.b = {
903902
.refresh = annotate_browser__refresh,
904903
.seek = ui_browser__list_head_seek,
905904
.write = annotate_browser__write,
906905
.filter = disasm_line__filter,
907906
.extra_title_lines = 1, /* for hists__scnprintf_title() */
908-
.priv = &ms,
907+
.priv = ms,
909908
.use_navkeypressed = true,
910909
},
911910
.opts = opts,
@@ -915,13 +914,13 @@ int symbol__tui_annotate(struct symbol *sym, struct map *map,
915914
if (sym == NULL)
916915
return -1;
917916

918-
if (map->dso->annotate_warned)
917+
if (ms->map->dso->annotate_warned)
919918
return -1;
920919

921-
err = symbol__annotate2(sym, map, evsel, opts, &browser.arch);
920+
err = symbol__annotate2(ms, evsel, opts, &browser.arch);
922921
if (err) {
923922
char msg[BUFSIZ];
924-
symbol__strerror_disassemble(sym, map, err, msg, sizeof(msg));
923+
symbol__strerror_disassemble(ms, err, msg, sizeof(msg));
925924
ui__error("Couldn't annotate %s:\n%s", sym->name, msg);
926925
goto out_free_offsets;
927926
}

tools/perf/ui/browsers/hists.c

Lines changed: 8 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -2405,16 +2405,15 @@ do_annotate(struct hist_browser *browser, struct popup_action *act)
24052405
static int
24062406
add_annotate_opt(struct hist_browser *browser __maybe_unused,
24072407
struct popup_action *act, char **optstr,
2408-
struct map *map, struct symbol *sym)
2408+
struct map_symbol *ms)
24092409
{
2410-
if (sym == NULL || map->dso->annotate_warned)
2410+
if (ms->sym == NULL || ms->map->dso->annotate_warned)
24112411
return 0;
24122412

2413-
if (asprintf(optstr, "Annotate %s", sym->name) < 0)
2413+
if (asprintf(optstr, "Annotate %s", ms->sym->name) < 0)
24142414
return 0;
24152415

2416-
act->ms.map = map;
2417-
act->ms.sym = sym;
2416+
act->ms = *ms;
24182417
act->fn = do_annotate;
24192418
return 1;
24202419
}
@@ -3115,20 +3114,17 @@ static int perf_evsel__hists_browse(struct evsel *evsel, int nr_events,
31153114
nr_options += add_annotate_opt(browser,
31163115
&actions[nr_options],
31173116
&options[nr_options],
3118-
bi->from.map,
3119-
bi->from.sym);
3120-
if (bi->to.sym != bi->from.sym)
3117+
&bi->from.ms);
3118+
if (bi->to.ms.sym != bi->from.ms.sym)
31213119
nr_options += add_annotate_opt(browser,
31223120
&actions[nr_options],
31233121
&options[nr_options],
3124-
bi->to.map,
3125-
bi->to.sym);
3122+
&bi->to.ms);
31263123
} else {
31273124
nr_options += add_annotate_opt(browser,
31283125
&actions[nr_options],
31293126
&options[nr_options],
3130-
browser->selection->map,
3131-
browser->selection->sym);
3127+
browser->selection);
31323128
}
31333129
skip_annotation:
31343130
nr_options += add_thread_opt(browser, &actions[nr_options],

0 commit comments

Comments
 (0)