1. 27 2月, 2020 2 次提交
    • R
      perf annotate: Prefer cmdline option over default config · 812b0f52
      Ravi Bangoria 提交于
      For all the perf-config options that can also be set from command line
      option, the preference is given to command line version in case of any
      conflict. But that's opposite in case of perf annotate. i.e. the more
      preference is given to default option rather than command line option.
      Fix it.
      
      Before:
      
        $ ./perf config
        annotate.show_nr_samples=false
      
        $ ./perf annotate shash --show-nr-samples
        Percent│
               │24:   mov    -0xc(%rbp),%eax
         49.19 │      imul   $0x1003f,%eax,%ecx
               │      mov    -0x18(%rbp),%rax
      
      After:
      
        Samples│
               │24:   mov    -0xc(%rbp),%eax
             1 │      imul   $0x1003f,%eax,%ecx
               │      mov    -0x18(%rbp),%rax
      Signed-off-by: NRavi Bangoria <ravi.bangoria@linux.ibm.com>
      Tested-by: NArnaldo Carvalho de Melo <acme@redhat.com>
      Cc: Adrian Hunter <adrian.hunter@intel.com>
      Cc: Alexey Budankov <alexey.budankov@linux.intel.com>
      Cc: Changbin Du <changbin.du@intel.com>
      Cc: Ian Rogers <irogers@google.com>
      Cc: Jin Yao <yao.jin@linux.intel.com>
      Cc: Jiri Olsa <jolsa@kernel.org>
      Cc: Leo Yan <leo.yan@linaro.org>
      Cc: Namhyung Kim <namhyung@kernel.org>
      Cc: Song Liu <songliubraving@fb.com>
      Cc: Taeung Song <treeze.taeung@gmail.com>
      Cc: Thomas Richter <tmricht@linux.ibm.com>
      Cc: Yisheng Xie <xieyisheng1@huawei.com>
      Link: http://lore.kernel.org/lkml/20200213064306.160480-7-ravi.bangoria@linux.ibm.comSigned-off-by: NArnaldo Carvalho de Melo <acme@redhat.com>
      812b0f52
    • R
      perf annotate: Make perf config effective · 7384083b
      Ravi Bangoria 提交于
      perf default config set by user in [annotate] section is totally ignored
      by annotate code. Fix it.
      
      Before:
      
        $ ./perf config
        annotate.hide_src_code=true
        annotate.show_nr_jumps=true
        annotate.show_nr_samples=true
      
        $ ./perf annotate shash
               │    unsigned h = 0;
               │      movl   $0x0,-0xc(%rbp)
               │    while (*s)
               │    ↓ jmp    44
               │    h = 65599 * h + *s++;
         11.33 │24:   mov    -0xc(%rbp),%eax
         43.50 │      imul   $0x1003f,%eax,%ecx
               │      mov    -0x18(%rbp),%rax
      
      After:
      
               │        movl   $0x0,-0xc(%rbp)
               │      ↓ jmp    44
             1 │1 24:   mov    -0xc(%rbp),%eax
             4 │        imul   $0x1003f,%eax,%ecx
               │        mov    -0x18(%rbp),%rax
      
      Note that we have removed show_nr_samples and show_total_period from
      annotation_options because they are not used. Instead of them we use
      symbol_conf.show_nr_samples and symbol_conf.show_total_period.
      
      Committer testing:
      
      Using 'perf annotate --stdio2' to use the TUI rendering but emitting the output to stdio:
      
        # perf config
        #
        # perf config annotate.hide_src_code=true
        # perf config
        annotate.hide_src_code=true
        #
        # perf config annotate.show_nr_jumps=true
        # perf config annotate.show_nr_samples=true
        # perf config
        annotate.hide_src_code=true
        annotate.show_nr_jumps=true
        annotate.show_nr_samples=true
        #
        #
      
      Before:
      
        # perf annotate --stdio2 ObjectInstance::weak_pointer_was_finalized
        Samples: 1  of event 'cycles', 4000 Hz, Event count (approx.): 830873, [percent: local period]
        ObjectInstance::weak_pointer_was_finalized() /usr/lib64/libgjs.so.0.0.0
        Percent
                    00000000000609f0 <ObjectInstance::weak_pointer_was_finalized()@@base>:
                      endbr64
                      cmpq    $0x0,0x20(%rdi)
                    ↓ je      10
                      xor     %eax,%eax
                    ← retq
                      xchg    %ax,%ax
        100.00  10:   push    %rbp
                      cmpq    $0x0,0x18(%rdi)
                      mov     %rdi,%rbp
                    ↓ jne     20
                1b:   xor     %eax,%eax
                      pop     %rbp
                    ← retq
                      nop
                20:   lea     0x18(%rdi),%rdi
                    → callq   JS_UpdateWeakPointerAfterGC(JS::Heap<JSObject*
                      cmpq    $0x0,0x18(%rbp)
                    ↑ jne     1b
                      mov     %rbp,%rdi
                    → callq   ObjectBase::jsobj_addr() const@plt
                      mov     $0x1,%eax
                      pop     %rbp
                    ← retq
        #
      
      After:
      
        # perf annotate --stdio2 ObjectInstance::weak_pointer_was_finalized 2> /dev/null
        Samples: 1  of event 'cycles', 4000 Hz, Event count (approx.): 830873, [percent: local period]
        ObjectInstance::weak_pointer_was_finalized() /usr/lib64/libgjs.so.0.0.0
        Samples       endbr64
                      cmpq    $0x0,0x20(%rdi)
                    ↓ je      10
                      xor     %eax,%eax
                    ← retq
                      xchg    %ax,%ax
           1  1 10:   push    %rbp
                      cmpq    $0x0,0x18(%rdi)
                      mov     %rdi,%rbp
                    ↓ jne     20
              1 1b:   xor     %eax,%eax
                      pop     %rbp
                    ← retq
                      nop
              1 20:   lea     0x18(%rdi),%rdi
                    → callq   JS_UpdateWeakPointerAfterGC(JS::Heap<JSObject*
                      cmpq    $0x0,0x18(%rbp)
                    ↑ jne     1b
                      mov     %rbp,%rdi
                    → callq   ObjectBase::jsobj_addr() const@plt
                      mov     $0x1,%eax
                      pop     %rbp
                    ← retq
        #
        # perf config annotate.show_nr_jumps
        annotate.show_nr_jumps=true
        # perf config annotate.show_nr_jumps=false
        # perf config annotate.show_nr_jumps
        annotate.show_nr_jumps=false
        #
        # perf annotate --stdio2 ObjectInstance::weak_pointer_was_finalized 2> /dev/null
        Samples: 1  of event 'cycles', 4000 Hz, Event count (approx.): 830873, [percent: local period]
        ObjectInstance::weak_pointer_was_finalized() /usr/lib64/libgjs.so.0.0.0
        Samples       endbr64
                      cmpq    $0x0,0x20(%rdi)
                    ↓ je      10
                      xor     %eax,%eax
                    ← retq
                      xchg    %ax,%ax
             1  10:   push    %rbp
                      cmpq    $0x0,0x18(%rdi)
                      mov     %rdi,%rbp
                    ↓ jne     20
                1b:   xor     %eax,%eax
                      pop     %rbp
                    ← retq
                      nop
                20:   lea     0x18(%rdi),%rdi
                    → callq   JS_UpdateWeakPointerAfterGC(JS::Heap<JSObject*
                      cmpq    $0x0,0x18(%rbp)
                    ↑ jne     1b
                      mov     %rbp,%rdi
                    → callq   ObjectBase::jsobj_addr() const@plt
                      mov     $0x1,%eax
                      pop     %rbp
                    ← retq
        #
      Signed-off-by: NRavi Bangoria <ravi.bangoria@linux.ibm.com>
      Tested-by: NArnaldo Carvalho de Melo <acme@redhat.com>
      Cc: Adrian Hunter <adrian.hunter@intel.com>
      Cc: Alexey Budankov <alexey.budankov@linux.intel.com>
      Cc: Changbin Du <changbin.du@intel.com>
      Cc: Ian Rogers <irogers@google.com>
      Cc: Jin Yao <yao.jin@linux.intel.com>
      Cc: Jiri Olsa <jolsa@kernel.org>
      Cc: Leo Yan <leo.yan@linaro.org>
      Cc: Namhyung Kim <namhyung@kernel.org>
      Cc: Song Liu <songliubraving@fb.com>
      Cc: Taeung Song <treeze.taeung@gmail.com>
      Cc: Thomas Richter <tmricht@linux.ibm.com>
      Cc: Yisheng Xie <xieyisheng1@huawei.com>
      Link: http://lore.kernel.org/lkml/20200213064306.160480-6-ravi.bangoria@linux.ibm.comSigned-off-by: NArnaldo Carvalho de Melo <acme@redhat.com>
      7384083b
  2. 14 1月, 2020 1 次提交
    • A
      perf tools: Support --prefix/--prefix-strip · 3b0b16bf
      Andi Kleen 提交于
      The objdump utility has useful --prefix / --prefix-strip options to
      allow changing source code file names hardcoded into executables' debug
      info. Add options to 'perf report', 'perf top' and 'perf annotate',
      which are then passed to objdump.
      
        $ mkdir foo
        $ echo 'main() { for (;;); }' > foo/foo.c
        $ gcc -g foo/foo.c
        foo/foo.c:1:1: warning: return type defaults to ‘int’ [-Wimplicit-int]
            1 | main() { for (;;); }
              | ^~~~
        $ perf record ./a.out
        ^C[ perf record: Woken up 1 times to write data ]
        [ perf record: Captured and wrote 0.230 MB perf.data (5721 samples) ]
        $ mv foo bar
        $ perf annotate
        <does not show source code>
        $ perf annotate --prefix=/home/ak/lsrc/git/bar --prefix-strip=5
        <does show source code>
      Signed-off-by: NAndi Kleen <ak@linux.intel.com>
      Tested-by: NJiri Olsa <jolsa@redhat.com>
      LPU-Reference: 20200107210444.214071-1-andi@firstfloor.org
      Signed-off-by: NArnaldo Carvalho de Melo <acme@redhat.com>
      3b0b16bf
  3. 12 11月, 2019 2 次提交
  4. 07 11月, 2019 1 次提交
  5. 21 9月, 2019 1 次提交
  6. 20 9月, 2019 1 次提交
  7. 01 9月, 2019 3 次提交
  8. 30 7月, 2019 1 次提交
  9. 09 7月, 2019 1 次提交
  10. 16 5月, 2019 1 次提交
    • J
      perf annotate: Remove hist__account_cycles() from callback · bdd1666b
      Jin Yao 提交于
      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>
      bdd1666b
  11. 23 2月, 2019 1 次提交
    • J
      perf data: Add global path holder · 2d4f2799
      Jiri Olsa 提交于
      Add a 'path' member to 'struct perf_data'. It will keep the configured
      path for the data (const char *). The path in struct perf_data_file is
      now dynamically allocated (duped) from it.
      
      This scheme is useful/used in following patches where struct
      perf_data::path holds the 'configure' directory path and struct
      perf_data_file::path holds the allocated path for specific files.
      
      Also it actually makes the code little simpler.
      Signed-off-by: NJiri Olsa <jolsa@kernel.org>
      Cc: Adrian Hunter <adrian.hunter@intel.com>
      Cc: Alexander Shishkin <alexander.shishkin@linux.intel.com>
      Cc: Alexey Budankov <alexey.budankov@linux.intel.com>
      Cc: Andi Kleen <ak@linux.intel.com>
      Cc: Namhyung Kim <namhyung@kernel.org>
      Cc: Peter Zijlstra <peterz@infradead.org>
      Cc: Stephane Eranian <eranian@google.com>
      Link: http://lkml.kernel.org/r/20190221094145.9151-3-jolsa@kernel.org
      [ Fixup data-convert-bt.c missing conversion ]
      Signed-off-by: NArnaldo Carvalho de Melo <acme@redhat.com>
      2d4f2799
  12. 06 2月, 2019 1 次提交
  13. 25 1月, 2019 2 次提交
  14. 19 9月, 2018 1 次提交
  15. 09 8月, 2018 1 次提交
    • J
      perf annotate: Add --percent-type option · 88c21190
      Jiri Olsa 提交于
      Add --percent-type option to set annotation percent type from following
      choices:
      
        global-period, local-period, global-hits, local-hits
      
      Examples:
      
        $ perf annotate --percent-type period-local --stdio | head -1
         Percent         |      Source code ... es, percent: local period)
        $ perf annotate --percent-type hits-local --stdio | head -1
         Percent         |      Source code ... es, percent: local hits)
        $ perf annotate --percent-type hits-global --stdio | head -1
         Percent         |      Source code ... es, percent: global hits)
        $ perf annotate --percent-type period-global --stdio | head -1
         Percent         |      Source code ... es, percent: global period)
      
      The local/global keywords set if the percentage is computed in the scope
      of the function (local) or the whole data (global).
      
      The period/hits keywords set the base the percentage is computed on -
      the samples period or the number of samples (hits).
      Signed-off-by: NJiri Olsa <jolsa@kernel.org>
      Tested-by: NArnaldo Carvalho de Melo <acme@redhat.com>
      Cc: Alexander Shishkin <alexander.shishkin@linux.intel.com>
      Cc: David Ahern <dsahern@gmail.com>
      Cc: Namhyung Kim <namhyung@kernel.org>
      Cc: Peter Zijlstra <peterz@infradead.org>
      Cc: Stephane Eranian <eranian@google.com>
      Link: http://lkml.kernel.org/r/20180804130521.11408-20-jolsa@kernel.orgSigned-off-by: NArnaldo Carvalho de Melo <acme@redhat.com>
      88c21190
  16. 25 6月, 2018 1 次提交
    • R
      perf tools: Fix crash caused by accessing feat_ops[HEADER_LAST_FEATURE] · 92ead7ee
      Ravi Bangoria 提交于
      perf_event__process_feature() accesses feat_ops[HEADER_LAST_FEATURE]
      which is not defined and thus perf is crashing. HEADER_LAST_FEATURE is
      used as an end marker for the perf report but it's unused for perf
      script/annotate. Ignore HEADER_LAST_FEATURE for perf script/annotate,
      just like it is done in 'perf report'.
      
      Before:
        # perf record -o - ls | perf script
        <SNIP 'ls' output>
        Segmentation fault (core dumped)
        #
      
      After:
        # perf record -o - ls | perf script
        <SNIP 'ls' output>
        Segmentation fault (core dumped)
        ls 7031 4392.099856:  250000 cpu-clock:uhH:  7f5e0ce7cd60
        ls 7031 4392.100355:  250000 cpu-clock:uhH:  7f5e0c706ef7
        #
      Signed-off-by: NRavi Bangoria <ravi.bangoria@linux.ibm.com>
      Cc: Alexander Shishkin <alexander.shishkin@linux.intel.com>
      Cc: Andi Kleen <ak@linux.intel.com>
      Cc: David Ahern <dsahern@gmail.com>
      Cc: David Carrillo-Cisneros <davidcc@google.com>
      Cc: Jin Yao <yao.jin@linux.intel.com>
      Cc: Jiri Olsa <jolsa@redhat.com>
      Cc: Namhyung Kim <namhyung@kernel.org>
      Fixes: 57b5de46 ("perf report: Support forced leader feature in pipe mode")
      Link: http://lkml.kernel.org/r/20180625124220.6434-4-ravi.bangoria@linux.ibm.comSigned-off-by: NArnaldo Carvalho de Melo <acme@redhat.com>
      92ead7ee
  17. 04 6月, 2018 6 次提交
  18. 22 5月, 2018 1 次提交
    • J
      perf annotate: Support '--group' option · 7ebaf489
      Jin Yao 提交于
      With the '--group' option, even for non-explicit group, 'perf annotate'
      will enable the group output.
      
      For example,
      
        $ perf record -e cycles,branches ./div
        $ perf annotate main --stdio --group
      
                       :            Disassembly of section .text:
                       :
                       :            00000000004004b0 <main>:
                       :            main():
                       :
                       :                    return i;
                       :            }
                       :
                       :            int main(void)
                       :            {
          0.00    0.00 :   4004b0:       push   %rbx
                       :                    int i;
                       :                    int flag;
                       :                    volatile double x = 1212121212, y = 121212;
                       :
                       :                    s_randseed = time(0);
          0.00    0.00 :   4004b1:       xor    %edi,%edi
                       :                    srand(s_randseed);
          0.00    0.00 :   4004b3:       mov    $0x77359400,%ebx
                       :
                       :                    return i;
                       :            }
                       :
      
      But if without --group, there is only one event reported.
      
        $ perf annotate main --stdio
      
               :            Disassembly of section .text:
               :
               :            00000000004004b0 <main>:
               :            main():
               :
               :                    return i;
               :            }
               :
               :            int main(void)
               :            {
          0.00 :   4004b0:       push   %rbx
               :                    int i;
               :                    int flag;
               :                    volatile double x = 1212121212, y = 121212;
               :
               :                    s_randseed = time(0);
          0.00 :   4004b1:       xor    %edi,%edi
               :                    srand(s_randseed);
          0.00 :   4004b3:       mov    $0x77359400,%ebx
               :
               :                    return i;
               :            }
      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: 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/1526914666-31839-4-git-send-email-yao.jin@linux.intel.comSigned-off-by: NArnaldo Carvalho de Melo <acme@redhat.com>
      7ebaf489
  19. 27 4月, 2018 1 次提交
    • A
      perf symbols: Unify symbol maps · 3183f8ca
      Arnaldo Carvalho de Melo 提交于
      Remove the split of symbol tables for data (MAP__VARIABLE) and for
      functions (MAP__FUNCTION), its unneeded and there were various places
      doing two lookups to find a symbol, so simplify this.
      
      We still will consider only the symbols that matched the filters in
      place, i.e. see the (elf_(sec,sym)|symbol_type)__filter() routines in
      the patch, just so that we consider only the same symbols as before,
      to reduce the possibility of regressions.
      
      All the tests on 50-something build environments, in varios versions
      of lots of distros and cross build environments were performed without
      build regressions, as usual with all pull requests the other tests were
      also performed: 'perf test' and 'make -C tools/perf build-test'.
      
      Also this was done at a great granularity so that regressions can be
      bisected more easily.
      
      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-hiq0fy2rsleupnqqwuojo1ne@git.kernel.orgSigned-off-by: NArnaldo Carvalho de Melo <acme@redhat.com>
      3183f8ca
  20. 21 3月, 2018 3 次提交
    • A
      perf annotate: Introduce --ignore-vmlinux command line option · be316409
      Arnaldo Carvalho de Melo 提交于
      This is already present in 'perf top', albeit undocumented (will fix),
      and is useful to use /proc/kcore instead of vmlinux and then get what is
      really in place, not what the kernel starts with, before alternatives,
      ftrace .text patching, etc, see the differences:
      
        # perf annotate --stdio2 _raw_spin_lock_irqsave
        _raw_spin_lock_irqsave() /lib/modules/4.16.0-rc4/build/vmlinux
        Event: anon group { cycles, instructions }
      
          0.00   3.17      → callq  __fentry__
          0.00   7.94        push   %rbx
          7.69  36.51      → callq  __page_file_index
                             mov    %rax,%rbx
          7.69   3.17      → callq  *ffffffff82225cd0
                             xor    %eax,%eax
                             mov    $0x1,%edx
         80.77  49.21        lock   cmpxchg %edx,(%rdi)
                             test   %eax,%eax
                           ↓ jne    2b
          3.85   0.00        mov    %rbx,%rax
                             pop    %rbx
                           ← retq
                       2b:   mov    %eax,%esi
                           → callq  queued_spin_lock_slowpath
                             mov    %rbx,%rax
                             pop    %rbx
                           ← retq
        [root@jouet ~]# perf annotate --ignore-vmlinux --stdio2 _raw_spin_lock_irqsave
        _raw_spin_lock_irqsave() /proc/kcore
        Event: anon group { cycles, instructions }
      
          0.00   3.17        nop
          0.00   7.94        push   %rbx
          0.00  23.81        pushfq
          7.69  12.70        pop    %rax
                             nop
                             mov    %rax,%rbx
          7.69   3.17        cli
                             nop
                             xor    %eax,%eax
                             mov    $0x1,%edx
         80.77  49.21        lock   cmpxchg %edx,(%rdi)
                             test   %eax,%eax
                           ↓ jne    2b
          3.85   0.00        mov    %rbx,%rax
                             pop    %rbx
                           ← retq
                       2b:   mov    %eax,%esi
                           → callq  *ffffffff820e96b0
                             mov    %rbx,%rax
                             pop    %rbx
                           ← retq
        #
      
      Diff of the output of those commands:
      
        # perf annotate --stdio2 _raw_spin_lock_irqsave > /tmp/vmlinux
        # perf annotate --ignore-vmlinux --stdio2 _raw_spin_lock_irqsave > /tmp/kcore
        # diff -y /tmp/vmlinux /tmp/kcore
        _raw_spin_lock_irqsave() vmlinux             | _raw_spin_lock_irqsave() /proc/kcore
        Event: anon group { cycles, instructions }     Event: anon group { cycles, instructions }
      
         0.00  3.17  → callq __fentry__              |  0.00  3.17     nop
         0.00  7.94    push  %rbx                       0.00  7.94     push  %rbx
         7.69 36.51  → callq __page_file_index       |  0.00 23.81     pushfq
                                                     >  7.69 12.70     pop   %rax
                                                     >                 nop
                       mov   %rax,%rbx                                 mov   %rax,%rbx
         7.69  3.17  → callq *ffffffff82225cd0       |  7.69  3.17     cli
                                                     >                 nop
                       xor   %eax,%eax                                 xor   %eax,%eax
                       mov   $0x1,%edx                                 mov   $0x1,%edx
        80.77 49.21    lock  cmpxchg %edx,(%rdi)       80.77 49.21     lock  cmpxchg %edx,(%rdi)
                       test  %eax,%eax                                 test  %eax,%eax
                     ↓ jne   2b                                      ↓ jne   2b
         3.85  0.00    mov   %rbx,%rax                  3.85  0.00     mov   %rbx,%rax
                       pop   %rbx                                      pop   %rbx
                     ← retq                                          ← retq
                  2b:  mov   %eax,%esi                            2b:  mov   %eax,%esi
                     → callq queued_spin_lock_slowpath|              → callq *ffffffff820e96b0
                       mov   %rbx,%rax                                 mov   %rbx,%rax
                       pop   %rbx                                      pop   %rbx
                     ← retq                                          ← retq
        #
      
      This should be further streamlined by doing both annotations and
      allowing the TUI to toggle initial/current, and show the patched
      instructions in a slightly different color.
      
      Cc: Adrian Hunter <adrian.hunter@intel.com>
      Cc: Andi Kleen <ak@linux.intel.com>
      Cc: David Ahern <dsahern@gmail.com>
      Cc: Jin Yao <yao.jin@linux.intel.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-wz8d269hxkcwaczr0r4rhyjg@git.kernel.orgSigned-off-by: NArnaldo Carvalho de Melo <acme@redhat.com>
      be316409
    • A
      perf annotate: Move the default annotate options to the library · 7f0b6fde
      Arnaldo Carvalho de Melo 提交于
      One more thing that goes from the TUI code to be used more widely,
      for instance it'll affect the default options used by:
      
        perf annotate --stdio2
      
      Cc: Adrian Hunter <adrian.hunter@intel.com>
      Cc: Andi Kleen <ak@linux.intel.com>
      Cc: David Ahern <dsahern@gmail.com>
      Cc: Jin Yao <yao.jin@linux.intel.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-0nsz0dm0akdbo30vgja2a10e@git.kernel.orgSigned-off-by: NArnaldo Carvalho de Melo <acme@redhat.com>
      7f0b6fde
    • A
      perf annotate: Introduce the --stdio2 output mode · befd2a38
      Arnaldo Carvalho de Melo 提交于
      This uses the TUI augmented formatting routines, modulo interactivity.
      
        # perf annotate --ignore-vmlinux --stdio2 _raw_spin_lock_irqsave
        _raw_spin_lock_irqsave() /proc/kcore
        Event: cycles:ppp
      
        Percent
      
                    Disassembly of section load0:
      
                    ffffffff9a8734b0 <load0>:
                      nop
                      push   %rbx
         50.00        pushfq
                      pop    %rax
                      nop
                      mov    %rax,%rbx
                      cli
                      nop
                      xor    %eax,%eax
                      mov    $0x1,%edx
         50.00        lock   cmpxchg %edx,(%rdi)
                      test   %eax,%eax
                    ↓ jne    2b
                      mov    %rbx,%rax
                      pop    %rbx
                    ← retq
                2b:   mov    %eax,%esi
                    → callq  queued_spin_lock_slowpath
                      mov    %rbx,%rax
                      pop    %rbx
                    ← retq
      Tested-by: NJin Yao <yao.jin@linux.intel.com>
      Cc: Adrian Hunter <adrian.hunter@intel.com>
      Cc: Andi Kleen <ak@linux.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-6cte5o8z84mbivbvqlg14uh1@git.kernel.orgSigned-off-by: NArnaldo Carvalho de Melo <acme@redhat.com>
      befd2a38
  21. 08 3月, 2018 1 次提交
    • J
      perf annotate: Support to display the IPC/Cycle in TUI mode · bb848c14
      Jin Yao 提交于
      Unlike the perf report interactive annotate mode, the perf annotate
      doesn't display the IPC/Cycle even if branch info is recorded in perf
      data file.
      
      perf record -b ...
      perf annotate function
      
      It should show IPC/cycle, but it doesn't.
      
      This patch lets perf annotate support the displaying of IPC/Cycle if
      branch info is in perf data.
      
      For example,
      
        perf annotate compute_flag
      
        Percent│ IPC Cycle
               │
               │
               │                Disassembly of section .text:
               │
               │                0000000000400640 <compute_flag>:
               │                compute_flag():
               │                volatile int count;
               │                static unsigned int s_randseed;
               │
               │                __attribute__((noinline))
               │                int compute_flag()
               │                {
         22.96 │1.18   584        sub    $0x8,%rsp
               │                        int i;
               │
               │                        i = rand() % 2;
         23.02 │1.18     1      → callq  rand@plt
               │
               │                        return i;
         27.05 │3.37              mov    %eax,%edx
               │                }
               │3.37              add    $0x8,%rsp
               │                {
               │                        int i;
               │
               │                        i = rand() % 2;
               │
               │                        return i;
               │3.37              shr    $0x1f,%edx
               │3.37              add    %edx,%eax
               │3.37              and    $0x1,%eax
               │3.37              sub    %edx,%eax
               │                }
         26.97 │3.37     2      ← retq
      
      Note that, this patch only supports TUI mode. For stdio, now it just keeps
      original behavior. Will support it in a follow-up patch.
      
        $ perf annotate compute_flag --stdio
      
         Percent |      Source code & Disassembly of div for cycles:ppp (7993 samples)
        ------------------------------------------------------------------------------
                 :
                 :
                 :
                 :            Disassembly of section .text:
                 :
                 :            0000000000400640 <compute_flag>:
                 :            compute_flag():
                 :            volatile int count;
                 :            static unsigned int s_randseed;
                 :
                 :            __attribute__((noinline))
                 :            int compute_flag()
                 :            {
            0.29 :   400640:       sub    $0x8,%rsp     # +100.00%
                 :                    int i;
                 :
                 :                    i = rand() % 2;
           42.93 :   400644:       callq  400490 <rand@plt>     # -100.00% (p:100.00%)
                 :
                 :                    return i;
            0.10 :   400649:       mov    %eax,%edx     # +100.00%
                 :            }
            0.94 :   40064b:       add    $0x8,%rsp
                 :            {
                 :                    int i;
                 :
                 :                    i = rand() % 2;
                 :
                 :                    return i;
           27.02 :   40064f:       shr    $0x1f,%edx
            0.15 :   400652:       add    %edx,%eax
            1.24 :   400654:       and    $0x1,%eax
            2.08 :   400657:       sub    %edx,%eax
                 :            }
           25.26 :   400659:       retq # -100.00% (p:100.00%)
      Signed-off-by: NJin Yao <yao.jin@linux.intel.com>
      Acked-by: NAndi Kleen <ak@linux.intel.com>
      Link: http://lkml.kernel.org/r/20180223170210.GC7045@tassilo.jf.intel.com
      Cc: Alexander Shishkin <alexander.shishkin@linux.intel.com>
      Cc: Jiri Olsa <jolsa@kernel.org>
      Cc: Peter Zijlstra <peterz@infradead.org>
      Link: http://lkml.kernel.org/r/1519724327-7773-1-git-send-email-yao.jin@linux.intel.comSigned-off-by: NArnaldo Carvalho de Melo <acme@redhat.com>
      bb848c14
  22. 02 11月, 2017 1 次提交
    • G
      License cleanup: add SPDX GPL-2.0 license identifier to files with no license · b2441318
      Greg Kroah-Hartman 提交于
      Many source files in the tree are missing licensing information, which
      makes it harder for compliance tools to determine the correct license.
      
      By default all files without license information are under the default
      license of the kernel, which is GPL version 2.
      
      Update the files which contain no license information with the 'GPL-2.0'
      SPDX license identifier.  The SPDX identifier is a legally binding
      shorthand, which can be used instead of the full boiler plate text.
      
      This patch is based on work done by Thomas Gleixner and Kate Stewart and
      Philippe Ombredanne.
      
      How this work was done:
      
      Patches were generated and checked against linux-4.14-rc6 for a subset of
      the use cases:
       - file had no licensing information it it.
       - file was a */uapi/* one with no licensing information in it,
       - file was a */uapi/* one with existing licensing information,
      
      Further patches will be generated in subsequent months to fix up cases
      where non-standard license headers were used, and references to license
      had to be inferred by heuristics based on keywords.
      
      The analysis to determine which SPDX License Identifier to be applied to
      a file was done in a spreadsheet of side by side results from of the
      output of two independent scanners (ScanCode & Windriver) producing SPDX
      tag:value files created by Philippe Ombredanne.  Philippe prepared the
      base worksheet, and did an initial spot review of a few 1000 files.
      
      The 4.13 kernel was the starting point of the analysis with 60,537 files
      assessed.  Kate Stewart did a file by file comparison of the scanner
      results in the spreadsheet to determine which SPDX license identifier(s)
      to be applied to the file. She confirmed any determination that was not
      immediately clear with lawyers working with the Linux Foundation.
      
      Criteria used to select files for SPDX license identifier tagging was:
       - Files considered eligible had to be source code files.
       - Make and config files were included as candidates if they contained >5
         lines of source
       - File already had some variant of a license header in it (even if <5
         lines).
      
      All documentation files were explicitly excluded.
      
      The following heuristics were used to determine which SPDX license
      identifiers to apply.
      
       - when both scanners couldn't find any license traces, file was
         considered to have no license information in it, and the top level
         COPYING file license applied.
      
         For non */uapi/* files that summary was:
      
         SPDX license identifier                            # files
         ---------------------------------------------------|-------
         GPL-2.0                                              11139
      
         and resulted in the first patch in this series.
      
         If that file was a */uapi/* path one, it was "GPL-2.0 WITH
         Linux-syscall-note" otherwise it was "GPL-2.0".  Results of that was:
      
         SPDX license identifier                            # files
         ---------------------------------------------------|-------
         GPL-2.0 WITH Linux-syscall-note                        930
      
         and resulted in the second patch in this series.
      
       - if a file had some form of licensing information in it, and was one
         of the */uapi/* ones, it was denoted with the Linux-syscall-note if
         any GPL family license was found in the file or had no licensing in
         it (per prior point).  Results summary:
      
         SPDX license identifier                            # files
         ---------------------------------------------------|------
         GPL-2.0 WITH Linux-syscall-note                       270
         GPL-2.0+ WITH Linux-syscall-note                      169
         ((GPL-2.0 WITH Linux-syscall-note) OR BSD-2-Clause)    21
         ((GPL-2.0 WITH Linux-syscall-note) OR BSD-3-Clause)    17
         LGPL-2.1+ WITH Linux-syscall-note                      15
         GPL-1.0+ WITH Linux-syscall-note                       14
         ((GPL-2.0+ WITH Linux-syscall-note) OR BSD-3-Clause)    5
         LGPL-2.0+ WITH Linux-syscall-note                       4
         LGPL-2.1 WITH Linux-syscall-note                        3
         ((GPL-2.0 WITH Linux-syscall-note) OR MIT)              3
         ((GPL-2.0 WITH Linux-syscall-note) AND MIT)             1
      
         and that resulted in the third patch in this series.
      
       - when the two scanners agreed on the detected license(s), that became
         the concluded license(s).
      
       - when there was disagreement between the two scanners (one detected a
         license but the other didn't, or they both detected different
         licenses) a manual inspection of the file occurred.
      
       - In most cases a manual inspection of the information in the file
         resulted in a clear resolution of the license that should apply (and
         which scanner probably needed to revisit its heuristics).
      
       - When it was not immediately clear, the license identifier was
         confirmed with lawyers working with the Linux Foundation.
      
       - If there was any question as to the appropriate license identifier,
         the file was flagged for further research and to be revisited later
         in time.
      
      In total, over 70 hours of logged manual review was done on the
      spreadsheet to determine the SPDX license identifiers to apply to the
      source files by Kate, Philippe, Thomas and, in some cases, confirmation
      by lawyers working with the Linux Foundation.
      
      Kate also obtained a third independent scan of the 4.13 code base from
      FOSSology, and compared selected files where the other two scanners
      disagreed against that SPDX file, to see if there was new insights.  The
      Windriver scanner is based on an older version of FOSSology in part, so
      they are related.
      
      Thomas did random spot checks in about 500 files from the spreadsheets
      for the uapi headers and agreed with SPDX license identifier in the
      files he inspected. For the non-uapi files Thomas did random spot checks
      in about 15000 files.
      
      In initial set of patches against 4.14-rc6, 3 files were found to have
      copy/paste license identifier errors, and have been fixed to reflect the
      correct identifier.
      
      Additionally Philippe spent 10 hours this week doing a detailed manual
      inspection and review of the 12,461 patched files from the initial patch
      version early this week with:
       - a full scancode scan run, collecting the matched texts, detected
         license ids and scores
       - reviewing anything where there was a license detected (about 500+
         files) to ensure that the applied SPDX license was correct
       - reviewing anything where there was no detection but the patch license
         was not GPL-2.0 WITH Linux-syscall-note to ensure that the applied
         SPDX license was correct
      
      This produced a worksheet with 20 files needing minor correction.  This
      worksheet was then exported into 3 different .csv files for the
      different types of files to be modified.
      
      These .csv files were then reviewed by Greg.  Thomas wrote a script to
      parse the csv files and add the proper SPDX tag to the file, in the
      format that the file expected.  This script was further refined by Greg
      based on the output to detect more types of files automatically and to
      distinguish between header and source .c files (which need different
      comment types.)  Finally Greg ran the script using the .csv files to
      generate the patches.
      Reviewed-by: NKate Stewart <kstewart@linuxfoundation.org>
      Reviewed-by: NPhilippe Ombredanne <pombredanne@nexb.com>
      Reviewed-by: NThomas Gleixner <tglx@linutronix.de>
      Signed-off-by: NGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      b2441318
  23. 31 10月, 2017 2 次提交
  24. 18 8月, 2017 2 次提交
  25. 27 7月, 2017 1 次提交
  26. 25 7月, 2017 1 次提交