Re: [RFC PATCH] perf tui: Annotate entries in callchains

From: Arnaldo Carvalho de Melo
Date: Fri Mar 20 2015 - 17:34:40 EST


Em Fri, Mar 20, 2015 at 02:12:30PM -0700, Stephane Eranian escreveu:
> On Fri, Mar 20, 2015 at 2:07 PM, Arnaldo Carvalho de Melo
> <arnaldo.melo@xxxxxxxxx> wrote:
> > Em Fri, Mar 20, 2015 at 05:39:22PM -0300, Arnaldo Carvalho de Melo escreveu:
> >> Em Fri, Mar 20, 2015 at 10:15:53AM -0700, Stephane Eranian escreveu:
> >> > On Thu, Mar 19, 2015 at 5:39 PM, Arnaldo Carvalho de Melo <arnaldo.melo@xxxxxxxxx> wrote:
> >> > > On Mar 19, 2015 9:34 PM, "Stephane Eranian" <eranian@xxxxxxxxxx> wrote:
> >> > >> On Thu, Mar 19, 2015 at 3:58 PM, Arnaldo Carvalho de Melo
> >> > >> <acme@xxxxxxxxxx> wrote:
> >> > >> > This patch, together with what is in my perf/core branch, should
> >> > >> > implement that feature we talked about recently, i.e. to allow
> >> > >> > annotating entries in callchains, please take a look at see if you think
> >> > >> > it is ok,

> >> > >> I tried on tip.git and a simple example. It does what I wanted.
> >> > >> I will try on more complex test cases.
> >> > >> Thanks for implementing this quickly.

> >> > > Thanks for testing, please let us know if you have further suggestions,

> >> > Ok, it does not work.
> >
> > Are you sure? I just tried, take a look at:
> >
> > http://vger.kernel.org/~acme/perf-report-annotate-callchain-entries-in-multiple-DSOs-in-the-same-hist_entry.png
> >
> > In there you will see that in the unmap_single_vma case there are
> > callchains that pass thru multiple DSOs in userspace (I used --call
> > dwarf in 'perf record') and those are marked as having
> > samples/annotation and when I go to those, pressing 'a' after moving the
> > cursor to it and it works as expected...

> > Do you have some specific example I could try?

> I tried on an example I cannot share.
> But I am guessing you could reproduce with a test which calls a libc
> or libm function
> heavily form multiple callers in the main program.
> Example:
> - pow()
> 50% foo() [main.c]
> 50% bar() [main.c]
>
> If I move the cursor line to foo() and annotate foo() is shows me the
> code of pow().

+ 49.83% pow-me-harder pow-me-harder [.] main
+ 27.16% pow-me-harder libm-2.17.so [.] __ieee754_pow_sse2
- 17.76% pow-me-harder libm-2.17.so [.] __pow
-â__pow libm-2.17.so
-â80.70% main pow-me-harder
__libc_start_main libc-2.17.so
_start pow-me-harder
16.82% 0x4000000000000000 unknown
2.44% 0x1 unknown
+ 2.57% pow-me-harder pow-me-harder [.] pow@plt
+ 2.36% pow-me-harder libm-2.17.so [.] @plt
+ 0.04% pow-me-harder [kernel.vmlinux] [k] intel_thermal_interrupt

And if I go to the line:

-â80.70% main pow-me-harder

And press 'a' I get:

main /home/acme/pow-me-harder
10.25 â 3e: mov -0x10(%rbp),%rax
1.03 â test %rax,%rax
4.39 â â js 53
3.87 â cvtsi2 %rax,%xmm3
1.63 â movsd %xmm3,-0x38(%rbp)
â â jmp 71
0.03 â 53: mov %rax,%rdx
0.91 â shr %rdx
0.29 â and $0x1,%eax
1.85 â or %rax,%rdx
7.38 â cvtsi2 %rdx,%xmm0
0.55 â movapd %xmm0,%xmm2
6.54 â addsd %xmm0,%xmm2
0.68 â movsd %xmm2,-0x38(%rbp)
1.44 â 71: cvtsi2 -0x4(%rbp),%xmm0
2.82 â movabs $0x4000000000000000,%rax
0.62 â mov %rax,-0x40(%rbp)
0.07 â movsd -0x40(%rbp),%xmm1
4.30 â â callq pow@plt
1.53 â addsd -0x38(%rbp),%xmm0
4.13 â ucomis 0xfd(%rip),%xmm0 # 400818 <__dso_handle+0x10>
4.06 â â jae a8
1.49 â cvttsd %xmm0,%rax
1.49 â mov %rax,-0x10(%rbp)
0.35 â â jmp cb
â a8: movsd 0xe8(%rip),%xmm1 # 400818 <__dso_handle+0x10>
0.14 â subsd %xmm1,%xmm0
2.57 â cvttsd %xmm0,%rax
0.66 â mov %rax,-0x10(%rbp)
â movabs $0x8000000000000000,%rax
7.84 â xor %rax,-0x10(%rbp)
16.80 â cb: mov -0x10(%rbp),%rax
2.15 â mov %rax,-0x10(%rbp)
â int main(int argc, char *argv[])
â {
â int n = atoi(argv[1]), i;
â unsigned long long total = 0;

While if I go to the line:

-â__pow libm-2.17.so

And press 'a', I get:

__pow /usr/lib64/libm-2.17.so
â Disassembly of section .text:
â
â 0000000000026290 <pow>:
â __pow():
â movapd %xmm0,%xmm2
â sub $0x18,%rsp
1.70 â movapd %xmm1,%xmm3
12.86 â movsd %xmm2,(%rsp)
â movsd %xmm3,0x8(%rsp)
2.43 â â callq *ABS*+0x1b110@plt
0.49 â movabs $0x7fffffffffffffff,%rcx
0.28 â movabs $0x7fefffffffffffff,%rdx
1.01 â movq %xmm0,%rax
12.58 â and %rcx,%rax
2.18 â movsd (%rsp),%xmm2
1.29 â cmp %rdx,%rax
19.70 â movsd 0x8(%rsp),%xmm3
1.50 â â ja 57
1.58 â xorpd %xmm1,%xmm1
13.35 â ucomis %xmm1,%xmm0
0.89 â â jnp a0
â 52: add $0x18,%rsp
16.83 â â retq
â 57: mov _DYNAMIC+0x230,%rsi
â cmpl $0xffffffff,(%rsi)
â â je 52


Since I don't have glibc-debuginfo installed, I get just assembly.

[acme@ssdandy linux]$ readelf -sw /usr/lib64/libm-2.17.so | grep -w __pow
1737: 0000000000026290 429 FUNC LOCAL DEFAULT 13 __pow
[acme@ssdandy linux]$

Strange, are you pressing 'V' on the main 'perf record' view, i.e. before
getting to the annotation browser, to see the DSO just after the symbol?

Trying with a deeper callchain in pow-me-harder.c...

- Arnaldo
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/