1. 13 11月, 2017 9 次提交
  2. 26 10月, 2017 1 次提交
    • R
      perf symbols: Fix memory corruption because of zero length symbols · 331c7cb3
      Ravi Bangoria 提交于
      Perf top is often crashing at very random locations on powerpc.  After
      investigating, I found the crash only happens when sample is of zero
      length symbol. Powerpc kernel has many such symbols which does not
      contain length details in vmlinux binary and thus start and end
      addresses of such symbols are same.
      
      Structure
      
        struct sym_hist {
              u64                   nr_samples;
              u64                   period;
              struct sym_hist_entry addr[0];
        };
      
      has last member 'addr[]' of size zero. 'addr[]' is an array of addresses
      that belongs to one symbol (function). If function consist of 100
      instructions, 'addr' points to an array of 100 'struct sym_hist_entry'
      elements. For zero length symbol, it points to the *empty* array, i.e.
      no members in the array and thus offset 0 is also invalid for such
      array.
      
        static int __symbol__inc_addr_samples(...)
        {
              ...
              offset = addr - sym->start;
              h = annotation__histogram(notes, evidx);
              h->nr_samples++;
              h->addr[offset].nr_samples++;
              h->period += sample->period;
              h->addr[offset].period += sample->period;
              ...
        }
      
      Here, when 'addr' is same as 'sym->start', 'offset' becomes 0, which is
      valid for normal symbols but *invalid* for zero length symbols and thus
      updating h->addr[offset] causes memory corruption.
      
      Fix this by adding one dummy element for zero length symbols.
      
      Link: https://lkml.org/lkml/2016/10/10/148
      Fixes: edee44be ("perf annotate: Don't throw error for zero length symbols")
      Signed-off-by: NRavi Bangoria <ravi.bangoria@linux.vnet.ibm.com>
      Acked-by: NJiri Olsa <jolsa@kernel.org>
      Acked-by: NNamhyung Kim <namhyung@kernel.org>
      Cc: Alexander Shishkin <alexander.shishkin@linux.intel.com>
      Cc: Jin Yao <yao.jin@linux.intel.com>
      Cc: Kim Phillips <kim.phillips@arm.com>
      Cc: Naveen N. Rao <naveen.n.rao@linux.vnet.ibm.com>
      Cc: Peter Zijlstra <peterz@infradead.org>
      Cc: Taeung Song <treeze.taeung@gmail.com>
      Link: http://lkml.kernel.org/r/1508854806-10542-1-git-send-email-ravi.bangoria@linux.vnet.ibm.comSigned-off-by: NArnaldo Carvalho de Melo <acme@redhat.com>
      331c7cb3
  3. 23 10月, 2017 1 次提交
  4. 18 8月, 2017 1 次提交
  5. 28 7月, 2017 1 次提交
  6. 27 7月, 2017 1 次提交
  7. 26 7月, 2017 1 次提交
  8. 25 7月, 2017 1 次提交
  9. 21 7月, 2017 4 次提交
  10. 19 7月, 2017 3 次提交
    • K
      perf buildid-cache: Cache debuginfo · d2396999
      Krister Johansen 提交于
      If a stripped binary is placed in the cache, the user is in a situation
      where there's a cached elf file present, but it doesn't have any symtab
      to use for name resolution.  Grab the debuginfo for binaries that don't
      end in .ko.  This yields a better chance of resolving symbols from older
      traces.
      Signed-off-by: NKrister Johansen <kjlx@templeofstupid.com>
      Cc: Alexander Shishkin <alexander.shishkin@linux.intel.com>
      Cc: Brendan Gregg <brendan.d.gregg@gmail.com>
      Cc: Peter Zijlstra <peterz@infradead.org>
      Cc: Thomas-Mich Richter <tmricht@linux.vnet.ibm.com>
      Link: http://lkml.kernel.org/r/1499305693-1599-7-git-send-email-kjlx@templeofstupid.comSigned-off-by: NArnaldo Carvalho de Melo <acme@redhat.com>
      d2396999
    • J
      perf annotate: Implement visual marker for macro fusion · 7e63a13a
      Jin Yao 提交于
      For marking fused instructions clearly this patch adds a line before the
      first instruction of pair and joins it with the arrow of the jump to its
      target.
      
      For example, when "je" is selected in annotate view, the line before
      cmpl is displayed and joins the arrow of "je".
      
             │   ┌──cmpl   $0x0,argp_program_version_hook
       81.93 │   ├──je     20
             │   │  lock   cmpxchg %esi,0x38a9a4(%rip)
             │   │↓ jne    29
             │   │↓ jmp    43
       11.47 │20:└─→cmpxch %esi,0x38a999(%rip)
      
      That means the cmpl+je is a fused instruction pair and they should be
      considered together.
      
      Changelog:
      
      v3: Use Arnaldo's fix to improve the arrow origin rendering.  To get the
          evsel->evlist->env->cpuid, save the evsel in annotate_browser.
      
      v2: new function "ins__is_fused" to check if the instructions are fused.
      Signed-off-by: NYao Jin <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: Jiri Olsa <jolsa@kernel.org>
      Cc: Kan Liang <kan.liang@intel.com>
      Cc: Peter Zijlstra <peterz@infradead.org>
      Link: http://lkml.kernel.org/r/1499403995-19857-3-git-send-email-yao.jin@linux.intel.comSigned-off-by: NArnaldo Carvalho de Melo <acme@redhat.com>
      7e63a13a
    • J
      perf annotate: Check for fused instructions · 69fb09f6
      Jin Yao 提交于
      Macro fusion merges two instructions to a single micro-op. Intel core
      platform performs this hardware optimization under limited
      circumstances.
      
      For example, CMP + JCC can be "fused" and executed /retired together.
      While with sampling this can result in the sample sometimes being on the
      JCC and sometimes on the CMP.  So for the fused instruction pair, they
      could be considered together.
      
      On Nehalem, fused instruction pairs:
      
        cmp/test + jcc.
      
      On other new CPU:
      
        cmp/test/add/sub/and/inc/dec + jcc.
      
      This patch adds an x86-specific function which checks if 2 instructions
      are in a "fused" pair. For non-x86 arch, the function is just NULL.
      
      Changelog:
      
      v4: Move the CPU model checking to symbol__disassemble and save the CPU
          family/model in arch structure.
      
          It avoids checking every time when jump arrow printed.
      
      v3: Add checking for Nehalem (CMP, TEST). For other newer Intel CPUs
          just check it by default (CMP, TEST, ADD, SUB, AND, INC, DEC).
      
      v2: Remove the original weak function. Arnaldo points out that doing it
          as a weak function that will be overridden by the host arch doesn't
          work. So now it's implemented as an arch-specific function.
      
      Committer fix:
      
      Do not access evsel->evlist->env->cpuid, ->env can be null, introduce
      perf_evsel__env_cpuid(), just like perf_evsel__env_arch(), also used in
      this function call.
      
      The original patch was segfaulting 'perf top' + annotation.
      
      But this essentially disables this fused instructions augmentation in
      'perf top', the right thing is to get the cpuid from the running kernel,
      left for a later patch tho.
      Signed-off-by: NYao Jin <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: Jiri Olsa <jolsa@kernel.org>
      Cc: Kan Liang <kan.liang@intel.com>
      Cc: Peter Zijlstra <peterz@infradead.org>
      Link: http://lkml.kernel.org/r/1499403995-19857-2-git-send-email-yao.jin@linux.intel.comSigned-off-by: NArnaldo Carvalho de Melo <acme@redhat.com>
      69fb09f6
  11. 20 6月, 2017 1 次提交
  12. 09 6月, 2017 2 次提交
  13. 02 6月, 2017 1 次提交
    • K
      perf annotate: Fix branch instruction with multiple operands · b13bbeee
      Kim Phillips 提交于
      'perf annotate' is dropping the cr* fields from branch instructions.
      
      Fix it by adding support to display branch instructions having
      multiple operands.
      
      Power Arch objdump of int_sqrt:
      
       20.36 | c0000000004d2694:   subf   r10,r10,r3
             | c0000000004d2698: v bgt    cr6,c0000000004d26a0 <int_sqrt+0x40>
        1.82 | c0000000004d269c:   mr     r3,r10
       29.18 | c0000000004d26a0:   mr     r10,r8
             | c0000000004d26a4: v bgt    cr7,c0000000004d26ac <int_sqrt+0x4c>
             | c0000000004d26a8:   mr     r10,r7
      
      Power Arch Before Patch:
      
       20.36 |       subf   r10,r10,r3
             |     v bgt    40
        1.82 |       mr     r3,r10
       29.18 | 40:   mr     r10,r8
             |     v bgt    4c
             |       mr     r10,r7
      
      Power Arch After patch:
      
       20.36 |       subf   r10,r10,r3
             |     v bgt    cr6,40
        1.82 |       mr     r3,r10
       29.18 | 40:   mr     r10,r8
             |     v bgt    cr7,4c
             |       mr     r10,r7
      
      Also support AArch64 conditional branch instructions, which can
      have up to three operands:
      
      Aarch64 Non-simplified (raw objdump) view:
      
             │ffff0000083cd11c: ↑ cbz    w0, ffff0000083cd100 <security_fil▒
      ...
        4.44 │ffff000│083cd134: ↓ tbnz   w0, #26, ffff0000083cd190 <securit▒
      ...
        1.37 │ffff000│083cd144: ↓ tbnz   w22, #5, ffff0000083cd1a4 <securit▒
             │ffff000│083cd148:   mov    w19, #0x20000                   //▒
        1.02 │ffff000│083cd14c: ↓ tbz    w22, #2, ffff0000083cd1ac <securit▒
      ...
        0.68 │ffff000└──3cd16c: ↑ cbnz   w0, ffff0000083cd120 <security_fil▒
      
      Aarch64 Simplified, before this patch:
      
             │    ↑ cbz    40
      ...
        4.44 │   │↓ tbnz   w0, #26, ffff0000083cd190 <security_file_permiss▒
      ...
        1.37 │   │↓ tbnz   w22, #5, ffff0000083cd1a4 <security_file_permiss▒
             │   │  mov    w19, #0x20000                   // #131072
        1.02 │   │↓ tbz    w22, #2, ffff0000083cd1ac <security_file_permiss▒
      ...
        0.68 │   └──cbnz   60
      
      the cbz operand is missing, and the tbz doesn't get simplified processing
      at all because the parsing function failed to match an address.
      
      Aarch64 Simplified, After this patch applied:
      
             │    ↑ cbz    w0, 40
      ...
        4.44 │   │↓ tbnz   w0, #26, d0
      ...
        1.37 │   │↓ tbnz   w22, #5, e4
             │   │  mov    w19, #0x20000                   // #131072
        1.02 │   │↓ tbz    w22, #2, ec
      ...
        0.68 │   └──cbnz   w0, 60
      Originally-by: NRavi Bangoria <ravi.bangoria@linux.vnet.ibm.com>
      Tested-by: NRavi Bangoria <ravi.bangoria@linux.vnet.ibm.com>
      Reported-by: NAnton Blanchard <anton@samba.org>
      Reported-by: NRobin Murphy <robin.murphy@arm.com>
      Signed-off-by: NKim Phillips <kim.phillips@arm.com>
      Cc: Alexander Shishkin <alexander.shishkin@linux.intel.com>
      Cc: Christian Borntraeger <borntraeger@de.ibm.com>
      Cc: Mark Rutland <mark.rutland@arm.com>
      Cc: Peter Zijlstra <peterz@infradead.org>
      Cc: Taeung Song <treeze.taeung@gmail.com>
      Link: http://lkml.kernel.org/r/20170601092959.f60d98912e8a1b66fd1e4c0e@arm.comSigned-off-by: NArnaldo Carvalho de Melo <acme@redhat.com>
      b13bbeee
  14. 27 5月, 2017 1 次提交
  15. 20 4月, 2017 5 次提交
  16. 12 4月, 2017 4 次提交
  17. 07 4月, 2017 1 次提交
  18. 05 4月, 2017 1 次提交
    • T
      perf annotate: Fix missing number of samples for source_line_samples · 99094a5e
      Taeung Song 提交于
      The option 'show-total-period' works fine without a option '-l'.  But if
      running 'perf annotate --stdio -l --show-total-period', you can see a
      problem showing only zero '0' for number of samples.
      
      Before:
          $ perf annotate --stdio -l --show-total-period
      ...
             0 :        400816:       push   %rbp
             0 :        400817:       mov    %rsp,%rbp
             0 :        40081a:       mov    %edi,-0x24(%rbp)
             0 :        40081d:       mov    %rsi,-0x30(%rbp)
             0 :        400821:       mov    -0x24(%rbp),%eax
             0 :        400824:       mov    -0x30(%rbp),%rdx
             0 :        400828:       mov    (%rdx),%esi
             0 :        40082a:       mov    $0x0,%edx
      ...
      
      The reason is it was missed to set number of samples of
      source_line_samples, so set it ordinarily.
      
      After:
          $ perf annotate --stdio -l --show-total-period
      ...
             3 :        400816:       push   %rbp
             4 :        400817:       mov    %rsp,%rbp
             0 :        40081a:       mov    %edi,-0x24(%rbp)
             0 :        40081d:       mov    %rsi,-0x30(%rbp)
             1 :        400821:       mov    -0x24(%rbp),%eax
             2 :        400824:       mov    -0x30(%rbp),%rdx
             0 :        400828:       mov    (%rdx),%esi
             1 :        40082a:       mov    $0x0,%edx
      ...
      Signed-off-by: NTaeung Song <treeze.taeung@gmail.com>
      Cc: Jiri Olsa <jolsa@kernel.org>
      Cc: Martin Liska <mliska@suse.cz>
      Cc: Masami Hiramatsu <mhiramat@kernel.org>
      Cc: Namhyung Kim <namhyung@kernel.org>
      Cc: Peter Zijlstra <peterz@infradead.org>
      Cc: Wang Nan <wangnan0@huawei.com>
      Fixes: 0c4a5bce ("perf annotate: Display total number of samples with --show-total-period")
      Link: http://lkml.kernel.org/r/1490703125-13643-1-git-send-email-treeze.taeung@gmail.comSigned-off-by: NArnaldo Carvalho de Melo <acme@redhat.com>
      99094a5e
  19. 28 3月, 2017 1 次提交
    • T
      perf annotate: Fix a bug of division by zero when calculating percent · 2e933b12
      Taeung Song 提交于
      Currently perf-annotate with --print-line can print
      -nan(0x8000000000000) because of division by zero when calculating
      percent. The division by zero happens when a sum of samples is zero in
      symbol__get_source_line(), so fix it.
      
      For example:
      
      After running 'perf record' like below,
      
          $ perf record -e "{cycles,page-faults,branch-misses}" ./a.out
      
      Before:
      
          $ perf annotate --stdio -l
      
        Sorted summary for file /home/taeung/workspace/a.out
        ----------------------------------------------
      
         32.89    -nan    7.04 a.c:38
         25.14    -nan    0.00 a.c:34
         16.26    -nan   56.34 a.c:31
         15.88    -nan    1.41 a.c:37
          5.67    -nan    0.00 a.c:39
          1.13    -nan   35.21 a.c:26
          0.95    -nan    0.00 a.c:44
          0.57    -nan    0.00 a.c:32
         Percent                 |      Source code & Disassembly of a.out for cycles (529 samples)
        -----------------------------------------------------------------------------------------
                               :
        ...
      
         a.c:26    0.57    -nan    4.23 :         40081a:       mov    %edi,-0x24(%rbp)
         a.c:26    0.00    -nan    9.86 :         40081d:       mov    %rsi,-0x30(%rbp)
      
        ...
      
      However, if a sum of samples is zero (e.g. 'page-faults'),
      skip calculating percent.
      
      After:
      
          $ perf annotate --stdio -l
      
        Sorted summary for file /home/taeung/workspace/a.out
        ----------------------------------------------
      
         32.89    0.00    7.04 a.c:38
         25.14    0.00    0.00 a.c:34
         16.26    0.00   56.34 a.c:31
         15.88    0.00    1.41 a.c:37
          5.67    0.00    0.00 a.c:39
          1.13    0.00   35.21 a.c:26
          0.95    0.00    0.00 a.c:44
          0.57    0.00    0.00 a.c:32
         Percent                 |      Source code & Disassembly of old for cycles (529 samples)
        -----------------------------------------------------------------------------------------
                               :
        ...
      
        a.c:26    0.57    0.00    4.23 :         40081a:       mov    %edi,-0x24(%rbp)
        a.c:26    0.00    0.00    9.86 :         40081d:       mov    %rsi,-0x30(%rbp)
      
        ...
      Signed-off-by: NTaeung Song <treeze.taeung@gmail.com>
      Tested-by: NArnaldo Carvalho de Melo <acme@redhat.com>
      Cc: Jiri Olsa <jolsa@redhat.com>
      Cc: Masami Hiramatsu <mhiramat@kernel.org>
      Cc: Namhyung Kim <namhyung@kernel.org>
      Cc: Peter Zijlstra <peterz@infradead.org>
      Cc: Wang Nan <wangnan0@huawei.com>
      Link: http://lkml.kernel.org/r/1490598638-13947-3-git-send-email-treeze.taeung@gmail.comSigned-off-by: NArnaldo Carvalho de Melo <acme@redhat.com>
      2e933b12