• He Kuang's avatar
    perf script: Show call graphs when 1st event doesn't have it but some other has · 40f20e50
    He Kuang authored
    There's a display inconsistency when there are multiple tracepoint
    events, some of which have the 'call-graph' config option set but the
    first one hasn't, i.e. the whole logic for call graph processing is
    enabled only if the first tracepoint event has call-graph set.
    
    For instance, if we record signal_deliver with call-graph and
    signal_generate without:
    
      $ perf record -g -a -e signal:signal_deliver -e signal:signal_generate/call-graph=no/
    
      [ perf record: Captured and wrote 0.017 MB perf.data (2 samples) ]
    
      $ perf script
    
      kworker/u2:1    13 [000]  6563.875949: signal:signal_generate: sig=2 errno=0 code=128 comm=perf pid=1313 grp=1 res=0 ff61cc __send_signal+0x3ec ([kernel.kallsyms])
      perf  1313 [000]  6563.877584:  signal:signal_deliver: sig=2 errno=0 code=128 sa_handler=43115e sa_flags=14000000
                  7ffff314 get_signal+0x80007f0023a4 ([kernel.kallsyms])
                  7fffe358 do_signal+0x80007f002028 ([kernel.kallsyms])
                  7fffa5e8 exit_to_usermode_loop+0x80007f002053 ([kernel.kallsyms])
                  ...
    
    Then we exchange the order of these two events in commandline, and keep
    signal_generate without call-graph.
    
      $ perf record -g -a -e signal:signal_generate/call-graph=no/ -e signal:signal_deliver
    
      [ perf record: Captured and wrote 0.017 MB perf.data (2 samples) ]
    
      $ perf script
    
        kworker/u2:2  1314 [000]  6933.353060: signal:signal_generate: sig=2 errno=0 code=128 comm=perf pid=1321 grp=1 res=0
                perf  1321 [000]  6933.353872:  signal:signal_deliver: sig=2 errno=0 code=128 sa_handler=43115e sa_flags=14000000
    
    This time, the callchain of the event signal_deliver disappeared. The
    problem is caused by that perf only checks for the first evsel in evlist
    and decides if callchain should be printed.
    
    This patch traverses all evsels in evlist to see if any of them have
    callchains, and shows the right result:
    
      $ perf script
    
      kworker/u2:2  1314 [000]  6933.353060: signal:signal_generate: sig=2 errno=0 code=128 comm=perf pid=1321 grp=1 res=0 ff61cc __send_signal+0x3ec ([kernel.kallsyms])
      perf  1321 [000]  6933.353872:  signal:signal_deliver: sig=2 errno=0 code=128 sa_handler=43115e sa_flags=14000000
                  7ffff314 get_signal+0x80007f0023a4 ([kernel.kallsyms])
                  7fffe358 do_signal+0x80007f002028 ([kernel.kallsyms])
                  7fffa5e8 exit_to_usermode_loop+0x80007f002053 ([kernel.kallsyms])
                  ...
    Signed-off-by: default avatarHe Kuang <hekuang@huawei.com>
    Tested-by: default avatarArnaldo Carvalho de Melo <acme@redhat.com>
    Cc: Alexander Shishkin <alexander.shishkin@linux.intel.com>
    Cc: Ingo Molnar <mingo@redhat.com>
    Cc: Peter Zijlstra <peterz@infradead.org>
    Cc: Wang Nan <wangnan0@huawei.com>
    Link: http://lkml.kernel.org/r/1463374279-97209-1-git-send-email-hekuang@huawei.comSigned-off-by: default avatarArnaldo Carvalho de Melo <acme@redhat.com>
    40f20e50
builtin-script.c 57.8 KB