From: Arnaldo Carvalho de Melo <acme@kernel.org>
To: Ingo Molnar <mingo@kernel.org>
Cc: linux-kernel@vger.kernel.org,
Masami Hiramatsu <masami.hiramatsu.pt@hitachi.com>,
Ananth N Mavinakayanahalli <ananth@in.ibm.com>,
David Ahern <dsahern@gmail.com>,
Hemant Kumar <hemant@linux.vnet.ibm.com>,
Jiri Olsa <jolsa@redhat.com>, Namhyung Kim <namhyung@kernel.org>,
Peter Zijlstra <peterz@infradead.org>,
Arnaldo Carvalho de Melo <acme@redhat.com>
Subject: [PATCH 05/30] perf probe: Skip kernel symbols which is out of .text
Date: Fri, 8 May 2015 17:56:17 -0300 [thread overview]
Message-ID: <1431118602-5877-6-git-send-email-acme@kernel.org> (raw)
In-Reply-To: <1431118602-5877-1-git-send-email-acme@kernel.org>
From: Masami Hiramatsu <masami.hiramatsu.pt@hitachi.com>
Skip the kernel symbols which is out of .text, e.g. the functions
in .inittext. Those are found in debuginfo/kallsyms, but already
freed from memory.
e.g.
----
# perf probe vfs_caches_init
vfs_caches_init+0 is out of .text, skip it.
Probe point 'vfs_caches_init' not found.
Error: Failed to add events.
----
Signed-off-by: Masami Hiramatsu <masami.hiramatsu.pt@hitachi.com>
Tested-by: Arnaldo Carvalho de Melo <acme@redhat.com>
Cc: Ananth N Mavinakayanahalli <ananth@in.ibm.com>
Cc: David Ahern <dsahern@gmail.com>
Cc: Hemant Kumar <hemant@linux.vnet.ibm.com>
Cc: Jiri Olsa <jolsa@redhat.com>
Cc: Namhyung Kim <namhyung@kernel.org>
Cc: Peter Zijlstra <peterz@infradead.org>
Link: http://lkml.kernel.org/r/20150506124649.4961.56249.stgit@localhost.localdomain
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
---
tools/perf/util/probe-event.c | 31 ++++++++++++++++++++++++-------
1 file changed, 24 insertions(+), 7 deletions(-)
diff --git a/tools/perf/util/probe-event.c b/tools/perf/util/probe-event.c
index 4265f2e..37a3a8b 100644
--- a/tools/perf/util/probe-event.c
+++ b/tools/perf/util/probe-event.c
@@ -557,8 +557,9 @@ static int post_process_probe_trace_events(struct probe_trace_event *tevs,
bool uprobe)
{
struct ref_reloc_sym *reloc_sym;
+ u64 etext_addr;
char *tmp;
- int i;
+ int i, skipped = 0;
if (uprobe)
return add_exec_to_probe_trace_events(tevs, ntevs, module);
@@ -572,19 +573,29 @@ static int post_process_probe_trace_events(struct probe_trace_event *tevs,
pr_warning("Relocated base symbol is not found!\n");
return -EINVAL;
}
+ /* Get the address of _etext for checking non-probable text symbol */
+ etext_addr = kernel_get_symbol_address_by_name("_etext", false);
for (i = 0; i < ntevs; i++) {
if (tevs[i].point.address && !tevs[i].point.retprobe) {
- tmp = strdup(reloc_sym->name);
- if (!tmp)
- return -ENOMEM;
+ /* If we found a wrong one, mark it by NULL symbol */
+ if (etext_addr < tevs[i].point.address) {
+ pr_warning("%s+%lu is out of .text, skip it.\n",
+ tevs[i].point.symbol, tevs[i].point.offset);
+ tmp = NULL;
+ skipped++;
+ } else {
+ tmp = strdup(reloc_sym->name);
+ if (!tmp)
+ return -ENOMEM;
+ }
free(tevs[i].point.symbol);
tevs[i].point.symbol = tmp;
tevs[i].point.offset = tevs[i].point.address -
reloc_sym->unrelocated_addr;
}
}
- return 0;
+ return skipped;
}
/* Try to find perf_probe_event with debuginfo */
@@ -630,11 +641,14 @@ static int try_to_find_probe_trace_events(struct perf_probe_event *pev,
pr_debug("Found %d probe_trace_events.\n", ntevs);
ret = post_process_probe_trace_events(*tevs, ntevs,
target, pev->uprobes);
- if (ret < 0) {
+ if (ret < 0 || ret == ntevs) {
clear_probe_trace_events(*tevs, ntevs);
zfree(tevs);
}
- return ret < 0 ? ret : ntevs;
+ if (ret != ntevs)
+ return ret < 0 ? ret : ntevs;
+ ntevs = 0;
+ /* Fall through */
}
if (ntevs == 0) { /* No error but failed to find probe point. */
@@ -2403,6 +2417,9 @@ static int __add_probe_trace_events(struct perf_probe_event *pev,
pr_info("Added new event%s\n", (ntevs > 1) ? "s:" : ":");
for (i = 0; i < ntevs; i++) {
tev = &tevs[i];
+ /* Skip if the symbol is out of .text (marked previously) */
+ if (!tev->point.symbol)
+ continue;
/* Ensure that the address is NOT blacklisted */
node = kprobe_blacklist__find_by_address(&blacklist,
tev->point.address);
--
2.1.0
next prev parent reply other threads:[~2015-05-08 21:17 UTC|newest]
Thread overview: 38+ messages / expand[flat|nested] mbox.gz Atom feed top
2015-05-08 20:56 [GIT PULL 00/30] perf/core improvements and fixes Arnaldo Carvalho de Melo
2015-05-08 20:56 ` [PATCH 01/30] perf probe: Fix to close probe_events file in error Arnaldo Carvalho de Melo
2015-05-08 20:56 ` [PATCH 02/30] perf probe: Fix a typo for the flags of open Arnaldo Carvalho de Melo
2015-05-08 20:56 ` [PATCH 03/30] perf probe: Fix to return 0 when positive value returned Arnaldo Carvalho de Melo
2015-05-08 20:56 ` [PATCH 04/30] perf probe: Make --line checks validate C-style function name Arnaldo Carvalho de Melo
2015-05-08 20:56 ` Arnaldo Carvalho de Melo [this message]
2015-05-08 20:56 ` [PATCH 06/30] perf probe: Support $params special probe argument Arnaldo Carvalho de Melo
2015-05-08 20:56 ` [PATCH 07/30] perf tools: Move x86 barrier.h stuff to tools/arch/x86/include/asm/barrier.h Arnaldo Carvalho de Melo
2015-05-08 20:56 ` [PATCH 08/30] perf tools: Move powerpc barrier.h stuff to tools/arch/powerpc/include/asm/barrier.h Arnaldo Carvalho de Melo
2015-05-08 20:56 ` [PATCH 09/30] perf tools: Move s390 barrier.h stuff to tools/arch/s390/include/asm/barrier.h Arnaldo Carvalho de Melo
2015-05-08 20:56 ` [PATCH 10/30] perf tools: Move barrier() definition to tools/include/linux/compiler.h Arnaldo Carvalho de Melo
2015-05-08 20:56 ` [PATCH 11/30] tools: Adopt asm-generic/barrier.h Arnaldo Carvalho de Melo
2015-05-08 20:56 ` [PATCH 12/30] perf tools: Move sh barrier.h stuff to tools/arch/sh/include/asm/barrier.h Arnaldo Carvalho de Melo
2015-05-08 20:56 ` [PATCH 13/30] perf tools: Move sparc barrier.h stuff to tools/arch/sparc/include/asm/barrier.h Arnaldo Carvalho de Melo
2015-05-08 20:56 ` [PATCH 14/30] perf tools: Move alpha barrier.h stuff to tools/arch/alpha/include/asm/barrier.h Arnaldo Carvalho de Melo
2015-05-08 20:56 ` [PATCH 15/30] perf tools: Move ia64 barrier.h stuff to tools/arch/ia64/include/asm/barrier.h Arnaldo Carvalho de Melo
2015-05-08 20:56 ` [PATCH 16/30] perf tools: Move arm(64) barrier.h stuff to tools/arch/arm*/include/asm/barrier.h Arnaldo Carvalho de Melo
2015-05-08 20:56 ` [PATCH 17/30] perf tools: Move xtensa barrier.h stuff to tools/arch/xtensa/include/asm/barrier.h Arnaldo Carvalho de Melo
2015-05-08 20:56 ` [PATCH 18/30] perf tools: Move mips barrier.h stuff to tools/arch/mips/include/asm/barrier.h Arnaldo Carvalho de Melo
2015-05-08 20:56 ` [PATCH 19/30] perf tools: Move tile barrier.h stuff to tools/arch/tile/include/asm/barrier.h Arnaldo Carvalho de Melo
2015-05-08 20:56 ` [PATCH 20/30] perf tools: Move generic barriers out of perf-sys.h Arnaldo Carvalho de Melo
2015-05-08 20:56 ` [PATCH 21/30] tools include: Add basic atomic.h implementation from the kernel sources Arnaldo Carvalho de Melo
2015-05-08 20:56 ` [PATCH 22/30] perf tools: Use atomic_t to implement thread__{get,put} refcnt Arnaldo Carvalho de Melo
2015-05-08 20:56 ` [PATCH 23/30] perf machine: Protect the machine->threads with a rwlock Arnaldo Carvalho de Melo
2015-05-08 20:56 ` [PATCH 24/30] perf bench futex: Support parallel waker threads Arnaldo Carvalho de Melo
2015-05-08 20:56 ` [PATCH 25/30] perf bench futex: Handle spurious wakeups Arnaldo Carvalho de Melo
2015-05-08 20:56 ` [PATCH 26/30] perf probe: Use perf_probe_event.target instead of passing as an argument Arnaldo Carvalho de Melo
2015-05-08 20:56 ` [PATCH 27/30] perf probe: Introduce probe_conf global configs Arnaldo Carvalho de Melo
2015-05-08 20:56 ` [PATCH 28/30] perf probe: Add --no-inlines option to avoid searching inline functions Arnaldo Carvalho de Melo
2015-05-08 20:56 ` [PATCH 29/30] perf probe: Support glob wildcards for function name Arnaldo Carvalho de Melo
2015-05-08 20:56 ` [PATCH 30/30] perf build: Disable libdw DWARF unwind when built with NO_DWARF Arnaldo Carvalho de Melo
2015-05-09 6:22 ` [GIT PULL 00/30] perf/core improvements and fixes Ingo Molnar
2015-05-11 5:09 ` Namhyung Kim
2015-05-11 14:06 ` Arnaldo Carvalho de Melo
2015-05-14 8:23 ` Namhyung Kim
2015-05-14 13:18 ` Arnaldo Carvalho de Melo
2015-05-15 2:08 ` Namhyung Kim
2015-05-18 16:21 ` Arnaldo Carvalho de Melo
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=1431118602-5877-6-git-send-email-acme@kernel.org \
--to=acme@kernel.org \
--cc=acme@redhat.com \
--cc=ananth@in.ibm.com \
--cc=dsahern@gmail.com \
--cc=hemant@linux.vnet.ibm.com \
--cc=jolsa@redhat.com \
--cc=linux-kernel@vger.kernel.org \
--cc=masami.hiramatsu.pt@hitachi.com \
--cc=mingo@kernel.org \
--cc=namhyung@kernel.org \
--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;
as well as URLs for NNTP newsgroup(s).