Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1755240AbbERXlk (ORCPT ); Mon, 18 May 2015 19:41:40 -0400 Received: from mail4.hitachi.co.jp ([133.145.228.5]:39537 "EHLO mail4.hitachi.co.jp" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1754866AbbERXli (ORCPT ); Mon, 18 May 2015 19:41:38 -0400 Message-ID: <555A78AA.1040406@hitachi.com> Date: Tue, 19 May 2015 08:41:30 +0900 From: Masami Hiramatsu Organization: Hitachi, Ltd., Japan User-Agent: Mozilla/5.0 (Windows NT 6.1; WOW64; rv:31.0) Gecko/20100101 Thunderbird/31.6.0 MIME-Version: 1.0 To: Arnaldo Carvalho de Melo CC: Wang Nan , a.p.zijlstra@chello.nl, paulus@samba.org, mingo@redhat.com, namhyung@kernel.org, lizefan@huawei.com, pi3orama@163.com, linux-kernel@vger.kernel.org Subject: Re: [PATCH tip/perf/core] perf probe: Load map before glob matching References: <1431692084-46287-1-git-send-email-wangnan0@huawei.com> <55560DA1.6090909@hitachi.com> <20150515200703.GD17158@kernel.org> <555733D3.20805@hitachi.com> <20150518131717.GH15972@kernel.org> In-Reply-To: <20150518131717.GH15972@kernel.org> Content-Type: text/plain; charset=windows-1252 Content-Transfer-Encoding: 7bit Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 3629 Lines: 105 On 2015/05/18 22:17, Arnaldo Carvalho de Melo wrote: > Em Sat, May 16, 2015 at 09:10:59PM +0900, Masami Hiramatsu escreveu: >> On 2015/05/16 5:07, Arnaldo Carvalho de Melo wrote: >>> Em Sat, May 16, 2015 at 12:15:45AM +0900, Masami Hiramatsu escreveu: >>>> On 2015/05/15 21:14, Wang Nan wrote: >>>>> 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 similay, >>>>> 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. >>>> >>>> Oops, yes. But I think we'd better fix map__for_each_symbol() to call >>>> map__load() if the map is not loaded, doesn't it? >>> >>> Well, that is something for a follow up patch, I'm applying his patch as >>> it fixes a problem and is trivially correct. >> >> OK, then I'm OK for this patch. > > Ok, tranforming the above statement into an Acked-by, ok? Yes, here is my ack :) Acked-by: Masami Hiramatsu And also, I've found that including map__load() in map__for_each_symbol() is not good idea. Also I think map__for_each_symbol_by_name() should not call map__load(), since the "filter" argument will be ignored if the map is already loaded. This means that the iterated elements can be changed. So, obviously the map should be loaded before calling map__for_each_XXX. Thank you, > >> Thank you, >> >>> >>> - Arnaldo >>> >>>> Thank you, >>>> >>>>> >>>>> 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 >>>>> --- >>>>> 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++; >>>>> >>>> >> -- >> Masami HIRAMATSU >> Linux Technology Research Center, System Productivity Research Dept. >> Center for Technology Innovation - Systems Engineering >> Hitachi, Ltd., Research & Development Group >> E-mail: masami.hiramatsu.pt@hitachi.com > -- Masami HIRAMATSU Linux Technology Research Center, System Productivity Research Dept. Center for Technology Innovation - Systems Engineering Hitachi, Ltd., Research & Development Group E-mail: masami.hiramatsu.pt@hitachi.com -- 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/