* [PATCH 2/2] perf script: Fix invalid LBR/binary mismatch error
@ 2019-11-27 9:56 Adrian Hunter
2019-11-27 15:18 ` Arnaldo Carvalho de Melo
2019-11-29 6:02 ` [tip: perf/urgent] " tip-bot2 for Adrian Hunter
0 siblings, 2 replies; 3+ messages in thread
From: Adrian Hunter @ 2019-11-27 9:56 UTC (permalink / raw)
To: Arnaldo Carvalho de Melo; +Cc: Jiri Olsa, linux-kernel, Andi Kleen
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
Reported-by: Andi Kleen <ak@linux.intel.com>
Fixes: e98df280bc2a ("perf script brstackinsn: Fix recovery from LBR/binary mismatch")
Signed-off-by: Adrian Hunter <adrian.hunter@intel.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.17.1
^ permalink raw reply related [flat|nested] 3+ messages in thread
* Re: [PATCH 2/2] perf script: Fix invalid LBR/binary mismatch error
2019-11-27 9:56 [PATCH 2/2] perf script: Fix invalid LBR/binary mismatch error Adrian Hunter
@ 2019-11-27 15:18 ` Arnaldo Carvalho de Melo
2019-11-29 6:02 ` [tip: perf/urgent] " tip-bot2 for Adrian Hunter
1 sibling, 0 replies; 3+ messages in thread
From: Arnaldo Carvalho de Melo @ 2019-11-27 15:18 UTC (permalink / raw)
To: Adrian Hunter; +Cc: Jiri Olsa, linux-kernel, Andi Kleen
Em Wed, Nov 27, 2019 at 11:56:31AM +0200, Adrian Hunter escreveu:
> 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
Thanks, applied,
- Arnaldo
> Reported-by: Andi Kleen <ak@linux.intel.com>
> Fixes: e98df280bc2a ("perf script brstackinsn: Fix recovery from LBR/binary mismatch")
> Signed-off-by: Adrian Hunter <adrian.hunter@intel.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.17.1
--
- Arnaldo
^ permalink raw reply [flat|nested] 3+ messages in thread
* [tip: perf/urgent] perf script: Fix invalid LBR/binary mismatch error
2019-11-27 9:56 [PATCH 2/2] perf script: Fix invalid LBR/binary mismatch error Adrian Hunter
2019-11-27 15:18 ` Arnaldo Carvalho de Melo
@ 2019-11-29 6:02 ` tip-bot2 for Adrian Hunter
1 sibling, 0 replies; 3+ messages in thread
From: tip-bot2 for Adrian Hunter @ 2019-11-29 6:02 UTC (permalink / raw)
To: linux-tip-commits
Cc: Andi Kleen, Adrian Hunter, Jiri Olsa, Arnaldo Carvalho de Melo,
x86, LKML
The following commit has been merged into the perf/urgent branch of tip:
Commit-ID: 5172672da02e483d9b3c4d814c3482d0c8ffb1a6
Gitweb: https://git.kernel.org/tip/5172672da02e483d9b3c4d814c3482d0c8ffb1a6
Author: Adrian Hunter <adrian.hunter@intel.com>
AuthorDate: Wed, 27 Nov 2019 11:56:31 +02:00
Committer: Arnaldo Carvalho de Melo <acme@redhat.com>
CommitterDate: Thu, 28 Nov 2019 08:08:38 -03:00
perf script: Fix invalid LBR/binary mismatch error
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 e8db26b..e2406b2 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");
}
^ permalink raw reply related [flat|nested] 3+ messages in thread
end of thread, other threads:[~2019-11-29 6:04 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2019-11-27 9:56 [PATCH 2/2] perf script: Fix invalid LBR/binary mismatch error Adrian Hunter
2019-11-27 15:18 ` Arnaldo Carvalho de Melo
2019-11-29 6:02 ` [tip: perf/urgent] " tip-bot2 for Adrian Hunter
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).