Re: [PATCH] perf annotate: Numeric assembly labels cause incorrectannotation

From: Eric B Munson
Date: Tue Feb 07 2012 - 09:25:46 EST


On Tue, 07 Feb 2012, Anton Blanchard wrote:

>
> A perf annotate of a kernel function written in assembly shows
> very strange percentages:
>
> : _GLOBAL(__copy_tofrom_user_base)
>
> ...
>
> : addi r3,r3,1
> 99.67 : c00000000004d78c: addi r3,r3,1
> :
> 0.00 : 1: bf cr7*4+2,2f
> 0.07 : c00000000004d790: bne- cr7,c00000000004d7a4
> : err1; lhz r0,0(r4)
> 0.00 : c00000000004d794: lhz r0,0(r4)
> : addi r4,r4,2
> 0.00 : c00000000004d798: addi r4,r4,2
> : err1; sth r0,0(r3)
> 0.00 : c00000000004d79c: sth r0,0(r3)
> : addi r3,r3,2
> 99.60 : c00000000004d7a0: addi r3,r3,2
> :
> 0.00 : 2: bf cr7*4+1,3f
> 0.12 : c00000000004d7a4: ble- cr7,c00000000004d7b8
> : err1; lwz r0,0(r4)
> 0.00 : c00000000004d7a8: lwz r0,0(r4)
> : addi r4,r4,4
> 0.00 : c00000000004d7ac: addi r4,r4,4
> : err1; stw r0,0(r3)
> 0.00 : c00000000004d7b0: stw r0,0(r3)
> : addi r3,r3,4
> 99.48 : c00000000004d7b4: addi r3,r3,4
>
> ~300% in one function. Urgh.
>
> This is caused by the way we parse objdump -S output, eg:
>
> addi r3,r3,1
> c00000000004d78c: addi r3,r3,1
>
> 1: bf cr7*4+2,2f
> c00000000004d790: bne- cr7,c00000000004d7a4
>
> We assume the asm label (1:) is an address, compute a bogus offset
> into the function and then screw up the matching of samples to lines.
> I notice this also fails with c inline assembly in a similar
> manner.
>
> We already have a sanity check that the address is not beyond the end
> of the function, so add a check against the start too.
>
> Signed-off-by: Anton Blanchard <anton@xxxxxxxxx>

Acked-by: Eric B Munson <emunson@xxxxxxxxx>

Attachment: signature.asc
Description: Digital signature