public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
From: Masami Hiramatsu <mhiramat@kernel.org>
To: Arnaldo Carvalho de Melo <acme@kernel.org>
Cc: Masami Hiramatsu <mhiramat@kernel.org>,
	linux-kernel@vger.kernel.org,
	Peter Zijlstra <peterz@infradead.org>,
	Ingo Molnar <mingo@redhat.com>, Jiri Olsa <jolsa@redhat.com>
Subject: [PATCH v2 2/3] perf-probe: Ignore vmlinux buildid if offline kernel is given
Date: Fri, 26 Aug 2016 01:24:42 +0900	[thread overview]
Message-ID: <147214228193.23638.12581984840822162131.stgit@devbox> (raw)
In-Reply-To: <147214224523.23638.10155676067678947950.stgit@devbox>

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 <mhiramat@kernel.org>
---
 Changes from v1:
  - Update the condition since --definition is introduced.
  - Skip post processing because this is not running kernel.
  - Update documentation too.
---
 tools/perf/Documentation/perf-probe.txt |    2 ++
 tools/perf/builtin-probe.c              |   10 +++++++++-
 tools/perf/util/probe-event.c           |    4 ++++
 tools/perf/util/symbol-elf.c            |    2 +-
 4 files changed, 16 insertions(+), 2 deletions(-)

diff --git a/tools/perf/Documentation/perf-probe.txt b/tools/perf/Documentation/perf-probe.txt
index 56db4d4..e6c9902 100644
--- a/tools/perf/Documentation/perf-probe.txt
+++ b/tools/perf/Documentation/perf-probe.txt
@@ -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::
diff --git a/tools/perf/builtin-probe.c b/tools/perf/builtin-probe.c
index 7a3d8c4..b4220cd 100644
--- a/tools/perf/builtin-probe.c
+++ b/tools/perf/builtin-probe.c
@@ -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");
diff --git a/tools/perf/util/probe-event.c b/tools/perf/util/probe-event.c
index ad7094d..8dcec0c 100644
--- a/tools/perf/util/probe-event.c
+++ b/tools/perf/util/probe-event.c
@@ -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");
diff --git a/tools/perf/util/symbol-elf.c b/tools/perf/util/symbol-elf.c
index a811c13..013cebf 100644
--- a/tools/perf/util/symbol-elf.c
+++ b/tools/perf/util/symbol-elf.c
@@ -685,7 +685,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) {

  parent reply	other threads:[~2016-08-25 16:24 UTC|newest]

Thread overview: 17+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2016-08-25 16:24 [PATCH v2 0/3] perf probe: Introduce remote cross-arch probes Masami Hiramatsu
2016-08-25 16:24 ` [PATCH v2 1/3] perf-probe: Show trace event definition Masami Hiramatsu
2016-09-05 13:22   ` [tip:perf/core] perf probe: " tip-bot for Masami Hiramatsu
2016-08-25 16:24 ` Masami Hiramatsu [this message]
2016-08-26 14:02   ` [PATCH v2 2/3] perf-probe: Ignore vmlinux buildid if offline kernel is given Masami Hiramatsu
2016-09-05 13:22   ` [tip:perf/core] perf probe: " tip-bot for Masami Hiramatsu
2016-08-25 16:24 ` [PATCH v2 3/3] perf-probe: Support probing on offline cross-arch binary Masami Hiramatsu
2016-08-31 20:54   ` Arnaldo Carvalho de Melo
2016-08-31 23:25     ` Masami Hiramatsu
2016-09-09 14:37       ` [BUG] " Arnaldo Carvalho de Melo
2016-09-09 14:59         ` [BUGFIX] " Arnaldo Carvalho de Melo
2016-09-09 15:28           ` Masami Hiramatsu
2016-09-09 15:43             ` Arnaldo Carvalho de Melo
2016-09-05 13:23   ` [tip:perf/core] perf probe: " tip-bot for Masami Hiramatsu
2016-08-26 14:57 ` [PATCH v2 4/4] perf-probe: Ignore vmlinux Build-id when offline vmlinux given Masami Hiramatsu
2016-09-05 13:23   ` [tip:perf/core] perf probe: " tip-bot for Masami Hiramatsu
2016-08-31  1:01 ` [PATCH v2 0/3] perf probe: Introduce remote cross-arch probes Masami Hiramatsu

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=147214228193.23638.12581984840822162131.stgit@devbox \
    --to=mhiramat@kernel.org \
    --cc=acme@kernel.org \
    --cc=jolsa@redhat.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=mingo@redhat.com \
    --cc=peterz@infradead.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox