1. 27 12月, 2019 2 次提交
    • J
      perf annotate: Remove hist__account_cycles() from callback · f83e4568
      Jin Yao 提交于
      mainline inclusion
      from mainline-5.2-rc1
      commit bdd1666b3d03
      category: bugfix
      bugzilla: 16426
      CVE: NA
      
      -------------------------------------------------
      
      The hist__account_cycles() function is executed when the
      hist_iter__branch_callback() is called.
      
      But it looks it's not necessary.  In hist__account_cycles, it already
      walks on all branch entries.
      
      This patch moves the hist__account_cycles out of callback, now the data
      processing is much faster than before.
      
      Previous code has an issue that the ch[offset].num++ (in
      __symbol__account_cycles) is executed repeatedly since
      hist__account_cycles is called in each hist_iter__branch_callback, so
      the counting of ch[offset].num is not correct (too big).
      
      With this patch, the issue is fixed. And we don't need the code of
      "ch->reset >= ch->num / 2" to check if there are too many overlaps (in
      annotation__count_and_fill), otherwise some data would be hidden.
      
      Now, we can try, for example:
      
        perf record -b ...
        perf annotate or perf report -s symbol
      
      The before/after output should be no change.
      
       v3:
       ---
       Fix the crash in stdio mode.
       Like previous code, it needs the checking of ui__has_annotation()
       before hist__account_cycles()
      
       v2:
       ---
       1. Cover the similar perf report
       2. Remove the checking code "ch->reset >= ch->num / 2"
      Signed-off-by: NJin Yao <yao.jin@linux.intel.com>
      Tested-by: NArnaldo Carvalho de Melo <acme@redhat.com>
      Cc: Alexander Shishkin <alexander.shishkin@linux.intel.com>
      Cc: Andi Kleen <ak@linux.intel.com>
      Cc: Jin Yao <yao.jin@intel.com>
      Cc: Jiri Olsa <jolsa@kernel.org>
      Cc: Kan Liang <kan.liang@linux.intel.com>
      Cc: Peter Zijlstra <peterz@infradead.org>
      Link: http://lkml.kernel.org/r/1552684577-29041-1-git-send-email-yao.jin@linux.intel.comSigned-off-by: NArnaldo Carvalho de Melo <acme@redhat.com>
      Signed-off-by: NWei Li <liwei391@huawei.com>
      Reviewed-by: NJian Cheng <cj.chengjian@huawei.com>
      Signed-off-by: NYang Yingliang <yangyingliang@huawei.com>
      f83e4568
    • W
      perf: fix incorrect change in annotate result · 7e5c7786
      Wei Li 提交于
      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>
      7e5c7786
  2. 31 8月, 2018 2 次提交
    • K
      perf annotate: Fix parsing aarch64 branch instructions after objdump update · 4e67b2a5
      Kim Phillips 提交于
      Starting with binutils 2.28, aarch64 objdump adds comments to the
      disassembly output to show the alternative names of a condition code
      [1].
      
      It is assumed that commas in objdump comments could occur in other
      arches now or in the future, so this fix is arch-independent.
      
      The fix could have been done with arm64 specific jump__parse and
      jump__scnprintf functions, but the jump__scnprintf instruction would
      have to have its comment character be a literal, since the scnprintf
      functions cannot receive a struct arch easily.
      
      This inconvenience also applies to the generic jump__scnprintf, which is
      why we add a raw_comment pointer to struct ins_operands, so the __parse
      function assigns it to be re-used by its corresponding __scnprintf
      function.
      
      Example differences in 'perf annotate --stdio2' output on an aarch64
      perf.data file:
      
      BEFORE: → b.cs   ffff200008133d1c <unwind_frame+0x18c>  // b.hs, dffff7ecc47b
      AFTER : ↓ b.cs   18c
      
      BEFORE: → b.cc   ffff200008d8d9cc <get_alloc_profile+0x31c>  // b.lo, b.ul, dffff727295b
      AFTER : ↓ b.cc   31c
      
      The branch target labels 18c and 31c also now appear in the output:
      
      BEFORE:        add    x26, x29, #0x80
      AFTER : 18c:   add    x26, x29, #0x80
      
      BEFORE:        add    x21, x21, #0x8
      AFTER : 31c:   add    x21, x21, #0x8
      
      The Fixes: tag below is added so stable branches will get the update; it
      doesn't necessarily mean that commit was broken at the time, rather it
      didn't withstand the aarch64 objdump update.
      
      Tested no difference in output for sample x86_64, power arch perf.data files.
      
      [1] https://sourceware.org/git/gitweb.cgi?p=binutils-gdb.git;a=commit;h=bb7eff5206e4795ac79c177a80fe9f4630aaf730Signed-off-by: NKim Phillips <kim.phillips@arm.com>
      Tested-by: NArnaldo Carvalho de Melo <acme@redhat.com>
      Cc: Alexander Shishkin <alexander.shishkin@linux.intel.com>
      Cc: Anton Blanchard <anton@samba.org>
      Cc: Christian Borntraeger <borntraeger@de.ibm.com>
      Cc: Jiri Olsa <jolsa@redhat.com>
      Cc: Mark Rutland <mark.rutland@arm.com>
      Cc: Namhyung Kim <namhyung@kernel.org>
      Cc: Peter Zijlstra <peterz@infradead.org>
      Cc: Ravi Bangoria <ravi.bangoria@linux.vnet.ibm.com>
      Cc: Robin Murphy <robin.murphy@arm.com>
      Cc: Taeung Song <treeze.taeung@gmail.com>
      Cc: linux-arm-kernel@lists.infradead.org
      Fixes: b13bbeee ("perf annotate: Fix branch instruction with multiple operands")
      Link: http://lkml.kernel.org/r/20180827125340.a2f7e291901d17cea05daba4@arm.comSigned-off-by: NArnaldo Carvalho de Melo <acme@redhat.com>
      4e67b2a5
    • M
      perf annotate: Properly interpret indirect call · 1dc27f63
      Martin Liška 提交于
      The patch changes the parsing of:
      
      	callq  *0x8(%rbx)
      
      from:
      
        0.26 │     → callq  *8
      
      to:
      
        0.26 │     → callq  *0x8(%rbx)
      
      in this case an address is followed by a register, thus one can't parse
      only the address.
      
      Committer testing:
      
      1) run 'perf record sleep 10'
      2) before applying the patch, run:
      
           perf annotate --stdio2 > /tmp/before
      
      3) after applying the patch, run:
      
           perf annotate --stdio2 > /tmp/after
      
      4) diff /tmp/before /tmp/after:
        --- /tmp/before 2018-08-28 11:16:03.238384143 -0300
        +++ /tmp/after  2018-08-28 11:15:39.335341042 -0300
        @@ -13274,7 +13274,7 @@
                      ↓ jle    128
                        hash_value = hash_table->hash_func (key);
                        mov    0x8(%rsp),%rdi
        -  0.91       → callq  *30
        +  0.91       → callq  *0x30(%r12)
                        mov    $0x2,%r8d
                        cmp    $0x2,%eax
                        node_hash = hash_table->hashes[node_index];
        @@ -13848,7 +13848,7 @@
                         mov    %r14,%rdi
                         sub    %rbx,%r13
                         mov    %r13,%rdx
        -              → callq  *38
        +              → callq  *0x38(%r15)
                         cmp    %rax,%r13
           1.91        ↓ je     240
                  1b4:   mov    $0xffffffff,%r13d
        @@ -14026,7 +14026,7 @@
                         mov    %rcx,-0x500(%rbp)
                         mov    %r15,%rsi
                         mov    %r14,%rdi
        -              → callq  *38
        +              → callq  *0x38(%rax)
                         mov    -0x500(%rbp),%rcx
                         cmp    %rax,%rcx
                       ↓ jne    9b0
      <SNIP tons of other such cases>
      Signed-off-by: NMartin Liška <mliska@suse.cz>
      Tested-by: NArnaldo Carvalho de Melo <acme@redhat.com>
      Tested-by: NKim Phillips <kim.phillips@arm.com>
      Cc: Jiri Olsa <jolsa@redhat.com>
      Link: http://lkml.kernel.org/r/bd1f3932-be2b-85f9-7582-111ee0a43b07@suse.czSigned-off-by: NArnaldo Carvalho de Melo <acme@redhat.com>
      1dc27f63
  3. 20 8月, 2018 1 次提交
  4. 09 8月, 2018 17 次提交
  5. 06 6月, 2018 1 次提交
    • A
      perf annnotate: Make __symbol__inc_addr_samples handle src->histograms == NULL · 8d628d26
      Arnaldo Carvalho de Melo 提交于
      Making it a bit more robust, this took place here when a sample appeared
      right after:
      
        ffffffff8a925000 D __nosave_end
      
      And before the next considered symbol, which, using kallsyms make us
      over guess the size of __nosave_end, and then the sequence:
      
        hist_entry__inc_addr_samples ->
          symbol__inc_addr_samples ->
            symbol__hists ->
              annotated_source__alloc_histograms
      
      Ends up not liking to allocate gigabytes of ram for annotation...
      
      This will be alleviated by considering BSS symbols, which we should but
      don't so far, and then we should investigate those samples further.
      
      The testcase was to have:
      
         perf top -e cycles/call-graph=fp/,cache-misses/call-graph=dwarf/,instructions
      
      Running for a while till it segfaulted trying to access NULL notes->src->histograms.
      
      Cc: Adrian Hunter <adrian.hunter@intel.com>
      Cc: David Ahern <dsahern@gmail.com>
      Cc: Jiri Olsa <jolsa@kernel.org>
      Cc: Namhyung Kim <namhyung@kernel.org>
      Cc: Wang Nan <wangnan0@huawei.com>
      Link: https://lkml.kernel.org/n/tip-ndfjtpiop3tdcnyjgp320ra8@git.kernel.orgSigned-off-by: NArnaldo Carvalho de Melo <acme@redhat.com>
      8d628d26
  6. 04 6月, 2018 15 次提交
  7. 23 5月, 2018 1 次提交
  8. 19 5月, 2018 1 次提交
    • J
      perf annotate: Create hotkey 'c' to show min/max cycles · 3e71fc03
      Jin Yao 提交于
      In the 'perf annotate' view, a new hotkey 'c' is created for showing the
      min/max cycles.
      
      For example, when press 'c', the annotate view is:
      
        Percent│ IPC     Cycle(min/max)
               │
               │
               │                             Disassembly of section .text:
               │
               │                             000000000003aab0 <random@@GLIBC_2.2.5>:
          8.22 │3.92                           sub    $0x18,%rsp
               │3.92                           mov    $0x1,%esi
               │3.92                           xor    %eax,%eax
               │3.92                           cmpl   $0x0,argp_program_version_hook@@G
               │3.92             1(2/1)      ↓ je     20
               │                               lock   cmpxchg %esi,__abort_msg@@GLIBC_P
               │                             ↓ jne    29
               │                             ↓ jmp    43
               │1.10                     20:   cmpxchg %esi,__abort_msg@@GLIBC_PRIVATE+
          8.93 │1.10             1(5/1)      ↓ je     43
      
      When press 'c' again, the annotate view is switched back:
      
        Percent│ IPC Cycle
               │
               │
               │                Disassembly of section .text:
               │
               │                000000000003aab0 <random@@GLIBC_2.2.5>:
          8.22 │3.92              sub    $0x18,%rsp
               │3.92              mov    $0x1,%esi
               │3.92              xor    %eax,%eax
               │3.92              cmpl   $0x0,argp_program_version_hook@@GLIBC_2.2.5+0x
               │3.92     1      ↓ je     20
               │                  lock   cmpxchg %esi,__abort_msg@@GLIBC_PRIVATE+0x8a0
               │                ↓ jne    29
               │                ↓ jmp    43
               │1.10        20:   cmpxchg %esi,__abort_msg@@GLIBC_PRIVATE+0x8a0
          8.93 │1.10     1      ↓ je     43
      Signed-off-by: NJin Yao <yao.jin@linux.intel.com>
      Cc: Alexander Shishkin <alexander.shishkin@linux.intel.com>
      Cc: Andi Kleen <ak@linux.intel.com>
      Cc: Jiri Olsa <jolsa@kernel.org>
      Cc: Kan Liang <kan.liang@linux.intel.com>
      Cc: Peter Zijlstra <peterz@infradead.org>
      Link: http://lkml.kernel.org/r/1526569118-14217-3-git-send-email-yao.jin@linux.intel.com
      [ Rename all maxmin to minmax ]
      Signed-off-by: NArnaldo Carvalho de Melo <acme@redhat.com>
      3e71fc03