linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Arnaldo Carvalho de Melo <acme@kernel.org>
To: Ingo Molnar <mingo@kernel.org>, Thomas Gleixner <tglx@linutronix.de>
Cc: Jiri Olsa <jolsa@kernel.org>, Namhyung Kim <namhyung@kernel.org>,
	Clark Williams <williams@redhat.com>,
	linux-kernel@vger.kernel.org, linux-perf-users@vger.kernel.org,
	Adrian Hunter <adrian.hunter@intel.com>,
	Andi Kleen <ak@linux.intel.com>, Jiri Olsa <jolsa@redhat.com>,
	Arnaldo Carvalho de Melo <acme@redhat.com>
Subject: [PATCH 22/22] perf script: Fix invalid LBR/binary mismatch error
Date: Thu, 28 Nov 2019 10:40:27 -0300	[thread overview]
Message-ID: <20191128134027.23726-23-acme@kernel.org> (raw)
In-Reply-To: <20191128134027.23726-1-acme@kernel.org>

From: Adrian Hunter <adrian.hunter@intel.com>

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: Andi Kleen <ak@linux.intel.com>
Signed-off-by: Adrian Hunter <adrian.hunter@intel.com>
Cc: Jiri Olsa <jolsa@redhat.com>
Link: http://lore.kernel.org/lkml/20191127095631.15663-1-adrian.hunter@intel.com
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
---
 tools/perf/builtin-script.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/tools/perf/builtin-script.c b/tools/perf/builtin-script.c
index e8db26b9b29e..e2406b291c1c 100644
--- a/tools/perf/builtin-script.c
+++ b/tools/perf/builtin-script.c
@@ -1126,7 +1126,7 @@ static int perf_sample__fprintf_brstackinsn(struct perf_sample *sample,
 				insn++;
 			}
 		}
-		if (off != (unsigned)len)
+		if (off != end - start)
 			printed += fprintf(fp, "\tmismatch of LBR data and executable\n");
 	}
 
-- 
2.21.0


  parent reply	other threads:[~2019-11-28 13:41 UTC|newest]

Thread overview: 24+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-11-28 13:40 [GIT PULL] perf/core improvements and fixes Arnaldo Carvalho de Melo
2019-11-28 13:40 ` [PATCH 01/22] perf script: Move map__fprintf_srccode() to near its only user Arnaldo Carvalho de Melo
2019-11-28 13:40 ` [PATCH 02/22] perf map: Ditch leftover map__reloc_vmlinux() prototype Arnaldo Carvalho de Melo
2019-11-28 13:40 ` [PATCH 03/22] perf map: Remove needless struct forward declarations Arnaldo Carvalho de Melo
2019-11-28 13:40 ` [PATCH 04/22] perf map: Remove unused functions Arnaldo Carvalho de Melo
2019-11-28 13:40 ` [PATCH 05/22] x86/insn: Add some more Intel instructions to the opcode map Arnaldo Carvalho de Melo
2019-11-28 13:40 ` [PATCH 06/22] x86/insn: perf tools: Add some more instructions to the new instructions test Arnaldo Carvalho de Melo
2019-11-28 13:40 ` [PATCH 07/22] perf maps: Merge 'struct maps' with 'struct map_groups' Arnaldo Carvalho de Melo
2019-11-28 13:40 ` [PATCH 08/22] perf thread: Rename thread->mg to thread->maps Arnaldo Carvalho de Melo
2019-11-28 13:40 ` [PATCH 09/22] perf addr_location: Rename al->mg to al->maps Arnaldo Carvalho de Melo
2019-11-28 13:40 ` [PATCH 10/22] perf map_symbol: Rename ms->mg to ms->maps Arnaldo Carvalho de Melo
2019-11-28 13:40 ` [PATCH 11/22] perf maps: Rename 'mg' variables to 'maps' Arnaldo Carvalho de Melo
2019-11-28 13:40 ` [PATCH 12/22] perf maps: Rename map_groups.h to maps.h Arnaldo Carvalho de Melo
2019-11-28 13:40 ` [PATCH 13/22] perf tests: Rename thread-mg-share to thread-maps-share Arnaldo Carvalho de Melo
2019-11-28 13:40 ` [PATCH 14/22] perf tests: Rename tests/map_groups.c to tests/maps.c Arnaldo Carvalho de Melo
2019-11-28 13:40 ` [PATCH 15/22] perf tools: Allow to link with libbpf dynamicaly Arnaldo Carvalho de Melo
2019-11-28 13:40 ` [PATCH 16/22] perf diff: Use llabs() with 64-bit values Arnaldo Carvalho de Melo
2019-11-28 13:40 ` [PATCH 17/22] " Arnaldo Carvalho de Melo
2019-11-28 13:40 ` [PATCH 18/22] perf regs: Make perf_reg_name() return "unknown" instead of NULL Arnaldo Carvalho de Melo
2019-11-28 13:40 ` [PATCH 19/22] perf pmu: Use file system cache to optimize sysfs access Arnaldo Carvalho de Melo
2019-11-28 13:40 ` [PATCH 20/22] perf affinity: Add infrastructure to save/restore affinity Arnaldo Carvalho de Melo
2019-11-28 13:40 ` [PATCH 21/22] perf script: Fix brstackinsn for AUXTRACE Arnaldo Carvalho de Melo
2019-11-28 13:40 ` Arnaldo Carvalho de Melo [this message]
2019-11-29  5:58 ` [GIT PULL] perf/core improvements and fixes Ingo Molnar

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20191128134027.23726-23-acme@kernel.org \
    --to=acme@kernel.org \
    --cc=acme@redhat.com \
    --cc=adrian.hunter@intel.com \
    --cc=ak@linux.intel.com \
    --cc=jolsa@kernel.org \
    --cc=jolsa@redhat.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-perf-users@vger.kernel.org \
    --cc=mingo@kernel.org \
    --cc=namhyung@kernel.org \
    --cc=tglx@linutronix.de \
    --cc=williams@redhat.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).