Skip to content

Commit

Permalink
perf probe: Ignore vmlinux buildid if offline kernel is given
Browse files Browse the repository at this point in the history
Ignore the buildid of running kernel when both of --definition and
--vmlinux is given because that kernel should be off-line.

This also skips post-processing of kprobe event for relocating symbol
and checking blacklist, because it can not be done on off-line kernel.

E.g. without this fix perf shows an error as below
  ----
  $ perf probe --vmlinux=./vmlinux-arm --definition do_sys_open
  ./vmlinux-arm with build id 7a1f76dd56e9c4da707cd3d6333f50748141434b not found, continuing without symbols
  Failed to find symbol do_sys_open in kernel
    Error: Failed to add events.
  ----
with this fix, we can get the definition
  ----
  $ perf probe --vmlinux=./vmlinux-arm --definition do_sys_open
  p:probe/do_sys_open do_sys_open+0
  ----

Signed-off-by: Masami Hiramatsu <[email protected]>
Cc: Jiri Olsa <[email protected]>
Cc: Peter Zijlstra <[email protected]>
Link: http://lkml.kernel.org/r/147214228193.23638.12581984840822162131.stgit@devbox
Signed-off-by: Arnaldo Carvalho de Melo <[email protected]>
  • Loading branch information
mhiramat authored and acmel committed Sep 1, 2016
1 parent 1c20b1d commit 428aff8
Show file tree
Hide file tree
Showing 4 changed files with 16 additions and 2 deletions.
2 changes: 2 additions & 0 deletions tools/perf/Documentation/perf-probe.txt
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,8 @@ OPTIONS
-k::
--vmlinux=PATH::
Specify vmlinux path which has debuginfo (Dwarf binary).
Only when using this with --definition, you can give an offline
vmlinux file.

-m::
--module=MODNAME|PATH::
Expand Down
10 changes: 9 additions & 1 deletion tools/perf/builtin-probe.c
Original file line number Diff line number Diff line change
Expand Up @@ -654,8 +654,16 @@ __cmd_probe(int argc, const char **argv, const char *prefix __maybe_unused)
return ret;
}
break;
case 'a':
case 'D':
/*
* If user gives offline vmlinux, ignore buildid, since
* --definition doesn't change running kernel.
*/
if (symbol_conf.vmlinux_name)
symbol_conf.ignore_vmlinux_buildid = true;
/* fall through */
case 'a':

/* Ensure the last given target is used */
if (params.target && !params.target_used) {
pr_err(" Error: -x/-m must follow the probe definitions.\n");
Expand Down
4 changes: 4 additions & 0 deletions tools/perf/util/probe-event.c
Original file line number Diff line number Diff line change
Expand Up @@ -674,6 +674,10 @@ post_process_kernel_probe_trace_events(struct probe_trace_event *tevs,
char *tmp;
int i, skipped = 0;

/* Skip post process if the target is an offline kernel */
if (symbol_conf.ignore_vmlinux_buildid)
return 0;

reloc_sym = kernel_get_ref_reloc_sym();
if (!reloc_sym) {
pr_warning("Relocated base symbol is not found!\n");
Expand Down
2 changes: 1 addition & 1 deletion tools/perf/util/symbol-elf.c
Original file line number Diff line number Diff line change
Expand Up @@ -732,7 +732,7 @@ int symsrc__init(struct symsrc *ss, struct dso *dso, const char *name,
}

/* Always reject images with a mismatched build-id: */
if (dso->has_build_id) {
if (dso->has_build_id && !symbol_conf.ignore_vmlinux_buildid) {
u8 build_id[BUILD_ID_SIZE];

if (elf_read_build_id(elf, build_id, BUILD_ID_SIZE) < 0) {
Expand Down

0 comments on commit 428aff8

Please sign in to comment.