perf/probe: Additional fixes for range only functions
cover perf/probe: Additional fixes for range only functions
Hi Arnaldo,
Here are some bugfixes for the bugs you found in previous series and similar one.
I found that there are some dwarf_entrypc() related bugs in perf probe and fixed all except one special add-hoc code in convert_variable_location()(*).
This time I embedded before-and-after examples in each commit. Please check it how to reproduce it.
(*) This had been introduced for fixup fentry related gcc bug, see commit 3d918a12a1b3 ("perf probe: Find fentry mcount fuzzed parameter location") for detail. Nowadays gcc already fixed this issue and this seems like a dead code. Moreover, it is not sure such old gcc can generate DIE without entry_pc attribute. So I decided not to touch it.
Thank you,
---
Masami Hiramatsu (6):
perf/probe: Fix wrong address verification
perf/probe: Fix to probe a function which has no entry pc perf/probe: Fix to probe an inline function which has no entry pc perf/probe: Fix to list probe event with correct line number perf/probe: Fix to show inlined function callsite without entry_pc perf/probe: Fix to show ranges of variables in functions without entry_pc
tools/perf/util/dwarf-aux.c | 6 +++--- tools/perf/util/probe-finder.c | 40 ++++++++++++++-------------------------- 2 files changed, 17 insertions(+), 29 deletions(-)
--
Masami Hiramatsu (Linaro) <[email protected]>
PATCH 1/6 perf/probe: Fix wrong address verification
Since there are some DIE which has only ranges instead of the combination of entrypc/highpc, address verification must use dwarf_haspc() instead of dwarf_entrypc/dwarf_highpc.
Also, the ranges only DIE will have a partial code in different section (e.g. unlikely code will be in text.unlikely as "FUNC.cold" symbol). In that case, we can not use dwarf_entrypc() or die_entrypc(), because the offset from original DIE can be a minus value.
Instead, this simply gets the symbol and offset from symtab.
Without this patch;
# tools/perf/perf probe -D clear_tasks_mm_cpumask:1
Failed to get entry address of clear_tasks_mm_cpumask
Error: Failed to add events.And with this patch
# tools/perf/perf probe -D clear_tasks_mm_cpumask:1 p:probe/clear_tasks_mm_cpumask clear_tasks_mm_cpumask+0 p:probe/clear_tasks_mm_cpumask_1 clear_tasks_mm_cpumask+5 p:probe/clear_tasks_mm_cpumask_2 clear_tasks_mm_cpumask+8 p:probe/clear_tasks_mm_cpumask_3 clear_tasks_mm_cpumask+16 p:probe/clear_tasks_mm_cpumask_4 clear_tasks_mm_cpumask+82
--- tools/perf/util/probe-finder.c | 32 ++++++++++---------------------- 1 file changed, 10 insertions(+), 22 deletions(-)
tools/perf/util/probe-finder.c +10 -22
@@ -604,38 +604,26 @@ static int convert_to_trace_point(Dwarf_Die *sp_die, Dwfl_Module *mod,const char *function, struct probe_trace_point *tp) { - Dwarf_Addr eaddr, highaddr; + Dwarf_Addr eaddr;GElf_Sym sym;const char *symbol;/* Verify the address is correct */ -if (dwarf_entrypc (sp_die, &eaddr) !=0 ) { -pr_warning ("Failed to get entry address of %s\n" , -dwarf_diename (sp_die)); -return -ENOENT ; - } -if (dwarf_highpc (sp_die, &highaddr) !=0 ) { -pr_warning ("Failed to get end address of %s\n" , -dwarf_diename (sp_die)); -return -ENOENT ; - } -if (paddr > highaddr) { -pr_warning ("Offset specified is greater than size of %s\n" , +if (!dwarf_haspc (sp_die, paddr)) { +pr_warning ("Specified offset is out of %s\n" ,dwarf_diename (sp_die));return -EINVAL ; } - symbol =dwarf_diename (sp_die); +/* Try to get actual symbol name from symtab */ + symbol =dwfl_module_addrsym (mod, paddr, &sym,NULL );if (!symbol) { -/* Try to get the symbol name from symtab */ - symbol =dwfl_module_addrsym (mod, paddr, &sym,NULL ); -if (!symbol) { -pr_warning ("Failed to find symbol at 0x%lx\n" , - (unsigned long )paddr); -return -ENOENT ; - } - eaddr = sym.st_value; +pr_warning ("Failed to find symbol at 0x%lx\n" , + (unsigned long )paddr); +return -ENOENT ; } + eaddr = sym.st_value; + tp->offset = (unsigned long )(paddr - eaddr); tp->address = (unsigned long )paddr; tp->symbol =strdup (symbol);
Re: [BUGFIX PATCH 1/6] perf/probe: Fix wrong address verification
Em Fri, Oct 25, 2019 at 05:46:25PM +0900, Masami Hiramatsu escreveu:
Quoted 17 lines
Since there are some DIE which has only ranges instead of the combination of entrypc/highpc, address verification must use
dwarf_haspc()instead of dwarf_entrypc/dwarf_highpc.Also, the ranges only DIE will have a partial code in different section (e.g. unlikely code will be in text.unlikely as "FUNC.cold" symbol). In that case, we can not use
dwarf_entrypc()ordie_entrypc(), because the offset from original DIE can be a minus value.Instead, this simply gets the symbol and offset from symtab.
Without this patch;
# tools/perf/perf probe -D clear_tasks_mm_cpumask:1 Failed to get entry address of clear_tasks_mm_cpumask Error: Failed to add events.
Quoted 7 lines
And with this patch
# tools/perf/perf probe -D clear_tasks_mm_cpumask:1 p:probe/clear_tasks_mm_cpumask clear_tasks_mm_cpumask+0 p:probe/clear_tasks_mm_cpumask_1 clear_tasks_mm_cpumask+5 p:probe/clear_tasks_mm_cpumask_2 clear_tasks_mm_cpumask+8 p:probe/clear_tasks_mm_cpumask_3 clear_tasks_mm_cpumask+16 p:probe/clear_tasks_mm_cpumask_4 clear_tasks_mm_cpumask+82
Ok, so this just asks for the definition, but doesn't try to actually _use_ it, which I did and it fails:
[root@quaco tracebuffer]# perf probe -D clear_tasks_mm_cpumask:1 p:probe/clear_tasks_mm_cpumask _text+919968 p:probe/clear_tasks_mm_cpumask_1 _text+919973 p:probe/clear_tasks_mm_cpumask_2 _text+919976 [root@quaco tracebuffer]#
[root@quaco tracebuffer]# perf probe clear_tasks_mm_cpumask Probe point 'clear_tasks_mm_cpumask' not found.
Error: Failed to add events.
[root@quaco tracebuffer]#
So I'll tentatively continue to apply the other patches in this series, maybe one of them will fix this.
- Arnaldo
Quoted 60 lines
Reported-by Arnaldo Carvalho de Melo <[email protected]>Fixes 576b523721b7 ("perf probe: Fix probing symbols with optimization suffix")Signed-off-by Masami Hiramatsu <[email protected]>--- tools/perf/util/probe-finder.c | 32 ++++++++++---------------------- 1 file changed, 10 insertions(+), 22 deletions(-)tools/perf/util/probe-finder.c +10
-22@@ -604,38 +604,26 @@ static int convert_to_trace_point(Dwarf_Die *sp_die, Dwfl_Module *mod,const char *function, struct probe_trace_point *tp) { - Dwarf_Addr eaddr, highaddr; + Dwarf_Addr eaddr;GElf_Sym sym;const char *symbol;/* Verify the address is correct */ -if (dwarf_entrypc (sp_die, &eaddr) !=0 ) { -pr_warning ("Failed to get entry address of %s\n" , -dwarf_diename (sp_die)); -return -ENOENT ; - } -if (dwarf_highpc (sp_die, &highaddr) !=0 ) { -pr_warning ("Failed to get end address of %s\n" , -dwarf_diename (sp_die)); -return -ENOENT ; - } -if (paddr > highaddr) { -pr_warning ("Offset specified is greater than size of %s\n" , +if (!dwarf_haspc (sp_die, paddr)) { +pr_warning ("Specified offset is out of %s\n" ,dwarf_diename (sp_die));return -EINVAL ; } - symbol =dwarf_diename (sp_die); +/* Try to get actual symbol name from symtab */ + symbol =dwfl_module_addrsym (mod, paddr, &sym,NULL );if (!symbol) { -/* Try to get the symbol name from symtab */ - symbol =dwfl_module_addrsym (mod, paddr, &sym,NULL ); -if (!symbol) { -pr_warning ("Failed to find symbol at 0x%lx\n" , - (unsigned long )paddr); -return -ENOENT ; - } - eaddr = sym.st_value; +pr_warning ("Failed to find symbol at 0x%lx\n" , + (unsigned long )paddr); +return -ENOENT ; } + eaddr = sym.st_value; + tp->offset = (unsigned long )(paddr - eaddr); tp->address = (unsigned long )paddr; tp->symbol =strdup (symbol);
Signature · 1 line
- Arnaldo
Re: [BUGFIX PATCH 1/6] perf/probe: Fix wrong address verification
Hi,
Quoted 39 lines · On Fri, 25 Oct 2019 09:14:48 -0300 Arnaldo Carvalho de Melo <[email protected]>…
Em Fri, Oct 25, 2019 at 05:46:25PM +0900, Masami Hiramatsu escreveu:
Quoted 17 lines
Since there are some DIE which has only ranges instead of the combination of entrypc/highpc, address verification must use
dwarf_haspc()instead of dwarf_entrypc/dwarf_highpc.Also, the ranges only DIE will have a partial code in different section (e.g. unlikely code will be in text.unlikely as "FUNC.cold" symbol). In that case, we can not use
dwarf_entrypc()ordie_entrypc(), because the offset from original DIE can be a minus value.Instead, this simply gets the symbol and offset from symtab.
Without this patch;
# tools/perf/perf probe -D clear_tasks_mm_cpumask:1 Failed to get entry address of clear_tasks_mm_cpumask Error: Failed to add events.Quoted 7 lines
And with this patch
# tools/perf/perf probe -D clear_tasks_mm_cpumask:1 p:probe/clear_tasks_mm_cpumask clear_tasks_mm_cpumask+0 p:probe/clear_tasks_mm_cpumask_1 clear_tasks_mm_cpumask+5 p:probe/clear_tasks_mm_cpumask_2 clear_tasks_mm_cpumask+8 p:probe/clear_tasks_mm_cpumask_3 clear_tasks_mm_cpumask+16 p:probe/clear_tasks_mm_cpumask_4 clear_tasks_mm_cpumask+82Ok, so this just asks for the definition, but doesn't try to actually _use_ it, which I did and it fails:
[root@quaco tracebuffer]# perf probe -D clear_tasks_mm_cpumask:1 p:probe/clear_tasks_mm_cpumask _text+919968 p:probe/clear_tasks_mm_cpumask_1 _text+919973 p:probe/clear_tasks_mm_cpumask_2 _text+919976 [root@quaco tracebuffer]#
[root@quaco tracebuffer]# perf probeclear_tasks_mm_cpumaskProbe point 'clear_tasks_mm_cpumask' not found.
Error: Failed to add events.
[root@quaco tracebuffer]#
Quoted 2 lines
So I'll tentatively continue to apply the other patches in this series, maybe one of them will fix this.
Yes, it should be fixed by [2/6] :)
Actually, a probe point with offset line and no-offset are handled a bit differently.
Thank you,
Signature · 1 line
Masami Hiramatsu <[email protected]>
Re: [BUGFIX PATCH 1/6] perf/probe: Fix wrong address verification
Em Fri, Oct 25, 2019 at 09:36:33PM +0900, Masami Hiramatsu escreveu:
Quoted 44 lines
Hi,
Quoted 39 lines · On Fri, 25 Oct 2019 09:14:48 -0300 Arnaldo Carvalho de Melo <[email protected]>…
Em Fri, Oct 25, 2019 at 05:46:25PM +0900, Masami Hiramatsu escreveu:
Quoted 17 lines
Since there are some DIE which has only ranges instead of the combination of entrypc/highpc, address verification must use
dwarf_haspc()instead of dwarf_entrypc/dwarf_highpc.Also, the ranges only DIE will have a partial code in different section (e.g. unlikely code will be in text.unlikely as "FUNC.cold" symbol). In that case, we can not use
dwarf_entrypc()ordie_entrypc(), because the offset from original DIE can be a minus value.Instead, this simply gets the symbol and offset from symtab.
Without this patch;
# tools/perf/perf probe -D clear_tasks_mm_cpumask:1 Failed to get entry address of clear_tasks_mm_cpumask Error: Failed to add events.Quoted 7 lines
And with this patch
# tools/perf/perf probe -D clear_tasks_mm_cpumask:1 p:probe/clear_tasks_mm_cpumask clear_tasks_mm_cpumask+0 p:probe/clear_tasks_mm_cpumask_1 clear_tasks_mm_cpumask+5 p:probe/clear_tasks_mm_cpumask_2 clear_tasks_mm_cpumask+8 p:probe/clear_tasks_mm_cpumask_3 clear_tasks_mm_cpumask+16 p:probe/clear_tasks_mm_cpumask_4 clear_tasks_mm_cpumask+82Ok, so this just asks for the definition, but doesn't try to actually _use_ it, which I did and it fails:
[root@quaco tracebuffer]# perf probe -D clear_tasks_mm_cpumask:1 p:probe/clear_tasks_mm_cpumask _text+919968 p:probe/clear_tasks_mm_cpumask_1 _text+919973 p:probe/clear_tasks_mm_cpumask_2 _text+919976 [root@quaco tracebuffer]#
[root@quaco tracebuffer]# perf probeclear_tasks_mm_cpumaskProbe point 'clear_tasks_mm_cpumask' not found.
Error: Failed to add events.
[root@quaco tracebuffer]#
Quoted 4 lines
Quoted 2 lines
So I'll tentatively continue to apply the other patches in this series, maybe one of them will fix this.
Yes, it should be fixed by [2/6] :)
Yeah, it is, works there, but unfortunately I couldn't see it in action even having put it successfuly into place:
[root@quaco ~]# perf probe clear_tasks_mm_cpumask:0 Added new event:
probe:clear_tasks_mm_cpumask (on clear_tasks_mm_cpumask)
You can now use it in all perf tools, such as:
perf record -e probe:clear_tasks_mm_cpumask -aR sleep 1
[root@quaco ~]# perf trace -e probe:clear_tasks_mm_cpumask/max-stack=16/
Doesn't seem to be used in x86-64...
[acme@quaco perf]$ find . -name "*.c" | xargs grep clear_tasks_mm_cpumask ./kernel/cpu.c: * clear_tasks_mm_cpumask - Safely clear tasks' mm_cpumask for a CPU ./kernel/cpu.c:void clear_tasks_mm_cpumask(int cpu)./arch/xtensa/kernel/smp.c: clear_tasks_mm_cpumask(cpu);./arch/csky/kernel/smp.c: clear_tasks_mm_cpumask(cpu);./arch/sh/kernel/smp.c: clear_tasks_mm_cpumask(cpu);./arch/arm/kernel/smp.c: clear_tasks_mm_cpumask(cpu);./arch/powerpc/mm/nohash/mmu_context.c: clear_tasks_mm_cpumask(cpu);
[acme@quaco perf]$ find . -name "*.h" | xargs grep clear_tasks_mm_cpumask ./include/linux/cpu.h:void clear_tasks_mm_cpumask(int cpu); [acme@quaco perf]$
:-)
Quoted 2 lines
Actually, a probe point with offset line and no-offset are handled a bit differently.
What is the difference? Anyway, things seem to work as advertised, so I'm happy ;-)
- Arnaldo
[tip: perf/core] perf probe: Fix wrong address verification
In reply to Masami HiramatsuThe following commit has been merged into the perf/core branch of tip:
The following commit has been merged into the perf/core branch of tip:
Commit-ID: 07d369857808b7e8e471bbbbb0074a6718f89b31 Gitweb: https://git.kernel.org/tip/07d369857808b7e8e471bbbbb0074a6718f89b31 Author: Masami Hiramatsu <[email protected]> AuthorDate: Fri, 25 Oct 2019 17:46:25 +09:00 Committer: Arnaldo Carvalho de Melo <[email protected]> CommitterDate: Wed, 06 Nov 2019 15:43:06 -03:00
perf probe: Fix wrong address verification
Since there are some DIE which has only ranges instead of the combination of entrypc/highpc, address verification must use dwarf_haspc() instead of dwarf_entrypc/dwarf_highpc.
Also, the ranges only DIE will have a partial code in different section (e.g. unlikely code will be in text.unlikely as "FUNC.cold" symbol). In that case, we can not use dwarf_entrypc() or die_entrypc(), because the offset from original DIE can be a minus value.
Instead, this simply gets the symbol and offset from symtab.
Without this patch;
# perf probe -D clear_tasks_mm_cpumask:1
Failed to get entry address of clear_tasks_mm_cpumask
Error: Failed to add events.And with this patch:
# perf probe -D clear_tasks_mm_cpumask:1 p:probe/clear_tasks_mm_cpumask clear_tasks_mm_cpumask+0 p:probe/clear_tasks_mm_cpumask_1 clear_tasks_mm_cpumask+5 p:probe/clear_tasks_mm_cpumask_2 clear_tasks_mm_cpumask+8 p:probe/clear_tasks_mm_cpumask_3 clear_tasks_mm_cpumask+16 p:probe/clear_tasks_mm_cpumask_4 clear_tasks_mm_cpumask+82
Committer testing:
I managed to reproduce the above:
[root@quaco ~]# perf probe -D clear_tasks_mm_cpumask:1 p:probe/clear_tasks_mm_cpumask _text+919968 p:probe/clear_tasks_mm_cpumask_1 _text+919973 p:probe/clear_tasks_mm_cpumask_2 _text+919976 [root@quaco ~]#
But then when trying to actually put the probe in place, it fails if I use :0 as the offset:
[root@quaco ~]# perf probe -L clear_tasks_mm_cpumask | head -5
<clear_tasks_mm_cpumask@/usr/src/debug/kernel-5.2.fc30/linux-5.2.18-200.fc30.x86_64/kernel/cpu.c:0>
0 void clear_tasks_mm_cpumask(int cpu)
1 {
2 struct task_struct *p; [root@quaco ~]# perf probe clear_tasks_mm_cpumask:0 Probe point 'clear_tasks_mm_cpumask' not found.
Error: Failed to add events.
[root@quaco
The next patch is needed to fix this case.
--- tools/perf/util/probe-finder.c | 32 ++++++++++---------------------- 1 file changed, 10 insertions(+), 22 deletions(-)
tools/perf/util/probe-finder.c +10 -22
@@ -604,38 +604,26 @@ static int convert_to_trace_point(Dwarf_Die *sp_die, Dwfl_Module *mod,const char *function, struct probe_trace_point *tp) { - Dwarf_Addr eaddr, highaddr; + Dwarf_Addr eaddr;GElf_Sym sym;const char *symbol;/* Verify the address is correct */ -if (dwarf_entrypc (sp_die, &eaddr) !=0 ) { -pr_warning ("Failed to get entry address of %s\n" , -dwarf_diename (sp_die)); -return -ENOENT ; - } -if (dwarf_highpc (sp_die, &highaddr) !=0 ) { -pr_warning ("Failed to get end address of %s\n" , -dwarf_diename (sp_die)); -return -ENOENT ; - } -if (paddr > highaddr) { -pr_warning ("Offset specified is greater than size of %s\n" , +if (!dwarf_haspc (sp_die, paddr)) { +pr_warning ("Specified offset is out of %s\n" ,dwarf_diename (sp_die));return -EINVAL ; } - symbol =dwarf_diename (sp_die); +/* Try to get actual symbol name from symtab */ + symbol =dwfl_module_addrsym (mod, paddr, &sym,NULL );if (!symbol) { -/* Try to get the symbol name from symtab */ - symbol =dwfl_module_addrsym (mod, paddr, &sym,NULL ); -if (!symbol) { -pr_warning ("Failed to find symbol at 0x%lx\n" , - (unsigned long )paddr); -return -ENOENT ; - } - eaddr = sym.st_value; +pr_warning ("Failed to find symbol at 0x%lx\n" , + (unsigned long )paddr); +return -ENOENT ; } + eaddr = sym.st_value; + tp->offset = (unsigned long )(paddr - eaddr); tp->address = (unsigned long )paddr; tp->symbol =strdup (symbol);
PATCH 2/6 perf/probe: Fix to probe a function which has no entry pc
In reply to Masami HiramatsuFix perf probe to probe a function which has no entry pc or low pc but only has ranges attribute.
probe_point_search_cb() uses dwarf_entrypc() to get the probe address, but that doesn't work for the function DIE which has only ranges attribute. Use die_entrypc() instead.
Without this fix,
# tools/perf/perf probe -k ../build-x86_64/vmlinux -D clear_tasks_mm_cpumask:0
Probe point 'clear_tasks_mm_cpumask' not found.
Error: Failed to add events.With this,
# tools/perf/perf probe -k ../build-x86_64/vmlinux -D clear_tasks_mm_cpumask:0 p:probe/clear_tasks_mm_cpumask clear_tasks_mm_cpumask+0
--- tools/perf/util/probe-finder.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
tools/perf/util/probe-finder.c +1 -1
@@ -982,7 +982,7 @@ static int probe_point_search_cb(Dwarf_Die *sp_die, void *data) param->retval =find_probe_point_by_line (pf); }else if (die_is_func_instance (sp_die)) {/* Instances always have the entry address */ -dwarf_entrypc (sp_die, &pf->addr); +die_entrypc (sp_die, &pf->addr);/* But in some case the entry address is 0 */ if (pf->addr ==0 ) { pr_debug("%s has no entry PC. Skipped\n",
[tip: perf/core] perf probe: Fix to probe a function which has no entry pc
The following commit has been merged into the perf/core branch of tip:
The following commit has been merged into the perf/core branch of tip:
Commit-ID: 5d16dbcc311d91267ddb45c6da4f187be320ecee Gitweb: https://git.kernel.org/tip/5d16dbcc311d91267ddb45c6da4f187be320ecee Author: Masami Hiramatsu <[email protected]> AuthorDate: Fri, 25 Oct 2019 17:46:34 +09:00 Committer: Arnaldo Carvalho de Melo <[email protected]> CommitterDate: Wed, 06 Nov 2019 15:43:06 -03:00
perf probe: Fix to probe a function which has no entry pc
Fix 'perf probe' to probe a function which has no entry pc or low pc but only has ranges attribute.
probe_point_search_cb() uses dwarf_entrypc() to get the probe address, but that doesn't work for the function DIE which has only ranges attribute. Use die_entrypc() instead.
Without this fix:
# perf probe -k ../build-x86_64/vmlinux -D clear_tasks_mm_cpumask:0
Probe point 'clear_tasks_mm_cpumask' not found.
Error: Failed to add events.With this:
# perf probe -k ../build-x86_64/vmlinux -D clear_tasks_mm_cpumask:0 p:probe/clear_tasks_mm_cpumask clear_tasks_mm_cpumask+0
Committer testing:
Before:
[root@quaco ~]# perf probe clear_tasks_mm_cpumask:0 Probe point 'clear_tasks_mm_cpumask' not found.
Error: Failed to add events.
[root@quaco ~]#
After:
[root@quaco ~]# perf probe clear_tasks_mm_cpumask:0 Added new event:
probe:clear_tasks_mm_cpumask (on clear_tasks_mm_cpumask)
You can now use it in all perf tools, such as:
perf record -e probe:clear_tasks_mm_cpumask -aR sleep 1
[root@quaco ~]#
Using it with 'perf trace':
[root@quaco ~]# perf trace -e probe:clear_tasks_mm_cpumask
Doesn't seem to be used in x86_64:
$ find . -name "*.c" | xargs grep clear_tasks_mm_cpumask ./kernel/cpu.c: * clear_tasks_mm_cpumask - Safely clear tasks' mm_cpumask for a CPU ./kernel/cpu.c:void clear_tasks_mm_cpumask(int cpu) ./arch/xtensa/kernel/smp.c: clear_tasks_mm_cpumask(cpu); ./arch/csky/kernel/smp.c: clear_tasks_mm_cpumask(cpu); ./arch/sh/kernel/smp.c: clear_tasks_mm_cpumask(cpu); ./arch/arm/kernel/smp.c: clear_tasks_mm_cpumask(cpu); ./arch/powerpc/mm/nohash/mmu_context.c: clear_tasks_mm_cpumask(cpu); $ find . -name "*.h" | xargs grep clear_tasks_mm_cpumask ./include/linux/cpu.h:void clear_tasks_mm_cpumask(int cpu); $ find . -name "*.S" | xargs grep clear_tasks_mm_cpumask $
--- tools/perf/util/probe-finder.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
tools/perf/util/probe-finder.c +1 -1
@@ -982,7 +982,7 @@ static int probe_point_search_cb(Dwarf_Die *sp_die, void *data) param->retval =find_probe_point_by_line (pf); }else if (die_is_func_instance (sp_die)) {/* Instances always have the entry address */ -dwarf_entrypc (sp_die, &pf->addr); +die_entrypc (sp_die, &pf->addr);/* But in some case the entry address is 0 */ if (pf->addr ==0 ) { pr_debug("%s has no entry PC. Skipped\n",
PATCH 3/6 perf/probe: Fix to probe an inline function which has no entry pc
In reply to Masami HiramatsuFix perf probe to probe an inlne function which has no entry pc or low pc but only has ranges attribute.
This seems very rare case, but I could find a few examples, as same as probe_point_search_cb(), use die_entrypc() to get the entry address in probe_point_inline_cb() too.
Without this patch,
# tools/perf/perf probe -D __amd_put_nb_event_constraints
Failed to get entry address of __amd_put_nb_event_constraints.
Probe point '__amd_put_nb_event_constraints' not found.
Error: Failed to add events.With this patch,
# tools/perf/perf probe -D __amd_put_nb_event_constraints p:probe/__amd_put_nb_event_constraints amd_put_event_constraints+43
--- tools/perf/util/probe-finder.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
tools/perf/util/probe-finder.c +1 -1
@@ -930,7 +930,7 @@ static int probe_point_inline_cb(Dwarf_Die *in_die, void *data) ret =find_probe_point_lazy (in_die, pf); else {/* Get probe address */ -if (dwarf_entrypc (in_die, &addr) !=0 ) { +if (die_entrypc (in_die, &addr) !=0 ) {pr_warning ("Failed to get entry address of %s.\n" ,dwarf_diename (in_die));return -ENOENT ;
Re: [BUGFIX PATCH 3/6] perf/probe: Fix to probe an inline function which has no entry pc
Em Fri, Oct 25, 2019 at 05:46:43PM +0900, Masami Hiramatsu escreveu:
Quoted 8 lines
Fix perf probe to probe an inlne function which has no entry pc or low pc but only has ranges attribute.
This seems very rare case, but I could find a few examples, as same as
probe_point_search_cb(), usedie_entrypc()to get the entry address inprobe_point_inline_cb()too.Without this patch,
Quoted 8 lines
# tools/perf/perf probe -D __amd_put_nb_event_constraints Failed to get entry address of __amd_put_nb_event_constraints. Probe point '__amd_put_nb_event_constraints' not found. Error: Failed to add events.With this patch,
# tools/perf/perf probe -D __amd_put_nb_event_constraints p:probe/__amd_put_nb_event_constraints amd_put_event_constraints+43
Here I got it slightly different:
Before:
[root@quaco ~]# perf probe -D __amd_put_nb_event_constraints Failed to get entry address of __amd_put_nb_event_constraints. Probe point '__amd_put_nb_event_constraints' not found.
Error: Failed to add events.
[root@quaco ~]#
After:
[root@quaco ~]# perf probe -D __amd_put_nb_event_constraints p:probe/__amd_put_nb_event_constraints _text+33789 [root@quaco ~]#
----
I'm now checking if this is because I applied patch 4/6 before 3/6
Quoted 19 lines
Fixes 4ea42b181434 ("perf: Add perf probe subcommand, a kprobe-event setup helper")Signed-off-by Masami Hiramatsu <[email protected]>--- tools/perf/util/probe-finder.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)tools/perf/util/probe-finder.c +1
-1@@ -930,7 +930,7 @@ static int probe_point_inline_cb(Dwarf_Die *in_die, void *data) ret =find_probe_point_lazy (in_die, pf); else {/* Get probe address */ -if (dwarf_entrypc (in_die, &addr) !=0 ) { +if (die_entrypc (in_die, &addr) !=0 ) {pr_warning ("Failed to get entry address of %s.\n" ,dwarf_diename (in_die));return -ENOENT ;
Signature · 1 line
- Arnaldo
Re: [BUGFIX PATCH 3/6] perf/probe: Fix to probe an inline function which has no entry pc
Em Fri, Oct 25, 2019 at 11:35:13AM -0300, Arnaldo Carvalho de Melo escreveu:
Quoted 30 lines
Em Fri, Oct 25, 2019 at 05:46:43PM +0900, Masami Hiramatsu escreveu:
Quoted 8 lines
Fix perf probe to probe an inlne function which has no entry pc or low pc but only has ranges attribute.
This seems very rare case, but I could find a few examples, as same as
probe_point_search_cb(), usedie_entrypc()to get the entry address inprobe_point_inline_cb()too.Without this patch,
Quoted 8 lines
# tools/perf/perf probe -D __amd_put_nb_event_constraints Failed to get entry address of __amd_put_nb_event_constraints. Probe point '__amd_put_nb_event_constraints' not found. Error: Failed to add events.With this patch,
# tools/perf/perf probe -D __amd_put_nb_event_constraints p:probe/__amd_put_nb_event_constraints amd_put_event_constraints+43Here I got it slightly different:
Before:
[root@quaco ~]# perf probe -D
__amd_put_nb_event_constraintsFailed to get entry address of__amd_put_nb_event_constraints. Probe point '__amd_put_nb_event_constraints' not found.
Error: Failed to add events.
[root@quaco ~]#After:
Quoted 8 lines
[root@quaco ~]# perf probe -D
__amd_put_nb_event_constraintsp:probe/__amd_put_nb_event_constraints _text+33789 [root@quaco ~]#----
I'm now checking if this is because I applied patch 4/6 before 3/6
Nope, even then:
[root@quaco ~]# perf probe -D __amd_put_nb_event_constraints p:probe/__amd_put_nb_event_constraints _text+33789 [root@quaco ~]# grep __amd_put_nb_event_constraints /proc/kallsyms [root@quaco ~]#
Ok, maybe this may help:
[root@quaco ~]# perf probe -v -D __amd_put_nb_event_constraints |& grep vmlinux Looking at the vmlinux_path (8 entries long)
Using /usr/lib/debug/lib/modules/5.2.18-200.fc30.x86_64/vmlinux for symbols Open Debuginfo file: /usr/lib/debug/lib/modules/5.2.18-200.fc30.x86_64/vmlinux [root@quaco ~]#
[root@quaco ~]# readelf -wi /usr/lib/debug/lib/modules/5.2.18-200.fc30.x86_64/vmlinux | grep __amd_put_nb_event_constraints -B1 -A7
<1><192640>: Abbrev Number: 123 (DW_TAG_subprogram)
<192641> DW_AT_name : (indirect string, offset: 0x299576): __amd_put_nb_event_constraints
<192645> DW_AT_decl_file : 1
<192646> DW_AT_decl_line : 361
<192648> DW_AT_decl_column : 13
<192649> DW_AT_prototyped : 1
<192649> DW_AT_inline : 1 (inlined)
<19264a> DW_AT_sibling : <0x192700> <2><19264e>: Abbrev Number: 38 (DW_TAG_formal_parameter)
^C
[root@quaco ~]#
Continuing to process the other patches...
- Arnaldo
Quoted 23 lines
Quoted 19 lines
Fixes 4ea42b181434 ("perf: Add perf probe subcommand, a kprobe-event setup helper")Signed-off-by Masami Hiramatsu <[email protected]>--- tools/perf/util/probe-finder.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)tools/perf/util/probe-finder.c +1
-1@@ -930,7 +930,7 @@ static int probe_point_inline_cb(Dwarf_Die *in_die, void *data) ret =find_probe_point_lazy (in_die, pf); else {/* Get probe address */ -if (dwarf_entrypc (in_die, &addr) !=0 ) { +if (die_entrypc (in_die, &addr) !=0 ) {pr_warning ("Failed to get entry address of %s.\n" ,dwarf_diename (in_die));return -ENOENT ;Signature · 1 line
- Arnaldo
Signature · 1 line
- Arnaldo
Re: [BUGFIX PATCH 3/6] perf/probe: Fix to probe an inline function which has no entry pc
Hi Arnaldo
Quoted 34 lines · On Fri, 25 Oct 2019 11:39:10 -0300 Arnaldo Carvalho de Melo <[email protected]>…
Em Fri, Oct 25, 2019 at 11:35:13AM -0300, Arnaldo Carvalho de Melo escreveu:
Quoted 33 lines
Em Fri, Oct 25, 2019 at 05:46:43PM +0900, Masami Hiramatsu escreveu:
Quoted 8 lines
Fix perf probe to probe an inlne function which has no entry pc or low pc but only has ranges attribute.
This seems very rare case, but I could find a few examples, as same as
probe_point_search_cb(), usedie_entrypc()to get the entry address inprobe_point_inline_cb()too.Without this patch,
Quoted 8 lines
# tools/perf/perf probe -D __amd_put_nb_event_constraints Failed to get entry address of __amd_put_nb_event_constraints. Probe point '__amd_put_nb_event_constraints' not found. Error: Failed to add events.With this patch,
# tools/perf/perf probe -D __amd_put_nb_event_constraints p:probe/__amd_put_nb_event_constraints amd_put_event_constraints+43Here I got it slightly different:
Before:
[root@quaco ~]# perf probe -D
__amd_put_nb_event_constraintsFailed to get entry address of__amd_put_nb_event_constraints. Probe point '__amd_put_nb_event_constraints' not found.
Error: Failed to add events.
[root@quaco ~]#After:
[root@quaco ~]# perf probe -D
__amd_put_nb_event_constraintsp:probe/__amd_put_nb_event_constraints _text+33789 [root@quaco ~]#
Ah, sorry, it was my mistake, when I copy the command, I lacked -k option, which means using offline kernel image. I'll update the patch description and resend it.
With online kernel (same buildid), perf-probe modifies the address with _text based offset for avoiding mixed up with same-name symbols. Even if there are several same-name symbols (like local functions), the "_text + offset" expression can identify one of them.
However, if the buildid of the given kernel image (specified by -k option) doesn't match, it generates event definition based on the symbol name. Hmm, I think we can use _text even with off-line kernel, I'll check it.
Quoted 4 lines
Quoted 4 lines
----
Quoted 8 lines
Quoted 1 line
I'm now checking if this is because I applied patch 4/6 before 3/6
Nope, even then:
[root@quaco ~]# perf probe -D
__amd_put_nb_event_constraintsp:probe/__amd_put_nb_event_constraints _text+33789 [root@quaco ~]# grep__amd_put_nb_event_constraints/proc/kallsyms[root@quaco ~]#
So, _text + offset is normal behavior. I'll try to renew the example with actual options. Sorry for confusing.
Thank you,
Quoted 53 lines
Ok, maybe this may help:
[root@quaco ~]# perf probe -v -D
__amd_put_nb_event_constraints|& grep vmlinux Looking at thevmlinux_path(8 entries long)
Using/usr/lib/debug/lib/modules/5.2.18-200.fc30.x86_64/vmlinuxfor symbols Open Debuginfo file:/usr/lib/debug/lib/modules/5.2.18-200.fc30.x86_64/vmlinux[root@quaco ~]#[root@quaco ~]# readelf -wi
/usr/lib/debug/lib/modules/5.2.18-200.fc30.x86_64/vmlinux| grep__amd_put_nb_event_constraints-B1 -A7
<1><192640>: Abbrev Number: 123 (DW_TAG_subprogram)<192641> DW_AT_name : (indirect string, offset: 0x299576): __amd_put_nb_event_constraints <192645> DW_AT_decl_file : 1 <192646> DW_AT_decl_line : 361 <192648> DW_AT_decl_column : 13 <192649> DW_AT_prototyped : 1 <192649> DW_AT_inline : 1 (inlined) <19264a> DW_AT_sibling : <0x192700><2><19264e>: Abbrev Number: 38 (
DW_TAG_formal_parameter)
^C
[root@quaco ~]#Continuing to process the other patches...
- Arnaldo
Quoted 23 lines
Quoted 19 lines
Fixes 4ea42b181434 ("perf: Add perf probe subcommand, a kprobe-event setup helper")Signed-off-by Masami Hiramatsu <[email protected]>--- tools/perf/util/probe-finder.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)tools/perf/util/probe-finder.c +1
-1@@ -930,7 +930,7 @@ static int probe_point_inline_cb(Dwarf_Die *in_die, void *data) ret =find_probe_point_lazy (in_die, pf); else {/* Get probe address */ -if (dwarf_entrypc (in_die, &addr) !=0 ) { +if (die_entrypc (in_die, &addr) !=0 ) {pr_warning ("Failed to get entry address of %s.\n" ,dwarf_diename (in_die));return -ENOENT ;Signature · 1 line
- ArnaldoSignature · 1 line
- Arnaldo
Signature · 1 line
Masami Hiramatsu <[email protected]>
[tip: perf/core] perf probe: Fix to probe an inline function which has no entry pc
In reply to Masami HiramatsuThe following commit has been merged into the perf/core branch of tip:
The following commit has been merged into the perf/core branch of tip:
Commit-ID: eb6933b29d20bf2c3053883d409a53f462c1a3ac Gitweb: https://git.kernel.org/tip/eb6933b29d20bf2c3053883d409a53f462c1a3ac Author: Masami Hiramatsu <[email protected]> AuthorDate: Fri, 25 Oct 2019 17:46:43 +09:00 Committer: Arnaldo Carvalho de Melo <[email protected]> CommitterDate: Wed, 06 Nov 2019 15:43:06 -03:00
perf probe: Fix to probe an inline function which has no entry pc
Fix perf probe to probe an inlne function which has no entry pc or low pc but only has ranges attribute.
This seems very rare case, but I could find a few examples, as same as probe_point_search_cb(), use die_entrypc() to get the entry address in probe_point_inline_cb() too.
Without this patch:
# perf probe -D __amd_put_nb_event_constraints
Failed to get entry address of __amd_put_nb_event_constraints.
Probe point '__amd_put_nb_event_constraints' not found.
Error: Failed to add events.With this patch:
# perf probe -D __amd_put_nb_event_constraints p:probe/__amd_put_nb_event_constraints amd_put_event_constraints+43
Committer testing:
Before:
[root@quaco ~]# perf probe -D __amd_put_nb_event_constraints Failed to get entry address of __amd_put_nb_event_constraints. Probe point '__amd_put_nb_event_constraints' not found.
Error: Failed to add events.
[root@quaco ~]#
After:
[root@quaco ~]# perf probe -D __amd_put_nb_event_constraints p:probe/__amd_put_nb_event_constraints _text+33789 [root@quaco ~]#
--- tools/perf/util/probe-finder.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
tools/perf/util/probe-finder.c +1 -1
@@ -930,7 +930,7 @@ static int probe_point_inline_cb(Dwarf_Die *in_die, void *data) ret =find_probe_point_lazy (in_die, pf); else {/* Get probe address */ -if (dwarf_entrypc (in_die, &addr) !=0 ) { +if (die_entrypc (in_die, &addr) !=0 ) {pr_warning ("Failed to get entry address of %s.\n" ,dwarf_diename (in_die));return -ENOENT ;
PATCH 4/6 perf/probe: Fix to list probe event with correct line number
In reply to Masami HiramatsuSince debuginfo__find_probe_point() uses dwarf_entrypc() for finding the entry address of the function on which a probe is, it will fail when the function DIE has only ranges attribute.
To fix this issue, use die_entrypc() instead of dwarf_entrypc().
Without this fix, perf probe -l shows incorrect offset.
# perf probe -l
probe:clear_tasks_mm_cpumask (on clear_tasks_mm_cpumask+18446744071579263632@work/linux/linux/kernel/cpu.c)
probe:clear_tasks_mm_cpumask_1 (on clear_tasks_mm_cpumask+18446744071579263752@work/linux/linux/kernel/cpu.c)With this,
# perf probe -l
probe:clear_tasks_mm_cpumask (on clear_tasks_mm_cpumask@work/linux/linux/kernel/cpu.c)
probe:clear_tasks_mm_cpumask_1 (on clear_tasks_mm_cpumask:21@work/linux/linux/kernel/cpu.c)--- tools/perf/util/probe-finder.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
tools/perf/util/probe-finder.c +2 -2
@@ -1566,7 +1566,7 @@ int debuginfo__find_probe_point(struct debuginfo *dbg, unsigned long addr,/* Get function entry information */ func = basefunc =dwarf_diename (&spdie);if (!func || -dwarf_entrypc (&spdie, &baseaddr) !=0 || +die_entrypc (&spdie, &baseaddr) !=0 ||dwarf_decl_line (&spdie, &baseline) !=0 ) { lineno =0 ; goto post;
@@ -1583,7 +1583,7 @@ int debuginfo__find_probe_point(struct debuginfo *dbg, unsigned long addr,while (die_find_top_inlinefunc (&spdie, (Dwarf_Addr )addr, &indie)) {/* There is an inline function */ -if (dwarf_entrypc (&indie, &_addr) ==0 && +if (die_entrypc (&indie, &_addr) ==0 && _addr == addr) {/* * addr is at an inline function entry.
[tip: perf/core] perf probe: Fix to list probe event with correct line number
The following commit has been merged into the perf/core branch of tip:
The following commit has been merged into the perf/core branch of tip:
Commit-ID: 3895534dd78f0fd4d3f9e05ee52b9cdd444a743e Gitweb: https://git.kernel.org/tip/3895534dd78f0fd4d3f9e05ee52b9cdd444a743e Author: Masami Hiramatsu <[email protected]> AuthorDate: Fri, 25 Oct 2019 17:46:52 +09:00 Committer: Arnaldo Carvalho de Melo <[email protected]> CommitterDate: Wed, 06 Nov 2019 15:43:06 -03:00
perf probe: Fix to list probe event with correct line number
Since debuginfo__find_probe_point() uses dwarf_entrypc() for finding the entry address of the function on which a probe is, it will fail when the function DIE has only ranges attribute.
To fix this issue, use die_entrypc() instead of dwarf_entrypc().
Without this fix, perf probe -l shows incorrect offset:
# perf probe -l
probe:clear_tasks_mm_cpumask (on clear_tasks_mm_cpumask+18446744071579263632@work/linux/linux/kernel/cpu.c)
probe:clear_tasks_mm_cpumask_1 (on clear_tasks_mm_cpumask+18446744071579263752@work/linux/linux/kernel/cpu.c)With this:
# perf probe -l
probe:clear_tasks_mm_cpumask (on clear_tasks_mm_cpumask@work/linux/linux/kernel/cpu.c)
probe:clear_tasks_mm_cpumask_1 (on clear_tasks_mm_cpumask:21@work/linux/linux/kernel/cpu.c)Committer testing:
Before:
[root@quaco ~]# perf probe -l
probe:clear_tasks_mm_cpumask (on clear_tasks_mm_cpumask+18446744071579765152@kernel/cpu.c)
[root@quaco ~]#
After:
[root@quaco ~]# perf probe -l
probe:clear_tasks_mm_cpumask (on clear_tasks_mm_cpumask@kernel/cpu.c)
[root@quaco ~]#
--- tools/perf/util/probe-finder.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
tools/perf/util/probe-finder.c +2 -2
@@ -1566,7 +1566,7 @@ int debuginfo__find_probe_point(struct debuginfo *dbg, unsigned long addr,/* Get function entry information */ func = basefunc =dwarf_diename (&spdie);if (!func || -dwarf_entrypc (&spdie, &baseaddr) !=0 || +die_entrypc (&spdie, &baseaddr) !=0 ||dwarf_decl_line (&spdie, &baseline) !=0 ) { lineno =0 ; goto post;
@@ -1583,7 +1583,7 @@ int debuginfo__find_probe_point(struct debuginfo *dbg, unsigned long addr,while (die_find_top_inlinefunc (&spdie, (Dwarf_Addr )addr, &indie)) {/* There is an inline function */ -if (dwarf_entrypc (&indie, &_addr) ==0 && +if (die_entrypc (&indie, &_addr) ==0 && _addr == addr) {/* * addr is at an inline function entry.
PATCH 5/6 perf/probe: Fix to show inlined function callsite without entry_pc
In reply to Masami HiramatsuFix perf-probe --line option to show inlined function callsite lines even if the function DIE has only ranges.
Without this,
# tools/perf/perf probe -L amd_put_event_constraints
...
2 {
3 if (amd_has_nb(cpuc) && amd_is_nb_event(&event->hw))
__amd_put_nb_event_constraints(cpuc, event);
5 }With this patch,
# tools/perf/perf probe -L amd_put_event_constraints
...
2 {
3 if (amd_has_nb(cpuc) && amd_is_nb_event(&event->hw))
4 __amd_put_nb_event_constraints(cpuc, event);
5 }--- tools/perf/util/dwarf-aux.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
tools/perf/util/dwarf-aux.c +1 -1
@@ -695,7 +695,7 @@ static int __die_walk_funclines_cb(Dwarf_Die *in_die, void *data)if (dwarf_tag (in_die) == DW_TAG_inlined_subroutine) { fname =die_get_call_file (in_die); lineno =die_get_call_lineno (in_die); -if (fname && lineno >0 &&dwarf_entrypc (in_die, &addr) ==0 ) { +if (fname && lineno >0 &&die_entrypc (in_die, &addr) ==0 ) { lw->retval = lw->callback (fname, lineno, addr, lw->data);if (lw->retval !=0 )return DIE_FIND_CB_END ;
[tip: perf/core] perf probe: Fix to show inlined function callsite without entry_pc
The following commit has been merged into the perf/core branch of tip:
The following commit has been merged into the perf/core branch of tip:
Commit-ID: 18e21eb671dc87a4f0546ba505a89ea93598a634 Gitweb: https://git.kernel.org/tip/18e21eb671dc87a4f0546ba505a89ea93598a634 Author: Masami Hiramatsu <[email protected]> AuthorDate: Fri, 25 Oct 2019 17:47:01 +09:00 Committer: Arnaldo Carvalho de Melo <[email protected]> CommitterDate: Wed, 06 Nov 2019 15:43:06 -03:00
perf probe: Fix to show inlined function callsite without entry_pc
Fix 'perf probe --line' option to show inlined function callsite lines even if the function DIE has only ranges.
Without this:
# perf probe -L amd_put_event_constraints
...
2 {
3 if (amd_has_nb(cpuc) && amd_is_nb_event(&event->hw))
__amd_put_nb_event_constraints(cpuc, event);
5 }With this patch:
# perf probe -L amd_put_event_constraints
...
2 {
3 if (amd_has_nb(cpuc) && amd_is_nb_event(&event->hw))
4 __amd_put_nb_event_constraints(cpuc, event);
5 }Committer testing:
Before:
[root@quaco ~]# perf probe -L amd_put_event_constraints
<amd_put_event_constraints@/usr/src/debug/kernel-5.2.fc30/linux-5.2.18-200.fc30.x86_64/arch/x86/events/amd/core.c:0>
0 static void amd_put_event_constraints(struct cpu_hw_events *cpuc,
struct perf_event *event)
2 {
3 if (amd_has_nb(cpuc) && amd_is_nb_event(&event->hw))
__amd_put_nb_event_constraints(cpuc, event);
5 } PMU_FORMAT_ATTR(event, "config:0-7,32-35");
PMU_FORMAT_ATTR(umask, "config:8-15" );[root@quaco ~]#
After:
[root@quaco ~]# perf probe -L amd_put_event_constraints
<amd_put_event_constraints@/usr/src/debug/kernel-5.2.fc30/linux-5.2.18-200.fc30.x86_64/arch/x86/events/amd/core.c:0>
0 static void amd_put_event_constraints(struct cpu_hw_events *cpuc,
struct perf_event *event)
2 {
3 if (amd_has_nb(cpuc) && amd_is_nb_event(&event->hw))
4 __amd_put_nb_event_constraints(cpuc, event);
5 } PMU_FORMAT_ATTR(event, "config:0-7,32-35");
PMU_FORMAT_ATTR(umask, "config:8-15" ); [root@quaco ~]# perf probe amd_put_event_constraints:4 Added new event:
probe:amd_put_event_constraints (on amd_put_event_constraints:4)
You can now use it in all perf tools, such as:
perf record -e probe:amd_put_event_constraints -aR sleep 1
[root@quaco ~]#
[root@quaco ~]# perf probe -l
probe:amd_put_event_constraints (on amd_put_event_constraints:4@arch/x86/events/amd/core.c) probe:clear_tasks_mm_cpumask (on clear_tasks_mm_cpumask@kernel/cpu.c)
[root@quaco ~]#
Using it:
[root@quaco ~]# perf trace -e probe:*
^C[root@quaco ~]#
Ok, Intel system here... :-)
--- tools/perf/util/dwarf-aux.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
tools/perf/util/dwarf-aux.c +1 -1
@@ -695,7 +695,7 @@ static int __die_walk_funclines_cb(Dwarf_Die *in_die, void *data)if (dwarf_tag (in_die) == DW_TAG_inlined_subroutine) { fname =die_get_call_file (in_die); lineno =die_get_call_lineno (in_die); -if (fname && lineno >0 &&dwarf_entrypc (in_die, &addr) ==0 ) { +if (fname && lineno >0 &&die_entrypc (in_die, &addr) ==0 ) { lw->retval = lw->callback (fname, lineno, addr, lw->data);if (lw->retval !=0 )return DIE_FIND_CB_END ;
PATCH 6/6 perf/probe: Fix to show ranges of variables in functions without entry_pc
In reply to Masami HiramatsuFix to show ranges of variables (--range and --vars option) in functions which DIE has only ranges but no entry_pc attribute.
Without this fix,
# tools/perf/perf probe --range -V clear_tasks_mm_cpumask Available variables at clear_tasks_mm_cpumask @<clear_tasks_mm_cpumask+0> (No matched variables)
With this fix,
# tools/perf/perf probe --range -V clear_tasks_mm_cpumask Available variables at clear_tasks_mm_cpumask @<clear_tasks_mm_cpumask+0> [VAL] int cpu @<clear_tasks_mm_cpumask+[0-35,317-317,2052-2059]>
--- tools/perf/util/dwarf-aux.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
tools/perf/util/dwarf-aux.c +2 -2
@@ -1019,7 +1019,7 @@ static int die_get_var_innermost_scope(Dwarf_Die *sp_die, Dwarf_Die *vr_die,bool first = true;const char *name; - ret =dwarf_entrypc (sp_die, &entry); + ret =die_entrypc (sp_die, &entry);if (ret)return ret;
@@ -1082,7 +1082,7 @@ int die_get_var_range(Dwarf_Die *sp_die, Dwarf_Die *vr_die, struct strbuf *buf)bool first = true;const char *name; - ret =dwarf_entrypc (sp_die, &entry); + ret =die_entrypc (sp_die, &entry);if (ret)return ret;
[tip: perf/core] perf probe: Fix to show ranges of variables in functions without entry_pc
The following commit has been merged into the perf/core branch of tip:
The following commit has been merged into the perf/core branch of tip:
Commit-ID: af04dd2f8ebaa8fbd46f698714acbf43da14da45 Gitweb: https://git.kernel.org/tip/af04dd2f8ebaa8fbd46f698714acbf43da14da45 Author: Masami Hiramatsu <[email protected]> AuthorDate: Fri, 25 Oct 2019 17:47:10 +09:00 Committer: Arnaldo Carvalho de Melo <[email protected]> CommitterDate: Wed, 06 Nov 2019 15:43:06 -03:00
perf probe: Fix to show ranges of variables in functions without entry_pc
Fix to show ranges of variables (--range and --vars option) in functions which DIE has only ranges but no entry_pc attribute.
Without this fix:
# perf probe --range -V clear_tasks_mm_cpumask Available variables at clear_tasks_mm_cpumask @<clear_tasks_mm_cpumask+0> (No matched variables)
With this fix:
# perf probe --range -V clear_tasks_mm_cpumask Available variables at clear_tasks_mm_cpumask @<clear_tasks_mm_cpumask+0> [VAL] int cpu @<clear_tasks_mm_cpumask+[0-35,317-317,2052-2059]>
Committer testing:
Before:
[root@quaco ~]# perf probe --range -V clear_tasks_mm_cpumask
Available variables at clear_tasks_mm_cpumask
@<clear_tasks_mm_cpumask+0>
(No matched variables)
[root@quaco ~]#After:
[root@quaco ~]# perf probe --range -V clear_tasks_mm_cpumask
Available variables at clear_tasks_mm_cpumask
@<clear_tasks_mm_cpumask+0>
[VAL] int cpu @<clear_tasks_mm_cpumask+[0-23,23-105,105-106,106-106,1843-1850,1850-1862]>
[root@quaco ~]#Using it:
[root@quaco ~]# perf probe clear_tasks_mm_cpumask cpu Added new event:
probe:clear_tasks_mm_cpumask (on clear_tasks_mm_cpumask with cpu)
You can now use it in all perf tools, such as:
perf record -e probe:clear_tasks_mm_cpumask -aR sleep 1
[root@quaco ~]# perf probe -l
probe:clear_tasks_mm_cpumask (on clear_tasks_mm_cpumask@kernel/cpu.c with cpu)
[root@quaco ~]#
[root@quaco ~]# perf trace -e probe:*cpumask
^C[root@quaco ~]#
--- tools/perf/util/dwarf-aux.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
tools/perf/util/dwarf-aux.c +2 -2
@@ -1019,7 +1019,7 @@ static int die_get_var_innermost_scope(Dwarf_Die *sp_die, Dwarf_Die *vr_die,bool first = true;const char *name; - ret =dwarf_entrypc (sp_die, &entry); + ret =die_entrypc (sp_die, &entry);if (ret)return ret;
@@ -1082,7 +1082,7 @@ int die_get_var_range(Dwarf_Die *sp_die, Dwarf_Die *vr_die, struct strbuf *buf)bool first = true;const char *name; - ret =dwarf_entrypc (sp_die, &entry); + ret =die_entrypc (sp_die, &entry);if (ret)return ret;