From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751662AbbCTCBE (ORCPT ); Thu, 19 Mar 2015 22:01:04 -0400 Received: from szxga03-in.huawei.com ([119.145.14.66]:31892 "EHLO szxga03-in.huawei.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751107AbbCTCA7 (ORCPT ); Thu, 19 Mar 2015 22:00:59 -0400 From: He Kuang To: , , , , CC: , Subject: [PATCHv2] perf probe: Fix failure to add multiple probes without debuginfo Date: Fri, 20 Mar 2015 09:56:56 +0800 Message-ID: <1426816616-2394-1-git-send-email-hekuang@huawei.com> X-Mailer: git-send-email 2.3.3.220.g9ab698f In-Reply-To: <20150319135919.GG2983@kernel.org> References: <20150319135919.GG2983@kernel.org> MIME-Version: 1.0 Content-Type: text/plain X-Originating-IP: [10.107.197.189] X-CFilter-Loop: Reflected X-Mirapoint-Virus-RAPID-Raw: score=unknown(0), refid=str=0001.0A020203.550B7F59.0023,ss=1,re=0.001,recu=0.000,reip=0.000,cl=1,cld=1,fgs=0, ip=0.0.0.0, so=2013-05-26 15:14:31, dmn=2013-03-21 17:37:32 X-Mirapoint-Loop-Id: 352242729e58b0ff33387036c309b088 Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 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 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; -- 2.3.3.220.g9ab698f