Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751415AbdILKQs (ORCPT ); Tue, 12 Sep 2017 06:16:48 -0400 Received: from mga04.intel.com ([192.55.52.120]:60836 "EHLO mga04.intel.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751311AbdILKQr (ORCPT ); Tue, 12 Sep 2017 06:16:47 -0400 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.42,382,1500966000"; d="asc'?scan'208";a="1194167747" Date: Tue, 12 Sep 2017 18:10:35 +0800 From: "Du, Changbin" To: peterz@infradead.org, mingo@redhat.com, acme@kernel.org, alexander.shishkin@linux.intel.com, linux-kernel@vger.kernel.org Cc: changbin.du@intel.com Subject: Does perf-annotate work correctly? Message-ID: <20170912101035.GA21638@intel.com> MIME-Version: 1.0 Content-Type: multipart/signed; micalg=pgp-sha1; protocol="application/pgp-signature"; boundary="HlL+5n6rz5pIUxbD" Content-Disposition: inline User-Agent: Mutt/1.5.24 (2015-08-30) Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 7781 Lines: 165 --HlL+5n6rz5pIUxbD Content-Type: text/plain; charset=utf-8 Content-Disposition: inline Content-Transfer-Encoding: quoted-printable When a annotate a symbol, I find the annotated C source code doesn't match = assembly code. So I cannot determine which line of C code has much overhead withou gdb's h= elp. Here is a example result of function apic_has_interrupt_for_ppr() in kvm mo= dule. =E2=94=82580 __clear_bit(KVM_APIC_PV_EOI_PENDING, &vcpu->arc= h.apic_attention); =E2=96=92 =E2=94=82581 } = =E2=96=92 =E2=94=82 = =E2=96=92 =E2=94=82583 static int apic_has_interrupt_for_ppr(struct kvm_lapic = *apic, u32 ppr) =E2=96=92 =E2=94=82584 { = =E2=96=92 0.88 =E2=94=8230: cmpb $0x0,0x91(%rdi) = =E2=96=92 2.54 =E2=94=82 =E2=86=93 je 63 = =E2=96=92 0.20 =E2=94=82 mov 0xa0(%rdi),%rcx = =E2=96=92 =E2=94=82581 int highest_irr; = =E2=96=92 =E2=94=82582 if (kvm_x86_ops->sync_pir_to_irr && apic->vcpu-= >arch.apicv_active) =E2=96=92 4.91 =E2=94=82 mov $0xe0,%eax x = =E2=96=92 1.46 =E2=94=8245: mov %eax,%edx x = =E2=96=92 0.02 =E2=94=82 sar $0x5,%edx x = =E2=96=92 3.57 =E2=94=82 shl $0x4,%edx x = =E2=96=92 3.34 =E2=94=82 movslq %edx,%rdx x = =E2=96=92 1.25 =E2=94=82 mov 0x200(%rcx,%rdx,1),%edx x = =E2=96=92 42.44 =E2=94=82 test %edx,%edx x = =E2=96=92 0.01 =E2=94=82 =E2=94=8C=E2=94=80=E2=94=80jne 88 = x =E2=96=92 3.48 =E2=94=82 =E2=94=82 sub $0x20,%eax x = =E2=96=92 2.24 =E2=94=82 =E2=94=82 cmp $0xffffffe0,%eax x = =E2=96=92 =E2=94=82586=E2=94=82apic_find_highest_irr(): = =E2=96=92 =E2=94=82 =E2=94=82 = =E2=96=92 =E2=94=82407=E2=94=82 /* = =E2=96=92 =E2=94=82408=E2=94=82 * Note that irr_pending is just a hint= =2E It will be always =E2=96=92 =E2=94=82409=E2=94=82 * true with virtual interrupt delivery= enabled. =E2=96=92 =E2=94=82410=E2=94=82 */ = =E2=96=92 =E2=94=82411=E2=94=82 if (!apic->irr_pending) = =E2=96=92 =E2=94=82 =E2=94=82=E2=86=91 jne 45 = =E2=96=92 0.62 =E2=94=8263:=E2=94=82 mov $0xffffffff,%eax = =E2=97=86 0.83 =E2=94=82 =E2=94=82 leaveq = =E2=96=92 13.52 =E2=94=82 =E2=94=82=E2=86=90 retq = =E2=96=92 =E2=94=826a:=E2=94=82 mov %esi,-0x4(%rbp) = =E2=96=92 =E2=94=82 =E2=94=82 mov %rdx,%rdi = =E2=96=92 =E2=94=82418=E2=94=82find_highest_vector(): = =E2=96=92 =E2=94=82340=E2=94=82static int find_highest_vector(void *bitmap) = =E2=96=92 =E2=94=82341=E2=94=82{ = =E2=96=92 =E2=94=82342=E2=94=82 int vec; = =E2=96=92 =E2=94=82343=E2=94=82 u32 *reg; = =E2=96=92 =E2=94=82 =E2=94=82 = =E2=96=92 =E2=94=82345=E2=94=82 for (vec =3D MAX_APIC_VECTOR - APIC_VEC= TORS_PER_REG; =E2=96=92 =E2=94=82 =E2=94=82=E2=86=92 callq *%rax = =E2=96=92 =E2=94=82 =E2=94=82 mov -0x4(%rbp),%esi = =E2=96=92 =E2=94=82343=E2=94=82 vec >=3D 0; vec -=3D APIC_VECTORS_= PER_REG) { =E2=96=92 =E2=94=82344=E2=94=82 reg =3D bitmap + REG_POS(vec); = =E2=96=92 =E2=94=82345=E2=94=82 if (*reg) = =E2=96=92 0.05 =E2=94=8275:=E2=94=82 cmp $0xffffffff,%eax = =E2=96=92 =E2=94=82 =E2=94=82=E2=86=91 je 63 = =E2=96=92 1.95 =E2=94=82 =E2=94=82 mov %eax,%edx = =E2=96=92 1.45 =E2=94=82 =E2=94=82 and $0xf0,%edx = =20 Look at the assembly code block where I have put a 'x' on the right. Appare= ntly the assembly code doesn't match the C source code arrounded. Let's look the cor= rect disassemble result from gdb: 340 for (vec =3D MAX_APIC_VECTOR - APIC_VECTORS_PER_REG; 0x000000000003b4e0 <+64>: mov $0xe0,%eax 342 reg =3D bitmap + REG_POS(vec); 343 if (*reg) 0x000000000003b4e5 <+69>: mov %eax,%edx 0x000000000003b4e7 <+71>: sar $0x5,%edx 0x000000000003b4ea <+74>: shl $0x4,%edx 0x000000000003b4ed <+77>: movslq %edx,%rdx 0x000000000003b4f0 <+80>: mov 0x200(%rcx,%rdx,1),%edx 0x000000000003b4f7 <+87>: test %edx,%edx 0x000000000003b4f9 <+89>: jne 0x3b528 341 vec >=3D 0; vec -=3D APIC_VECTORS_PER_REG) { 0x000000000003b4fb <+91>: sub $0x20,%eax 340 for (vec =3D MAX_APIC_VECTOR - APIC_VECTORS_PER_REG; 0x000000000003b4fe <+94>: cmp $0xffffffe0,%eax 0x000000000003b501 <+97>: jne 0x3b4e5 Compared to gdb, perf-annoate has messed up. is it a bug or just perf is no= t as perfect as gdb? --=20 Thanks, Changbin Du --HlL+5n6rz5pIUxbD Content-Type: application/pgp-signature; name="signature.asc" -----BEGIN PGP SIGNATURE----- Version: GnuPG v1 iQEcBAEBAgAGBQJZt7KbAAoJEAanuZwLnPNU/98H/1N3A5Hv/FdGDZN7LZkpFqEJ uG887Q8KeVP5TViVT3E78hXWLOpN+EkSAMxJeixKSJvr1W5H1QtlEVjdvFYrpO5l kpZKiKX/O8R6JMTo/nPMq9qVu+ETaKRdgKK8llKxgGxS0NYZR6SV751xzTWpoMi6 NrA4J20MjfGCHPuIvqNa0JOuf+CO4zCnBE6lIb5o3x28qr+V518XuZzJEaLAfaIt UkpNZP6CcOxH8jPes9TJ6zyB2zTDJsrwVh6JBdUUGkND33jNOY7LrUVx9vQ4Mmpw Jj4o5bUFH2uZdZf/Oy9ZabiEXddykG6867mJmJIFreCua4s4FI82s9yzpP5twck= =RutU -----END PGP SIGNATURE----- --HlL+5n6rz5pIUxbD--