Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1753525AbbETMXu (ORCPT ); Wed, 20 May 2015 08:23:50 -0400 Received: from terminus.zytor.com ([198.137.202.10]:56709 "EHLO terminus.zytor.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751876AbbETMXs (ORCPT ); Wed, 20 May 2015 08:23:48 -0400 Date: Wed, 20 May 2015 05:23:27 -0700 From: tip-bot for Wang Nan Message-ID: Cc: acme@redhat.com, namhyung@kernel.org, linux-kernel@vger.kernel.org, masami.hiramatsu.pt@hitachi.com, paulus@samba.org, hpa@zytor.com, a.p.zijlstra@chello.nl, tglx@linutronix.de, lizefan@huawei.com, mingo@kernel.org, wangnan0@huawei.com Reply-To: wangnan0@huawei.com, mingo@kernel.org, lizefan@huawei.com, a.p.zijlstra@chello.nl, tglx@linutronix.de, hpa@zytor.com, masami.hiramatsu.pt@hitachi.com, linux-kernel@vger.kernel.org, paulus@samba.org, namhyung@kernel.org, acme@redhat.com In-Reply-To: <1431692084-46287-1-git-send-email-wangnan0@huawei.com> References: <1431692084-46287-1-git-send-email-wangnan0@huawei.com> To: linux-tip-commits@vger.kernel.org Subject: [tip:perf/core] perf probe: Load map before glob matching Git-Commit-ID: 75e4a2a6af15e956993913314ced2582b350a647 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: 2425 Lines: 67 Commit-ID: 75e4a2a6af15e956993913314ced2582b350a647 Gitweb: http://git.kernel.org/tip/75e4a2a6af15e956993913314ced2582b350a647 Author: Wang Nan AuthorDate: Fri, 15 May 2015 12:14:44 +0000 Committer: Arnaldo Carvalho de Melo CommitDate: Mon, 18 May 2015 10:16:48 -0300 perf probe: Load map before glob matching Commit 4c859351226c920b227fec040a3b447f0d482af3 ("perf probe: Support glob wildcards for function name") introduces a problem: # /root/perf probe kmem_cache_free Failed to find symbol kmem_cache_free in kernel Error: Failed to add events. The reason is the replacement of map__for_each_symbol_by_name() (by map__for_each_symbol()). Although their names are similar, map__for_each_symbol doesn't call map__load() and dso__sort_by_name() before searching. The missing of map__load() causes this problem because it search symbol before load dso map. This patch ensures map__load() is called before using map__for_each_symbol(). After this patch: # /root/perf probe kmem_cache_free Added new event: probe:kmem_cache_free (on kmem_cache_free%return) You can now use it in all perf tools, such as: perf record -e probe:kmem_cache_free -aR sleep 1 Signed-off-by: Wang Nan Acked-by: Masami Hiramatsu Cc: Namhyung Kim Cc: Paul Mackerras Cc: Peter Zijlstra Cc: Zefan Li Cc: pi3orama@163.com Link: http://lkml.kernel.org/r/1431692084-46287-1-git-send-email-wangnan0@huawei.com Signed-off-by: Arnaldo Carvalho de Melo --- tools/perf/util/probe-event.c | 3 +++ 1 file changed, 3 insertions(+) diff --git a/tools/perf/util/probe-event.c b/tools/perf/util/probe-event.c index 2399dc4..1faa1e6 100644 --- a/tools/perf/util/probe-event.c +++ b/tools/perf/util/probe-event.c @@ -2499,6 +2499,9 @@ static int find_probe_functions(struct map *map, char *name) struct symbol *sym; struct rb_node *tmp; + if (map__load(map, NULL) < 0) + return 0; + map__for_each_symbol(map, sym, tmp) { if (strglobmatch(sym->name, name)) found++; -- 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/