perf probe: Load map before glob matching
PATCH 1/1 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 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.
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
--- tools/perf/util/probe-event.c | 3 +++ 1 file changed, 3 insertions(+)
tools/perf/util/probe-event.c +3 -0
@@ -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++;
Signature · 1 line
1.8.3.4
Quoted 7 lines · Wang Nan
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.
Quoted 5 lines
The reason is the replacement of
map__for_each_symbol_by_name()(bymap__for_each_symbol()). Although their names are similay,map__for_each_symboldoesn't callmap__load()anddso__sort_by_name()before searching. The missing ofmap__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?
Thank you,
Quoted 34 lines
This patch ensures
map__load()is called before usingmap__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 <[email protected]>--- tools/perf/util/probe-event.c | 3 +++ 1 file changed, 3 insertions(+)tools/perf/util/probe-event.c +3
-0@@ -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++;
Signature · 5 lines
Masami HIRAMATSU Linux Technology Research Center, System Productivity Research Dept. Center for Technology Innovation - Systems Engineering Hitachi, Ltd., Research & Development Group E-mail: [email protected]
Arnaldo Carvalho de Melo
maintainerEm Sat, May 16, 2015 at 12:15:45AM +0900, Masami Hiramatsu escreveu:
Quoted 8 lines · Wang Nan
Quoted 7 lines
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.
Quoted 8 lines
Quoted 5 lines
The reason is the replacement of
map__for_each_symbol_by_name()(bymap__for_each_symbol()). Although their names are similay,map__for_each_symboldoesn't callmap__load()anddso__sort_by_name()before searching. The missing ofmap__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 callmap__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.
- Arnaldo
Quoted 44 lines
Thank you,
Quoted 34 lines
This patch ensures
map__load()is called before usingmap__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 <[email protected]>--- tools/perf/util/probe-event.c | 3 +++ 1 file changed, 3 insertions(+)tools/perf/util/probe-event.c +3
-0@@ -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++;Signature · 5 lines
Masami HIRAMATSU Linux Technology Research Center, System Productivity Research Dept. Center for Technology Innovation - Systems Engineering Hitachi, Ltd., Research & Development Group E-mail: [email protected]
Quoted 15 lines · Arnaldo Carvalho de Melo
Em Sat, May 16, 2015 at 12:15:45AM +0900, Masami Hiramatsu escreveu:
Quoted 14 lines · Wang Nan
Quoted 12 lines
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()(bymap__for_each_symbol()). Although their names are similay,map__for_each_symboldoesn't callmap__load()anddso__sort_by_name()before searching. The missing ofmap__load()causes this problem because it search symbol before load dso map.
Quoted 5 lines
Quoted 2 lines
Oops, yes. But I think we'd better fix
map__for_each_symbol()to callmap__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.
Thank you,
Quoted 40 lines
- Arnaldo
Quoted 37 lines
Thank you,
Quoted 34 lines
This patch ensures
map__load()is called before usingmap__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 <[email protected]>--- tools/perf/util/probe-event.c | 3 +++ 1 file changed, 3 insertions(+)tools/perf/util/probe-event.c +3
-0@@ -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++;
Signature · 5 lines
Masami HIRAMATSU Linux Technology Research Center, System Productivity Research Dept. Center for Technology Innovation - Systems Engineering Hitachi, Ltd., Research & Development Group E-mail: [email protected]
Arnaldo Carvalho de Melo
maintainerEm Sat, May 16, 2015 at 09:10:59PM +0900, Masami Hiramatsu escreveu:
Quoted 16 lines · Arnaldo Carvalho de Melo
Quoted 15 lines
Em Sat, May 16, 2015 at 12:15:45AM +0900, Masami Hiramatsu escreveu:
Quoted 14 lines · Wang Nan
Quoted 12 lines
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()(bymap__for_each_symbol()). Although their names are similay,map__for_each_symboldoesn't callmap__load()anddso__sort_by_name()before searching. The missing ofmap__load()causes this problem because it search symbol before load dso map.
Quoted 7 lines
Quoted 5 lines
Quoted 2 lines
Oops, yes. But I think we'd better fix
map__for_each_symbol()to callmap__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?
Quoted 48 lines
Thank you,
Quoted 40 lines
- Arnaldo
Quoted 37 lines
Thank you,
Quoted 34 lines
This patch ensures
map__load()is called before usingmap__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 <[email protected]>--- tools/perf/util/probe-event.c | 3 +++ 1 file changed, 3 insertions(+)tools/perf/util/probe-event.c +3
-0@@ -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++;Signature · 5 lines
Masami HIRAMATSU Linux Technology Research Center, System Productivity Research Dept. Center for Technology Innovation - Systems Engineering Hitachi, Ltd., Research & Development Group E-mail: [email protected]
Masami Hiramatsu
Acked-byQuoted 20 lines · Arnaldo Carvalho de Melo
Em Sat, May 16, 2015 at 09:10:59PM +0900, Masami Hiramatsu escreveu:
Quoted 19 lines · Arnaldo Carvalho de Melo
Quoted 18 lines
Em Sat, May 16, 2015 at 12:15:45AM +0900, Masami Hiramatsu escreveu:
Quoted 16 lines · Wang Nan
Quoted 7 lines
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.Quoted 5 lines
The reason is the replacement of
map__for_each_symbol_by_name()(bymap__for_each_symbol()). Although their names are similay,map__for_each_symboldoesn't callmap__load()anddso__sort_by_name()before searching. The missing ofmap__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 callmap__load()if the map is not loaded, doesn't it?
Quoted 6 lines
Quoted 4 lines
Quoted 2 lines
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 :)
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,
Quoted 50 lines
Quoted 49 lines
Thank you,
Quoted 40 lines
- Arnaldo
Quoted 37 lines
Thank you,
Quoted 34 lines
This patch ensures
map__load()is called before usingmap__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 <[email protected]>--- tools/perf/util/probe-event.c | 3 +++ 1 file changed, 3 insertions(+)tools/perf/util/probe-event.c +3
-0@@ -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++;Signature · 5 lines
Masami HIRAMATSU Linux Technology Research Center, System Productivity Research Dept. Center for Technology Innovation - Systems Engineering Hitachi, Ltd., Research & Development Group E-mail: [email protected]
Signature · 5 lines
Masami HIRAMATSU Linux Technology Research Center, System Productivity Research Dept. Center for Technology Innovation - Systems Engineering Hitachi, Ltd., Research & Development Group E-mail: [email protected]
Arnaldo Carvalho de Melo
maintainerEm Tue, May 19, 2015 at 08:41:30AM +0900, Masami Hiramatsu escreveu:
Quoted 12 lines · Arnaldo Carvalho de Melo
Quoted 5 lines
Em Sat, May 16, 2015 at 09:10:59PM +0900, Masami Hiramatsu escreveu:
Quoted 2 lines · Arnaldo Carvalho de Melo
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 <[email protected]>
Quoted 6 lines
And also, I've found that including
map__load()inmap__for_each_symbol()is not good idea. Also I thinkmap__for_each_symbol_by_name()should not callmap__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 callingmap__for_each_XXX.
Right, agreed with your comments, and that filter thing needs moving to some other suitable place, like setting a filter at symbol system start, etc.
- Arnaldo
Quoted 60 lines
Thank you,
Quoted 50 lines
Quoted 49 lines
Thank you,
Quoted 40 lines
- Arnaldo
Quoted 37 lines
Thank you,
Quoted 34 lines
This patch ensures
map__load()is called before usingmap__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 <[email protected]>--- tools/perf/util/probe-event.c | 3 +++ 1 file changed, 3 insertions(+)tools/perf/util/probe-event.c +3
-0@@ -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++;Signature · 5 lines
Masami HIRAMATSU Linux Technology Research Center, System Productivity Research Dept. Center for Technology Innovation - Systems Engineering Hitachi, Ltd., Research & Development Group E-mail: [email protected]Signature · 5 lines
Masami HIRAMATSU Linux Technology Research Center, System Productivity Research Dept. Center for Technology Innovation - Systems Engineering Hitachi, Ltd., Research & Development Group E-mail: [email protected]
tip-bot for Wang Nan
merge botperf probe: Load map before glob matching
Commit-ID: 75e4a2a6af15e956993913314ced2582b350a647 Gitweb: http://git.kernel.org/tip/75e4a2a6af15e956993913314ced2582b350a647 Author: Wang Nan <[email protected]> AuthorDate: Fri, 15 May 2015 12:14:44 +0000 Committer: Arnaldo Carvalho de Melo <[email protected]> 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
--- tools/perf/util/probe-event.c | 3 +++ 1 file changed, 3 insertions(+)
tools/perf/util/probe-event.c +3 -0
@@ -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++;