From: Namhyung Kim <namhyung@kernel.org>
To: Arnaldo Carvalho de Melo <acme@kernel.org>
Cc: Ingo Molnar <mingo@kernel.org>,
Peter Zijlstra <a.p.zijlstra@chello.nl>,
Jiri Olsa <jolsa@redhat.com>, LKML <linux-kernel@vger.kernel.org>,
David Ahern <dsahern@gmail.com>, Kan Liang <kan.liang@intel.com>,
Frederic Weisbecker <fweisbec@gmail.com>,
Andi Kleen <andi@firstfloor.org>, Wang Nan <wangnan0@huawei.com>
Subject: [PATCH 2/3] perf callchain: Stop resolving callchains after invalid address
Date: Thu, 26 Nov 2015 16:08:19 +0900 [thread overview]
Message-ID: <1448521700-32062-2-git-send-email-namhyung@kernel.org> (raw)
In-Reply-To: <1448521700-32062-1-git-send-email-namhyung@kernel.org>
Unwinding optimized binaries using frame pointer gives garbage. Check
callchain address and stop if it's under vm.mmap_min_addr sysctl value.
Before:
$ perf report --stdio --no-children -g callee
...
1.37% perf [kernel.vmlinux] [k] smp_call_function_single
|
---smp_call_function_single
_perf_event_enable
perf_event_for_each_child
perf_ioctl
do_vfs_ioctl
sys_ioctl
entry_SYSCALL_64_fastpath
__GI___ioctl
0
0
0x1c5aa70
0x1c5b910
0x1c5aa70
0x1c5b910
0x1c5aa70
0x1c5b910
0x1c5aa70
0x1c5b910
0x1c5aa70
0x1c5b910
...
After:
$ perf report --stdio --no-children -g callee
...
1.37% perf [kernel.vmlinux] [k] smp_call_function_single
|
---smp_call_function_single
_perf_event_enable
perf_event_for_each_child
perf_ioctl
do_vfs_ioctl
sys_ioctl
entry_SYSCALL_64_fastpath
__GI___ioctl
$ perf report --stdio --no-children -g caller
...
1.37% perf [kernel.vmlinux] [k] smp_call_function_single
|
---__GI__ioctl
entry_SYSCALL_64_fastpath
sys_ioctl
do_vfs_ioctl
perf_ioctl
perf_event_for_each_child
_perf_event_enable
smp_call_function_single
Signed-off-by: Namhyung Kim <namhyung@kernel.org>
---
tools/perf/perf.c | 6 ++++++
tools/perf/util/machine.c | 13 +++++++++++++
tools/perf/util/util.c | 1 +
tools/perf/util/util.h | 1 +
4 files changed, 21 insertions(+)
diff --git a/tools/perf/perf.c b/tools/perf/perf.c
index 4bee53c3f796..0075a6d38e3a 100644
--- a/tools/perf/perf.c
+++ b/tools/perf/perf.c
@@ -18,6 +18,7 @@
#include "util/bpf-loader.h"
#include "util/debug.h"
#include <api/fs/tracing_path.h>
+#include <api/fs/fs.h>
#include <pthread.h>
const char perf_usage_string[] =
@@ -528,11 +529,16 @@ int main(int argc, const char **argv)
{
const char *cmd;
char sbuf[STRERR_BUFSIZE];
+ int min_addr;
/* The page_size is placed in util object. */
page_size = sysconf(_SC_PAGE_SIZE);
cacheline_size = sysconf(_SC_LEVEL1_DCACHE_LINESIZE);
+ if (sysctl__read_int("vm/mmap_min_addr", &min_addr) < 0)
+ min_addr = page_size;
+ mmap_min_addr = min_addr;
+
cmd = perf_extract_argv0_path(argv[0]);
if (!cmd)
cmd = "perf-help";
diff --git a/tools/perf/util/machine.c b/tools/perf/util/machine.c
index 7f5071a4d9aa..0a2f35e0d737 100644
--- a/tools/perf/util/machine.c
+++ b/tools/perf/util/machine.c
@@ -1860,6 +1860,19 @@ static int thread__resolve_callchain_sample(struct thread *thread,
#endif
ip = chain->ips[j];
+ /*
+ * Callchain value under mmap_min_addr means it's broken
+ * or the end of callchain. Stop.
+ */
+ if (ip < mmap_min_addr) {
+ if (callchain_param.order == ORDER_CALLEE)
+ break;
+
+ /* ignore current callchains for CALLER order */
+ callchain_cursor_reset(&callchain_cursor);
+ continue;
+ }
+
err = add_callchain_ip(thread, parent, root_al, &cpumode, ip);
if (err)
diff --git a/tools/perf/util/util.c b/tools/perf/util/util.c
index 75759aebc7b8..8e198acd9fa6 100644
--- a/tools/perf/util/util.c
+++ b/tools/perf/util/util.c
@@ -30,6 +30,7 @@ struct callchain_param callchain_param = {
*/
unsigned int page_size;
int cacheline_size;
+unsigned long mmap_min_addr;
bool test_attr__enabled;
diff --git a/tools/perf/util/util.h b/tools/perf/util/util.h
index dcc659017976..506d4dbb58be 100644
--- a/tools/perf/util/util.h
+++ b/tools/perf/util/util.h
@@ -281,6 +281,7 @@ void sighandler_dump_stack(int sig);
extern unsigned int page_size;
extern int cacheline_size;
+extern unsigned long mmap_min_addr;
void get_term_dimensions(struct winsize *ws);
void set_term_quiet_input(struct termios *old);
--
2.6.2
next prev parent reply other threads:[~2015-11-26 7:08 UTC|newest]
Thread overview: 22+ messages / expand[flat|nested] mbox.gz Atom feed top
2015-11-26 7:08 [PATCH 1/3] perf top: Fix freeze on --call-graph flat/folded Namhyung Kim
2015-11-26 7:08 ` Namhyung Kim [this message]
2015-11-26 7:43 ` [PATCH 2/3] perf callchain: Stop resolving callchains after invalid address Ingo Molnar
2015-11-26 14:12 ` Namhyung Kim
2015-11-27 7:48 ` Ingo Molnar
2015-11-26 13:14 ` David Ahern
2015-11-26 15:00 ` Namhyung Kim
2015-11-26 15:48 ` David Ahern
2015-11-26 15:58 ` Jiri Olsa
2015-11-26 16:19 ` Arnaldo Carvalho de Melo
2015-12-02 5:20 ` Namhyung Kim
2015-11-26 7:08 ` [PATCH 3/3] perf callchain: Honor hide_unresolved Namhyung Kim
2015-11-26 8:46 ` Jiri Olsa
2015-11-26 16:20 ` Arnaldo Carvalho de Melo
2015-11-27 7:43 ` [tip:perf/core] " tip-bot for Namhyung Kim
2015-11-26 8:38 ` [PATCH 1/3] perf top: Fix freeze on --call-graph flat/folded Jiri Olsa
2015-11-26 13:52 ` Namhyung Kim
2015-11-26 14:00 ` Jiri Olsa
2015-11-26 15:10 ` Namhyung Kim
2015-11-26 15:22 ` Jiri Olsa
2015-11-26 16:32 ` Arnaldo Carvalho de Melo
2015-11-27 7:43 ` [tip:perf/core] " tip-bot for Namhyung Kim
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=1448521700-32062-2-git-send-email-namhyung@kernel.org \
--to=namhyung@kernel.org \
--cc=a.p.zijlstra@chello.nl \
--cc=acme@kernel.org \
--cc=andi@firstfloor.org \
--cc=dsahern@gmail.com \
--cc=fweisbec@gmail.com \
--cc=jolsa@redhat.com \
--cc=kan.liang@intel.com \
--cc=linux-kernel@vger.kernel.org \
--cc=mingo@kernel.org \
--cc=wangnan0@huawei.com \
/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
Powered by JetHome