]> git.baikalelectronics.ru Git - kernel.git/commit
perf/x86: Make branch classifier fusion-aware
authorSandipan Das <sandipan.das@amd.com>
Thu, 11 Aug 2022 12:29:58 +0000 (17:59 +0530)
committerPeter Zijlstra <peterz@infradead.org>
Fri, 26 Aug 2022 22:05:44 +0000 (00:05 +0200)
commit350bf9f4a0461975fc6e6a6ac2e7d55694a427ec
tree332c39baad41b137a57aa1b0974fe41ca7ec00bb
parent9d20e4a2b64567d51d283a415c343964efc8db8e
perf/x86: Make branch classifier fusion-aware

With branch fusion and other optimizations, branch sampling hardware in
some processors can report a branch from address that points to an
instruction preceding the actual branch by several bytes.

In such cases, the classifier cannot determine the branch type which leads
to failures such as with the recently added test from commit 4a3259f50ccb
("perf test: Add test for branch stack sampling"). Branch information is
also easier to consume and annotate if branch from addresses always point
to branch instructions.

Add a new variant of the branch classifier that can account for instruction
fusion. If fusion is expected and the current branch from address does not
point to a branch instruction, it attempts to find the first branch within
the next (MAX_INSN_SIZE - 1) bytes and if found, additionally provides the
offset between the reported branch from address and the address of the
expected branch instruction.

Signed-off-by: Sandipan Das <sandipan.das@amd.com>
Signed-off-by: Peter Zijlstra (Intel) <peterz@infradead.org>
Link: https://lore.kernel.org/r/b6bb0abaa8a54c0b6d716344700ee11a1793d709.1660211399.git.sandipan.das@amd.com
arch/x86/events/perf_event.h
arch/x86/events/utils.c