• A
    perf script: Fix invalid LBR/binary mismatch error · 484c4d9a
    Adrian Hunter 提交于
    [ Upstream commit 5172672da02e483d9b3c4d814c3482d0c8ffb1a6 ]
    
    The 'len' returned by grab_bb() includes an extra MAXINSN bytes to allow
    for the last instruction, so the the final 'offs' will not be 'len'.
    Fix the error condition logic accordingly.
    
    Before:
    
      $ perf record -e '{intel_pt//,cpu/mem_inst_retired.all_loads,aux-sample-size=8192/pp}:u' grep -rqs jhgjhg /boot
      [ perf record: Woken up 19 times to write data ]
      [ perf record: Captured and wrote 2.274 MB perf.data ]
      $ perf script -F +brstackinsn --xed --itrace=i1usl100 | head
                grep 13759 [002]  8091.310257:       1862                                        instructions:uH:      5641d58069eb bmexec+0x86b (/bin/grep)
            bmexec+2485:
            00005641d5806b35                        jnz 0x5641d5806bd0              # MISPRED
            00005641d5806bd0                        movzxb  (%r13,%rdx,1), %eax
            00005641d5806bd6                        add %rdi, %rax
            00005641d5806bd9                        movzxb  -0x1(%rax), %edx
            00005641d5806bdd                        cmp %rax, %r14
            00005641d5806be0                        jnb 0x5641d58069c0              # MISPRED
            mismatch of LBR data and executable
            00005641d58069c0                        movzxb  (%r13,%rdx,1), %edi
    
    After:
    
      $ perf script -F +brstackinsn --xed --itrace=i1usl100 | head
                grep 13759 [002]  8091.310257:       1862                                        instructions:uH:      5641d58069eb bmexec+0x86b (/bin/grep)
            bmexec+2485:
            00005641d5806b35                        jnz 0x5641d5806bd0              # MISPRED
            00005641d5806bd0                        movzxb  (%r13,%rdx,1), %eax
            00005641d5806bd6                        add %rdi, %rax
            00005641d5806bd9                        movzxb  -0x1(%rax), %edx
            00005641d5806bdd                        cmp %rax, %r14
            00005641d5806be0                        jnb 0x5641d58069c0              # MISPRED
            00005641d58069c0                        movzxb  (%r13,%rdx,1), %edi
            00005641d58069c6                        add %rax, %rdi
    
    Fixes: e98df280bc2a ("perf script brstackinsn: Fix recovery from LBR/binary mismatch")
    Reported-by: NAndi Kleen <ak@linux.intel.com>
    Signed-off-by: NAdrian Hunter <adrian.hunter@intel.com>
    Cc: Jiri Olsa <jolsa@redhat.com>
    Link: http://lore.kernel.org/lkml/20191127095631.15663-1-adrian.hunter@intel.comSigned-off-by: NArnaldo Carvalho de Melo <acme@redhat.com>
    Signed-off-by: NSasha Levin <sashal@kernel.org>
    484c4d9a
builtin-script.c 91.6 KB