• Namhyung Kim's avatar
    perf annotate: Add --skip-empty option · ce533c9b
    Namhyung Kim authored
    Like in 'perf report', we want to hide empty events in the 'perf annotate'
    output.  This is consistent when the option is set in perf report.
    
    For example, the following command would use 3 events including dummy.
    
      $ perf mem record -a -- perf test -w noploop
    
      $ perf evlist
      cpu/mem-loads,ldlat=30/P
      cpu/mem-stores/P
      dummy:u
    
    Just using perf annotate with --group will show the all 3 events.
    
      $ perf annotate --group --stdio | head
       Percent                 |	Source code & Disassembly of ...
      --------------------------------------------------------------
                               : 0     0xe060 <_dl_relocate_object>:
          0.00    0.00    0.00 :    e060:       pushq   %rbp
          0.00    0.00    0.00 :    e061:       movq    %rsp, %rbp
          0.00    0.00    0.00 :    e064:       pushq   %r15
          0.00    0.00    0.00 :    e066:       movq    %rdi, %r15
          0.00    0.00    0.00 :    e069:       pushq   %r14
          0.00    0.00    0.00 :    e06b:       pushq   %r13
          0.00    0.00    0.00 :    e06d:       movl    %edx, %r13d
    
    Now with --skip-empty, it'll hide the last dummy event.
    
      $ perf annotate --group --stdio --skip-empty | head
       Percent         |	Source code & Disassembly of ...
      ------------------------------------------------------
                       : 0     0xe060 <_dl_relocate_object>:
          0.00    0.00 :    e060:       pushq   %rbp
          0.00    0.00 :    e061:       movq    %rsp, %rbp
          0.00    0.00 :    e064:       pushq   %r15
          0.00    0.00 :    e066:       movq    %rdi, %r15
          0.00    0.00 :    e069:       pushq   %r14
          0.00    0.00 :    e06b:       pushq   %r13
          0.00    0.00 :    e06d:       movl    %edx, %r13d
    
    Committer testing:
    
      root@x1:~# perf evlist
      cpu_atom/mem-loads,ldlat=30/P
      cpu_atom/mem-stores/P
      dummy:u
      root@x1:~#
    
    Before:
    
      root@x1:~# perf annotate --group --stdio2 do_lookup_x | head -25
      Samples: 20  of events 'cpu_atom/mem-loads,ldlat=30/P, cpu_atom/mem-stores/P, dummy:u', 4000 Hz, Event count (approx.): 769079, [percent: local period]
      do_lookup_x() /usr/lib64/ld-linux-x86-64.so.2
      Percent                       0x9900 <do_lookup_x>:
                                      pushq      %rbp
                                      movq       %rsp,%rbp
                                      pushq      %r15
                                      pushq      %r14
                                      pushq      %r13
                                      pushq      %r12
                                      pushq      %rbx
                                      subq       $0x88,%rsp
                                      movq       %rdi,-0x50(%rbp)
                                      movl       8(%r9),%edi
                                      movq       0x10(%rbp),%r12
                                      movq       0x28(%rbp),%r10
                                      movq       %rdx,-0x70(%rbp)
                                      movq       %rcx,-0x58(%rbp)
                                      movq       %rdi,%r11
         0.00    5.73    0.00         movq       %r8,-0x68(%rbp)
                                      movq       (%r9),%r8
                                      movl       %esi,%eax
         8.30    0.00    0.00         movl       0x30(%rbp),%r9d
                                      movl       %esi,%r15d
                                      shrl       $6, %eax
                                      movq       %r8,%r13
      root@x1:~#
    
    After:
    
      root@x1:~# perf annotate --group --skip-empty --stdio2 do_lookup_x | head -25
      Samples: 20  of events 'cpu_atom/mem-loads,ldlat=30/P, cpu_atom/mem-stores/P', 4000 Hz, Event count (approx.): 769079, [percent: local period]
      do_lookup_x() /usr/lib64/ld-linux-x86-64.so.2
      Percent               0x9900 <do_lookup_x>:
                              pushq      %rbp
                              movq       %rsp,%rbp
                              pushq      %r15
                              pushq      %r14
                              pushq      %r13
                              pushq      %r12
                              pushq      %rbx
                              subq       $0x88,%rsp
                              movq       %rdi,-0x50(%rbp)
                              movl       8(%r9),%edi
                              movq       0x10(%rbp),%r12
                              movq       0x28(%rbp),%r10
                              movq       %rdx,-0x70(%rbp)
                              movq       %rcx,-0x58(%rbp)
                              movq       %rdi,%r11
         0.00    5.73         movq       %r8,-0x68(%rbp)
                              movq       (%r9),%r8
                              movl       %esi,%eax
         8.30    0.00         movl       0x30(%rbp),%r9d
                              movl       %esi,%r15d
                              shrl       $6, %eax
                              movq       %r8,%r13
      root@x1:~#
    Signed-off-by: default avatarNamhyung Kim <namhyung@kernel.org>
    Tested-by: default avatarArnaldo Carvalho de Melo <acme@redhat.com>
    Cc: Adrian Hunter <adrian.hunter@intel.com>
    Cc: Ian Rogers <irogers@google.com>
    Cc: Ingo Molnar <mingo@kernel.org>
    Cc: Jiri Olsa <jolsa@kernel.org>
    Cc: Kan Liang <kan.liang@linux.intel.com>
    Cc: Peter Zijlstra <peterz@infradead.org>
    Link: https://lore.kernel.org/r/20240803211332.1107222-6-namhyung@kernel.orgSigned-off-by: default avatarArnaldo Carvalho de Melo <acme@redhat.com>
    ce533c9b
builtin-annotate.c 24.3 KB