From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1755580AbbCSN7Y (ORCPT ); Thu, 19 Mar 2015 09:59:24 -0400 Received: from mail.kernel.org ([198.145.29.136]:56963 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751984AbbCSN7W (ORCPT ); Thu, 19 Mar 2015 09:59:22 -0400 Date: Thu, 19 Mar 2015 10:59:19 -0300 From: Arnaldo Carvalho de Melo To: He Kuang Cc: masami.hiramatsu.pt@hitachi.com, a.p.zijlstra@chello.nl, mingo@redhat.com, namhyung@kernel.org, wangnan0@huawei.com, linux-kernel@vger.kernel.org Subject: Re: [PATCH] perf probe: Fix failure to add multiple probes without debuginfo Message-ID: <20150319135919.GG2983@kernel.org> References: <1426757023-14290-1-git-send-email-hekuang@huawei.com> <1426759324-32538-1-git-send-email-hekuang@huawei.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <1426759324-32538-1-git-send-email-hekuang@huawei.com> X-Url: http://acmel.wordpress.com User-Agent: Mutt/1.5.23 (2014-03-12) Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Em Thu, Mar 19, 2015 at 06:02:04PM +0800, He Kuang escreveu: > 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 getting ref_reloc_sym from machine->vmlinux_maps. Can't this be solved by using the kernel_get_ref_reloc_sym(void) static function in this same file? - Arnaldo > 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 > > Signed-off-by: He Kuang > --- > tools/perf/util/probe-event.c | 14 +++++++++++++- > 1 file changed, 13 insertions(+), 1 deletion(-) > > diff --git a/tools/perf/util/probe-event.c b/tools/perf/util/probe-event.c > index c5e1338..75d41ee 100644 > --- a/tools/perf/util/probe-event.c > +++ b/tools/perf/util/probe-event.c > @@ -2540,7 +2540,19 @@ static int find_probe_trace_events_from_map(struct perf_probe_event *pev, > } > > if (!pev->uprobes && !pp->retprobe) { > - kmap = map__kmap(map); > + struct machine *machine; > + struct map *vmlinux_map = NULL; > + > + if (map->groups && map->groups->machine) { > + machine = map->groups->machine; > + vmlinux_map = machine->vmlinux_maps[MAP__FUNCTION]; > + } > + > + if (vmlinux_map) > + kmap = map__kmap(vmlinux_map); > + else > + kmap = map__kmap(map); > + > reloc_sym = kmap->ref_reloc_sym; > if (!reloc_sym) { > pr_warning("Relocated base symbol is not found!\n"); > -- > 2.3.3.220.g9ab698f