perf: fix incorrect change in annotate result
hulk inclusion category: bugfix bugzilla: 9583 CVE: NA ------------------------------------------------- The output of "perf annotate -l --stdio xxx" changed since commit 425859ff ("perf annotate: No need to calculate notes->start twice") removed notes->start assignment in symbol__calc_lines(). It will get failed in find_address_in_section() from symbol__tty_annotate() subroutine as the a2l->addr is wrong. So the annotate summary doesn't report the line number of source code correctly. Before fix: [root@localhost tools]# ./perf/perf record -o perf.data /root/common_while_1 ^C[ perf record: Woken up 1 times to write data ] [ perf record: Captured and wrote 0.261 MB perf.data (6538 samples) ] [root@localhost tools]# ./perf/perf annotate -i perf.data -l -s hotspot_1 --stdio | less Sorted summary for file /root/common_while_1 ---------------------------------------------- 32.53 common_while_1[3c] 32.26 common_while_1[14] 15.59 common_while_1[38] 14.89 common_while_1[2c] 2.48 common_while_1[48] 1.10 common_while_1[c] 0.58 common_while_1[8] Percent | Source code & Disassembly of common_while_1 for cycles:ppp (2457 samples, percent: local period) ---------------------------------------------------------------------------------------------------------------- : : : : Disassembly of section .text: : : 00000000004008b0 <hotspot_1>: : hotspot_1(): : for(i = 0; i<=100; i++) { : s_cnt2++; : } : } : : void hotspot_1() { 0.00 : 4008b0: stp x29, x30, [sp,#-32]! 0.00 : 4008b4: mov x29, sp : int i; : while(1) { : hotspot_2(); common_while_1[8] 0.58 : 4008b8: bl 400864 <hotspot_2> : for(i = 0; i<=100; i++) { common_while_1[c] 1.10 : 4008bc: str wzr, [x29,#28] 0.00 : 4008c0: b 4008ec <hotspot_1+0x3c> : s_cnt1++; common_while_1[14] 32.26 : 4008c4: adrp x0, 420000 <fclose@GLIBC_2.17> 0.00 : 4008c8: add x0, x0, #0x7c 0.16 : 4008cc: ldr w0, [x0] 0.00 : 4008d0: add w1, w0, #0x1 ... After fix: [root@localhost tools]# ./perf/perf record -o perf.data /root/common_while_1 ^C[ perf record: Woken up 1 times to write data ] [ perf record: Captured and wrote 0.261 MB perf.data (6538 samples) ] [root@localhost tools]# ./perf/perf annotate -i perf.data -l -s hotspot_1 --stdio | less Sorted summary for file /root/common_while_1 ---------------------------------------------- 50.27 common_while_1.c:37 46.46 common_while_1.c:38 2.79 common_while_1.c:36 Percent | Source code & Disassembly of common_while_1 for cycles:ppp (3149 samples, percent: local period) ---------------------------------------------------------------------------------------------------------------- : : : : Disassembly of section .text: : : 00000000004008b0 <hotspot_1>: : hotspot_1(): : for(i = 0; i<=100; i++) { : s_cnt2++; : } : } : : void hotspot_1() { 0.00 : 4008b0: stp x29, x30, [sp,#-32]! 0.00 : 4008b4: mov x29, sp : int i; : while(1) { : hotspot_2(); common_while_1.c:36 0.82 : 4008b8: bl 400864 <hotspot_2> : for(i = 0; i<=100; i++) { common_while_1.c:37 1.17 : 4008bc: str wzr, [x29,#28] 0.00 : 4008c0: b 4008ec <hotspot_1+0x3c> : s_cnt1++; common_while_1.c:38 31.33 : 4008c4: adrp x0, 420000 <fclose@GLIBC_2.17> 0.00 : 4008c8: add x0, x0, #0x7c 0.19 : 4008cc: ldr w0, [x0] 0.00 : 4008d0: add w1, w0, #0x1 ... Fixes: 425859ff ("perf annotate: No need to calculate notes->start twice") Signed-off-by: NWei Li <liwei391@huawei.com> Signed-off-by: NWei Li <liwei391@huawei.com> Reviewed-by: NLi Bin <huawei.libin@huawei.com> Signed-off-by: NYang Yingliang <yangyingliang@huawei.com>
Showing
想要评论请 注册 或 登录