• A
    perf intel-pt: Fix duplicate branch after CBR · a58a057c
    Adrian Hunter 提交于
    CBR events can result in a duplicate branch event, because the state
    type defaults to a branch. Fix by clearing the state type.
    
    Example: trace 'sleep' and hope for a frequency change
    
     Before:
    
       $ perf record -e intel_pt//u sleep 0.1
       [ perf record: Woken up 1 times to write data ]
       [ perf record: Captured and wrote 0.034 MB perf.data ]
       $ perf script --itrace=bpe > before.txt
    
     After:
    
       $ perf script --itrace=bpe > after.txt
       $ diff -u before.txt after.txt
       --- before.txt  2020-07-07 14:42:18.191508098 +0300
       +++ after.txt   2020-07-07 14:42:36.587891753 +0300
       @@ -29673,7 +29673,6 @@
                   sleep 93431 [007] 15411.619905:          1  branches:u:                 0 [unknown] ([unknown]) =>     7f0818abb2e0 clock_nanosleep@@GLIBC_2.17+0x0 (/usr/lib/x86_64-linux-gnu/libc-2.31.so)
                   sleep 93431 [007] 15411.619905:          1  branches:u:      7f0818abb30c clock_nanosleep@@GLIBC_2.17+0x2c (/usr/lib/x86_64-linux-gnu/libc-2.31.so) =>                0 [unknown] ([unknown])
                   sleep 93431 [007] 15411.720069:         cbr:  cbr: 15 freq: 1507 MHz ( 56%)         7f0818abb30c clock_nanosleep@@GLIBC_2.17+0x2c (/usr/lib/x86_64-linux-gnu/libc-2.31.so)
       -           sleep 93431 [007] 15411.720069:          1  branches:u:      7f0818abb30c clock_nanosleep@@GLIBC_2.17+0x2c (/usr/lib/x86_64-linux-gnu/libc-2.31.so) =>                0 [unknown] ([unknown])
                   sleep 93431 [007] 15411.720076:          1  branches:u:                 0 [unknown] ([unknown]) =>     7f0818abb30e clock_nanosleep@@GLIBC_2.17+0x2e (/usr/lib/x86_64-linux-gnu/libc-2.31.so)
                   sleep 93431 [007] 15411.720077:          1  branches:u:      7f0818abb323 clock_nanosleep@@GLIBC_2.17+0x43 (/usr/lib/x86_64-linux-gnu/libc-2.31.so) =>     7f0818ac0eb7 __nanosleep+0x17 (/usr/lib/x86_64-linux-gnu/libc-2.31.so)
                   sleep 93431 [007] 15411.720077:          1  branches:u:      7f0818ac0ebf __nanosleep+0x1f (/usr/lib/x86_64-linux-gnu/libc-2.31.so) =>     55cb7e4c2827 rpl_nanosleep+0x97 (/usr/bin/sleep)
    
    Fixes: 91de8684 ("perf intel-pt: Cater for CBR change in PSB+")
    Fixes: abe5a1d3 ("perf intel-pt: Decoder to output CBR changes immediately")
    Signed-off-by: NAdrian Hunter <adrian.hunter@intel.com>
    Reviewed-by: NAndi Kleen <ak@linux.intel.com>
    Tested-by: NArnaldo Carvalho de Melo <acme@redhat.com>
    Cc: Jiri Olsa <jolsa@redhat.com>
    Cc: stable@vger.kernel.org
    Link: http://lore.kernel.org/lkml/20200710151104.15137-3-adrian.hunter@intel.comSigned-off-by: NArnaldo Carvalho de Melo <acme@redhat.com>
    a58a057c
intel-pt-decoder.c 75.4 KB