From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752091AbbCUMTb (ORCPT ); Sat, 21 Mar 2015 08:19:31 -0400 Received: from mail4.hitachi.co.jp ([133.145.228.5]:46994 "EHLO mail4.hitachi.co.jp" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751422AbbCUMTa (ORCPT ); Sat, 21 Mar 2015 08:19:30 -0400 Message-ID: <550D61C9.10002@hitachi.com> Date: Sat, 21 Mar 2015 21:19:21 +0900 From: Masami Hiramatsu Organization: Hitachi, Ltd., Japan User-Agent: Mozilla/5.0 (Windows NT 6.1; WOW64; rv:13.0) Gecko/20120614 Thunderbird/13.0.1 MIME-Version: 1.0 To: Arnaldo Carvalho de Melo CC: He Kuang , a.p.zijlstra@chello.nl, mingo@redhat.com, namhyung@kernel.org, wangnan0@huawei.com, linux-kernel@vger.kernel.org Subject: Re: [PATCHv2] perf probe: Fix failure to add multiple probes without debuginfo References: <20150319135919.GG2983@kernel.org> <1426816616-2394-1-git-send-email-hekuang@huawei.com> <550BCF76.1000809@hitachi.com> <20150320135050.GF16485@kernel.org> In-Reply-To: <20150320135050.GF16485@kernel.org> Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: 7bit Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org (2015/03/20 22:50), Arnaldo Carvalho de Melo wrote: > Em Fri, Mar 20, 2015 at 04:42:46PM +0900, Masami Hiramatsu escreveu: >> (2015/03/20 10:56), He Kuang wrote: >>> Perf tries to find probe function addresses from map when debuginfo >>> could not be found. >>> >>> To the first added function, the value of ref_reloc_sym was set in >>> maps__set_kallsyms_ref_reloc_sym() and can be obtained from >>> host_machine->kmaps->maps. After that, new maps are added to >>> host_machine->kmaps->maps in dso__load_kcore(), all these new added maps >>> do not have a valid ref_reloc_sym. >>> >>> When adding a second function, get_target_map() may get a map without >>> valid ref_reloc_sym, and raise the error "Relocated base symbol is not >>> found". >>> >>> Fix this by using kernel_get_ref_reloc_sym() to get ref_reloc_sym. >>> >>> This problem can be reproduced as following: >>> >>> $ perf probe --add='sys_write' --add='sys_open' >>> Relocated base symbol is not found! >>> Error: Failed to add events. >>> >>> After this patch: >>> >>> $ perf probe --add='sys_write' --add='sys_open' >>> Added new event: >>> probe:sys_write (on sys_write) >>> >>> You can now use it in all perf tools, such as: >>> >>> perf record -e probe:sys_write -aR sleep 1 >>> >>> Added new event: >>> probe:sys_open (on sys_open) >>> >>> You can now use it in all perf tools, such as: >>> >>> perf record -e probe:sys_open -aR sleep 1 >>> >> >> OK, I've checked that this solve the problem :) >> >> Acked-by: Masami Hiramatsu > > Ok, next time, please consider sending a Tested-by: tag instead, if what > you did was to apply the patch, check that it fixes the problem, that > provides a stronger patch endorsement. I see. :) Tested-by: Masami Hiramatsu BTW, I've found another bug in perf probe for these sys_XXX functions. ---- # ./perf probe -vfn --add="sys_write" --add="sys_open" probe-definition(0): sys_write symbol:sys_write file:(null) line:0 offset:0 return:0 lazy:(null) 0 arguments probe-definition(1): sys_open symbol:sys_open file:(null) line:0 offset:0 return:0 lazy:(null) 0 arguments symsrc__init: cannot get elf header. Looking at the vmlinux_path (7 entries long) Using /usr/lib/debug/lib/modules/3.10.0-123.13.2.el7.x86_64/vmlinux for symbols Open Debuginfo file: /usr/lib/debug/lib/modules/3.10.0-123.13.2.el7.x86_64/vmlinux Try to find probe point from debuginfo. Symbol sys_write address found : 3b0100 Failed to find debug information for address 3b0100 Probe point 'sys_write' not found. Error: Failed to add events. Reason: No such file or directory (Code: -2) ---- Something went wrong... :-( I'll check that. Thank you, > > - Arnaldo > >> >> Thank you! >> >>> Signed-off-by: He Kuang >>> --- >>> tools/perf/util/probe-event.c | 4 +--- >>> 1 file changed, 1 insertion(+), 3 deletions(-) >>> >>> diff --git a/tools/perf/util/probe-event.c b/tools/perf/util/probe-event.c >>> index c5e1338..c1ccd6a 100644 >>> --- a/tools/perf/util/probe-event.c >>> +++ b/tools/perf/util/probe-event.c >>> @@ -2507,7 +2507,6 @@ static int find_probe_trace_events_from_map(struct perf_probe_event *pev, >>> int max_tevs, const char *target) >>> { >>> struct map *map = NULL; >>> - struct kmap *kmap = NULL; >>> struct ref_reloc_sym *reloc_sym = NULL; >>> struct symbol *sym; >>> struct probe_trace_event *tev; >>> @@ -2540,8 +2539,7 @@ static int find_probe_trace_events_from_map(struct perf_probe_event *pev, >>> } >>> >>> if (!pev->uprobes && !pp->retprobe) { >>> - kmap = map__kmap(map); >>> - reloc_sym = kmap->ref_reloc_sym; >>> + reloc_sym = kernel_get_ref_reloc_sym(); >>> if (!reloc_sym) { >>> pr_warning("Relocated base symbol is not found!\n"); >>> ret = -EINVAL; >>> >> >> >> -- >> Masami HIRAMATSU >> Software Platform Research Dept. Linux Technology Research Center >> Hitachi, Ltd., Yokohama Research Laboratory >> E-mail: masami.hiramatsu.pt@hitachi.com >> > -- Masami HIRAMATSU Software Platform Research Dept. Linux Technology Research Center Hitachi, Ltd., Yokohama Research Laboratory E-mail: masami.hiramatsu.pt@hitachi.com