* [PATCH 18/20] perf probe: Do not access kallsyms when analyzing user binaries
2014-09-17 21:24 [GIT PULL 00/20] perf/core improvements and fixes Arnaldo Carvalho de Melo
@ 2014-09-17 21:24 ` Arnaldo Carvalho de Melo
2014-09-19 5:15 ` [GIT PULL 00/20] perf/core improvements and fixes Ingo Molnar
1 sibling, 0 replies; 3+ messages in thread
From: Arnaldo Carvalho de Melo @ 2014-09-17 21:24 UTC (permalink / raw)
To: Ingo Molnar
Cc: linux-kernel, Masami Hiramatsu, david lerner, linux-perf-users,
yrl.pp-manager.tt, Arnaldo Carvalho de Melo
From: Masami Hiramatsu <masami.hiramatsu.pt@hitachi.com>
Do not access kallsyms to show available variables and show source lines
in user binaries.
This behavior always requires the root privilege when sysctl sets
kernel.kptr_restrict=1, but we don't need it just for analyzing user
binaries.
Without this patch (by normal user, kptr_restrict=1):
----
$ perf probe -x ./perf -V add_cmdname
Failed to init vmlinux path.
Error: Failed to show vars.
$ perf probe -x ./perf -L add_cmdname
Failed to init vmlinux path.
Error: Failed to show lines.
----
With this patch:
----
$ perf probe -x ./perf -V add_cmdname
Available variables at add_cmdname
@<perf_unknown_cmd_config+144>
(No matched variables)
@<list_commands_in_dir+160>
(No matched variables)
@<add_cmdname+0>
char* name
size_t len
struct cmdnames* cmds
$ perf probe -x ./perf -L add_cmdname
<add_cmdname@/home/fedora/ksrc/linux-3/tools/perf/util/help.c:0>
0 void add_cmdname(struct cmdnames *cmds, const char *name, size_t len)
1 {
2 struct cmdname *ent = malloc(sizeof(*ent) + len + 1);
4 ent->len = len;
5 memcpy(ent->name, name, len);
6 ent->name[len] = 0;
...
----
Signed-off-by: Masami Hiramatsu <masami.hiramatsu.pt@hitachi.com>
Cc: david lerner <dlernerdroid@gmail.com>
Cc: linux-perf-users@vger.kernel.org
Cc: yrl.pp-manager.tt@hitachi.com
Link: http://lkml.kernel.org/r/20140917084054.3722.73975.stgit@kbuild-f20.novalocal
[ Added missing 'bool user' argument to the !DWARF show_line_range() stub ]
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
---
tools/perf/builtin-probe.c | 3 ++-
tools/perf/util/probe-event.c | 9 +++++----
tools/perf/util/probe-event.h | 3 ++-
3 files changed, 9 insertions(+), 6 deletions(-)
diff --git a/tools/perf/builtin-probe.c b/tools/perf/builtin-probe.c
index 4d6858dbebea..04412b4770a2 100644
--- a/tools/perf/builtin-probe.c
+++ b/tools/perf/builtin-probe.c
@@ -472,7 +472,8 @@ __cmd_probe(int argc, const char **argv, const char *prefix __maybe_unused)
usage_with_options(probe_usage, options);
}
- ret = show_line_range(¶ms.line_range, params.target);
+ ret = show_line_range(¶ms.line_range, params.target,
+ params.uprobes);
if (ret < 0)
pr_err_with_code(" Error: Failed to show lines.", ret);
return ret;
diff --git a/tools/perf/util/probe-event.c b/tools/perf/util/probe-event.c
index f73595fc0627..be37b5aca335 100644
--- a/tools/perf/util/probe-event.c
+++ b/tools/perf/util/probe-event.c
@@ -697,11 +697,11 @@ end:
return ret;
}
-int show_line_range(struct line_range *lr, const char *module)
+int show_line_range(struct line_range *lr, const char *module, bool user)
{
int ret;
- ret = init_symbol_maps(false);
+ ret = init_symbol_maps(user);
if (ret < 0)
return ret;
ret = __show_line_range(lr, module);
@@ -776,7 +776,7 @@ int show_available_vars(struct perf_probe_event *pevs, int npevs,
int i, ret = 0;
struct debuginfo *dinfo;
- ret = init_symbol_maps(false);
+ ret = init_symbol_maps(pevs->uprobes);
if (ret < 0)
return ret;
@@ -822,7 +822,8 @@ static int try_to_find_probe_trace_events(struct perf_probe_event *pev,
}
int show_line_range(struct line_range *lr __maybe_unused,
- const char *module __maybe_unused)
+ const char *module __maybe_unused,
+ bool user __maybe_unused)
{
pr_warning("Debuginfo-analysis is not supported.\n");
return -ENOSYS;
diff --git a/tools/perf/util/probe-event.h b/tools/perf/util/probe-event.h
index 776c9347a3b6..e01e9943139f 100644
--- a/tools/perf/util/probe-event.h
+++ b/tools/perf/util/probe-event.h
@@ -128,7 +128,8 @@ extern int add_perf_probe_events(struct perf_probe_event *pevs, int npevs,
bool force_add);
extern int del_perf_probe_events(struct strlist *dellist);
extern int show_perf_probe_events(void);
-extern int show_line_range(struct line_range *lr, const char *module);
+extern int show_line_range(struct line_range *lr, const char *module,
+ bool user);
extern int show_available_vars(struct perf_probe_event *pevs, int npevs,
int max_probe_points, const char *module,
struct strfilter *filter, bool externs);
--
1.9.3
^ permalink raw reply related [flat|nested] 3+ messages in thread
* Re: [GIT PULL 00/20] perf/core improvements and fixes
2014-09-17 21:24 [GIT PULL 00/20] perf/core improvements and fixes Arnaldo Carvalho de Melo
2014-09-17 21:24 ` [PATCH 18/20] perf probe: Do not access kallsyms when analyzing user binaries Arnaldo Carvalho de Melo
@ 2014-09-19 5:15 ` Ingo Molnar
1 sibling, 0 replies; 3+ messages in thread
From: Ingo Molnar @ 2014-09-19 5:15 UTC (permalink / raw)
To: Arnaldo Carvalho de Melo
Cc: linux-kernel, Adrian Hunter, Alexander Yarygin, Anton Blanchard,
Avi Kivity, Chanho Park, Christian Borntraeger, Corey Ashford,
David Ahern, david lerner, Don Zickus, Frederic Weisbecker,
Jean Pihet, Jiri Olsa, John Spencer, Kyle McMartin,
linux-perf-users, Masami Hiramatsu, Michael Ellerman,
Mike Galbraith, Namhyung Kim, Paul Mackerras, Peter Zijlstra
* Arnaldo Carvalho de Melo <acme@kernel.org> wrote:
> Hi Ingo,
>
> Please consider pulling,
>
> - Arnaldo
>
> The following changes since commit c88f2096136416b261bd3647cc260935f6e95805:
>
> perf: Do not check PERF_EVENT_STATE_EXIT on syscall read path (2014-09-16 10:30:36 +0200)
>
> are available in the git repository at:
>
> git://git.kernel.org/pub/scm/linux/kernel/git/acme/linux.git tags/perf-core-for-mingo
>
> for you to fetch changes up to e5685730e2c620f97bc12380e9370e857e5bd7a7:
>
> perf record: Use ring buffer consume method to look like other tools (2014-09-17 18:01:43 -0300)
>
> ----------------------------------------------------------------
> perf/core improvements and fixes:
>
> User visible:
>
> o Add +field argument support for --sort option (Jiri Olsa)
>
> o Do not access kallsyms when analyzing user binaries with 'probe' (Masami Hiramatsu)
>
> o Ignore stripped vmlinux and fallback to kallsyms (Anton Blanchard)
>
> o Add path to Ubuntu kernel debuginfo file (Anton Blanchard)
>
> o Disable kernel symbol demangling by default (Avi Kivity)
>
> Infrastructure:
>
> o More intel PT prep work, from Adrian Hunter, including:
>
> - Let a user specify a PMU event without any config terms
> - Add perf-with-kcore script
> - Let default config be defined for a PMU
> - Add perf_pmu__scan_file()
>
> o "perf kvm stat report" improvements by Alexander Yarygin:
> o Save pid string in opts.target.pid
> o Enable the target.system_wide flag
> o Unify the title bar output
>
> o Fix build issue on powerpc when DWARF support is disabled (Anton Blanchard)
>
> o Allow to specify lib compile variable for spec usage (Jiri Olsa)
>
> o Fix build on ARM (Stephane Eranian)
>
> o Fix build on powerpc when DWARF support is disabled (Anton Blanchard)
>
> o Don't include sys/poll.h directly (Arnaldo Carvalho de Melo)
>
> o Use ring buffer consume method to look like other tools (Arnaldo Carvalho de Melo)
>
> Chanho Park (1):
> perf tools: define _DEFAULT_SOURCE for glibc_2.20
>
> o Allow to specify lib compile variable for spec usage (Jiri Olsa)
>
> o Fix GNU-only grep usage in Makefile (John Spencer)
>
> Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
>
> ----------------------------------------------------------------
> Adrian Hunter (4):
> perf tools: Let a user specify a PMU event without any config terms
> perf tools: Add perf-with-kcore script
> perf tools: Let default config be defined for a PMU
> perf tools: Add perf_pmu__scan_file()
>
> Alexander Yarygin (3):
> perf kvm stat report: Save pid string in opts.target.pid
> perf kvm stat report: Enable the target.system_wide flag
> perf kvm stat report: Unify the title bar output
>
> Anton Blanchard (3):
> perf tools powerpc: Fix build issue when DWARF support is disabled
> perf symbols: Ignore stripped vmlinux and fallback to kallsyms
> perf symbols: Add path to Ubuntu kernel debuginfo file
>
> Arnaldo Carvalho de Melo (2):
> perf tools: Don't include sys/poll.h directly
> perf record: Use ring buffer consume method to look like other tools
>
> Avi Kivity (1):
> perf tools: Disable kernel symbol demangling by default
>
> Chanho Park (1):
> perf tools: define _DEFAULT_SOURCE for glibc_2.20
>
> Jiri Olsa (2):
> perf tools: Add +field argument support for --sort option
> perf tools: Allow to specify lib compile variable for spec usage
>
> John Spencer (1):
> perf tools: Fix GNU-only grep usage in Makefile
>
> Masami Hiramatsu (2):
> perf probe: Do not access kallsyms when analyzing user binaries
> perf probe: Do not use dwfl_module_addrsym if dwarf_diename finds symbol name
>
> Stephane Eranian (1):
> perf tool: fix compilation for ARM
>
> tools/perf/.gitignore | 1 +
> tools/perf/Documentation/perf-probe.txt | 3 +
> tools/perf/Documentation/perf-report.txt | 3 +
> tools/perf/Documentation/perf-top.txt | 3 +
> tools/perf/Makefile.perf | 5 +-
> tools/perf/arch/arm/tests/dwarf-unwind.c | 1 +
> tools/perf/arch/arm/util/unwind-libunwind.c | 1 +
> tools/perf/arch/powerpc/Makefile | 2 +-
> tools/perf/bench/sched-messaging.c | 2 +-
> tools/perf/builtin-kvm.c | 23 +--
> tools/perf/builtin-probe.c | 5 +-
> tools/perf/builtin-record.c | 8 +-
> tools/perf/builtin-report.c | 2 +
> tools/perf/builtin-top.c | 4 +-
> tools/perf/config/Makefile | 12 +-
> tools/perf/config/utilities.mak | 2 +-
> tools/perf/perf-with-kcore.sh | 259 ++++++++++++++++++++++++++++
> tools/perf/tests/pmu.c | 2 +-
> tools/perf/util/kvm-stat.h | 1 -
> tools/perf/util/parse-events.c | 13 +-
> tools/perf/util/parse-events.y | 10 ++
> tools/perf/util/pmu.c | 79 +++++++--
> tools/perf/util/pmu.h | 12 +-
> tools/perf/util/probe-event.c | 9 +-
> tools/perf/util/probe-event.h | 3 +-
> tools/perf/util/probe-finder.c | 16 +-
> tools/perf/util/sort.c | 37 +++-
> tools/perf/util/symbol-elf.c | 15 +-
> tools/perf/util/symbol.c | 9 +-
> tools/perf/util/symbol.h | 1 +
> tools/perf/util/util.h | 4 +-
> 31 files changed, 487 insertions(+), 60 deletions(-)
> create mode 100644 tools/perf/perf-with-kcore.sh
Pulled into tip:perf/core, thanks a lot Arnaldo!
Ingo
^ permalink raw reply [flat|nested] 3+ messages in thread