Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > linux.kernel > #1470259 > unrolled thread

[PATCH v2 2/3] perf-probe: Ignore vmlinux buildid if offline kernel is given

Started byMasami Hiramatsu <mhiramat@kernel.org>
First post2016-08-25 18:30 +0200
Last post2016-09-05 15:30 +0200
Articles 3 — 2 participants

Back to article view | Back to linux.kernel

This discussion starts older than the indexed window; earlier articles aren't shown. The article labeled Started by below is the oldest one visible, not the original post.


Contents

  [PATCH v2 2/3] perf-probe: Ignore vmlinux buildid if offline kernel is given Masami Hiramatsu <mhiramat@kernel.org> - 2016-08-25 18:30 +0200
    Re: [PATCH v2 2/3] perf-probe: Ignore vmlinux buildid if offline  kernel is given Masami Hiramatsu <mhiramat@kernel.org> - 2016-08-26 16:10 +0200
    [tip:perf/core] perf probe: Ignore vmlinux buildid if offline  kernel is given tip-bot for Masami Hiramatsu <tipbot@zytor.com> - 2016-09-05 15:30 +0200

#1470259 — [PATCH v2 2/3] perf-probe: Ignore vmlinux buildid if offline kernel is given

FromMasami Hiramatsu <mhiramat@kernel.org>
Date2016-08-25 18:30 +0200
Subject[PATCH v2 2/3] perf-probe: Ignore vmlinux buildid if offline kernel is given
Message-ID<sa5Hr-3mY-9@gated-at.bofh.it>
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) {

[toc] | [next] | [standalone]


#1470736 — Re: [PATCH v2 2/3] perf-probe: Ignore vmlinux buildid if offline kernel is given

FromMasami Hiramatsu <mhiramat@kernel.org>
Date2016-08-26 16:10 +0200
SubjectRe: [PATCH v2 2/3] perf-probe: Ignore vmlinux buildid if offline kernel is given
Message-ID<sapZv-83J-1@gated-at.bofh.it>
In reply to#1470259
On Fri, 26 Aug 2016 01:24:42 +0900
Masami Hiramatsu <mhiramat@kernel.org> wrote:

> 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.

Ahh, I missed other commands which doesn't change running kernel,
like --funcs, --vars, --lines. Those also should ignore buildid if
vmlinux is given. (--add, --del, and --list depend on/change running
kernel)

I'll add a patch to handle that.

Thank you,

> 
> 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) {
> 


-- 
Masami Hiramatsu <mhiramat@kernel.org>

[toc] | [prev] | [next] | [standalone]


#1476438 — [tip:perf/core] perf probe: Ignore vmlinux buildid if offline kernel is given

Fromtip-bot for Masami Hiramatsu <tipbot@zytor.com>
Date2016-09-05 15:30 +0200
Subject[tip:perf/core] perf probe: Ignore vmlinux buildid if offline kernel is given
Message-ID<se28i-4is-33@gated-at.bofh.it>
In reply to#1470259
Commit-ID:  428aff82e92a29da0e4276623180f9a98f2d5b16
Gitweb:     http://git.kernel.org/tip/428aff82e92a29da0e4276623180f9a98f2d5b16
Author:     Masami Hiramatsu <mhiramat@kernel.org>
AuthorDate: Fri, 26 Aug 2016 01:24:42 +0900
Committer:  Arnaldo Carvalho de Melo <acme@redhat.com>
CommitDate: Thu, 1 Sep 2016 09:44:14 -0300

perf probe: Ignore vmlinux buildid if offline kernel is given

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>
Cc: Jiri Olsa <jolsa@redhat.com>
Cc: Peter Zijlstra <peterz@infradead.org>
Link: http://lkml.kernel.org/r/147214228193.23638.12581984840822162131.stgit@devbox
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
---
 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 4a49cb8..8a1e9e6 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 fbe31ef..e680371 100644
--- a/tools/perf/util/symbol-elf.c
+++ b/tools/perf/util/symbol-elf.c
@@ -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) {

[toc] | [prev] | [standalone]


Back to top | Article view | linux.kernel


csiph-web