Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1753486AbbHVGza (ORCPT ); Sat, 22 Aug 2015 02:55:30 -0400 Received: from terminus.zytor.com ([198.137.202.10]:60178 "EHLO terminus.zytor.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751469AbbHVGz3 (ORCPT ); Sat, 22 Aug 2015 02:55:29 -0400 Date: Fri, 21 Aug 2015 23:54:27 -0700 From: tip-bot for Wang Nan Message-ID: Cc: mingo@kernel.org, dsahern@gmail.com, daniel@iogearbox.net, linux-kernel@vger.kernel.org, hpa@zytor.com, acme@redhat.com, masami.hiramatsu.pt@hitachi.com, tglx@linutronix.de, xiakaixu@huawei.com, a.p.zijlstra@chello.nl, lizefan@huawei.com, wangnan0@huawei.com, hekuang@huawei.com, jolsa@kernel.org, brendan.d.gregg@gmail.com, namhyung@kernel.org, ast@plumgrid.com Reply-To: a.p.zijlstra@chello.nl, lizefan@huawei.com, wangnan0@huawei.com, xiakaixu@huawei.com, masami.hiramatsu.pt@hitachi.com, tglx@linutronix.de, mingo@kernel.org, dsahern@gmail.com, hpa@zytor.com, daniel@iogearbox.net, linux-kernel@vger.kernel.org, acme@redhat.com, namhyung@kernel.org, ast@plumgrid.com, brendan.d.gregg@gmail.com, hekuang@huawei.com, jolsa@kernel.org In-Reply-To: <1440151770-129878-2-git-send-email-wangnan0@huawei.com> References: <1440151770-129878-2-git-send-email-wangnan0@huawei.com> To: linux-tip-commits@vger.kernel.org Subject: [tip:perf/core] perf probe: Try to use symbol table if searching debug info failed Git-Commit-ID: 1c0bd0e891aaed0219010bfe79b32e1b0b82d662 X-Mailer: tip-git-log-daemon Robot-ID: Robot-Unsubscribe: Contact to get blacklisted from these emails MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Content-Type: text/plain; charset=UTF-8 Content-Disposition: inline Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 4213 Lines: 104 Commit-ID: 1c0bd0e891aaed0219010bfe79b32e1b0b82d662 Gitweb: http://git.kernel.org/tip/1c0bd0e891aaed0219010bfe79b32e1b0b82d662 Author: Wang Nan AuthorDate: Fri, 21 Aug 2015 10:09:02 +0000 Committer: Arnaldo Carvalho de Melo CommitDate: Fri, 21 Aug 2015 12:57:20 -0300 perf probe: Try to use symbol table if searching debug info failed A problem can occur in a statically linked perf when vmlinux can be found: # perf probe --add sys_epoll_pwait probe-definition(0): sys_epoll_pwait symbol:sys_epoll_pwait file:(null) line:0 offset:0 return:0 lazy:(null) 0 arguments Looking at the vmlinux_path (7 entries long) Using /lib/modules/4.2.0-rc1+/build/vmlinux for symbols Open Debuginfo file: /lib/modules/4.2.0-rc1+/build/vmlinux Try to find probe point from debuginfo. Symbol sys_epoll_pwait address found : ffffffff8122bd40 Matched function: SyS_epoll_pwait Failed to get call frame on 0xffffffff8122bd40 An error occurred in debuginfo analysis (-2). Error: Failed to add events. Reason: No such file or directory (Code: -2) The reason is caused by libdw that, if libdw is statically linked, it can't load libebl_{arch}.so reliable. In this case it is still possible to get the address from /proc/kalksyms. However, perf tries that only when libdw returns -EBADF. This patch gives it another chance to utilize symbol table, even if libdw returns an error code other than -EBADF. After applying this patch: # perf probe -nv --add sys_epoll_pwait probe-definition(0): sys_epoll_pwait symbol:sys_epoll_pwait file:(null) line:0 offset:0 return:0 lazy:(null) 0 arguments Looking at the vmlinux_path (7 entries long) Using /lib/modules/4.2.0-rc1+/build/vmlinux for symbols Open Debuginfo file: /lib/modules/4.2.0-rc1+/build/vmlinux Try to find probe point from debuginfo. Symbol sys_epoll_pwait address found : ffffffff8122bd40 Matched function: SyS_epoll_pwait Failed to get call frame on 0xffffffff8122bd40 An error occurred in debuginfo analysis (-2). Trying to use symbols. Opening /sys/kernel/debug/tracing/kprobe_events write=1 Added new event: Writing event: p:probe/sys_epoll_pwait _text+2276672 probe:sys_epoll_pwait (on sys_epoll_pwait) You can now use it in all perf tools, such as: perf record -e probe:sys_epoll_pwait -aR sleep 1 Although libdw returns an error (Failed to get call frame), perf tries symbol table and finally gets correct address. Signed-off-by: Wang Nan Cc: Alexei Starovoitov Cc: Brendan Gregg Cc: Daniel Borkmann Cc: David Ahern Cc: He Kuang Cc: Jiri Olsa Cc: Kaixu Xia Cc: Masami Hiramatsu Cc: Namhyung Kim Cc: Peter Zijlstra Cc: Zefan Li Cc: pi3orama@163.com Link: http://lkml.kernel.org/r/1440151770-129878-2-git-send-email-wangnan0@huawei.com Signed-off-by: Arnaldo Carvalho de Melo --- tools/perf/util/probe-event.c | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/tools/perf/util/probe-event.c b/tools/perf/util/probe-event.c index fe4941a..f07374b 100644 --- a/tools/perf/util/probe-event.c +++ b/tools/perf/util/probe-event.c @@ -705,9 +705,10 @@ static int try_to_find_probe_trace_events(struct perf_probe_event *pev, } /* Error path : ntevs < 0 */ pr_debug("An error occurred in debuginfo analysis (%d).\n", ntevs); - if (ntevs == -EBADF) { - pr_warning("Warning: No dwarf info found in the vmlinux - " - "please rebuild kernel with CONFIG_DEBUG_INFO=y.\n"); + if (ntevs < 0) { + if (ntevs == -EBADF) + pr_warning("Warning: No dwarf info found in the vmlinux - " + "please rebuild kernel with CONFIG_DEBUG_INFO=y.\n"); if (!need_dwarf) { pr_debug("Trying to use symbols.\n"); return 0; -- To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/