]> git.baikalelectronics.ru Git - kernel.git/commit
perf/x86/amd/lbr: Add LbrExtV2 hardware branch filter support
authorSandipan Das <sandipan.das@amd.com>
Thu, 11 Aug 2022 12:29:55 +0000 (17:59 +0530)
committerPeter Zijlstra <peterz@infradead.org>
Fri, 26 Aug 2022 22:05:43 +0000 (00:05 +0200)
commit74768f630d26b35326354ed97f378d0ca07a4391
tree88294aa43aad7a0ebedabb85612874d730a3e455
parent626648a2a6719669d3132a3bea7bbfbe1aad8729
perf/x86/amd/lbr: Add LbrExtV2 hardware branch filter support

If AMD Last Branch Record Extension Version 2 (LbrExtV2) is detected,
convert the requested branch filter (PERF_SAMPLE_BRANCH_* flags) to the
corresponding hardware filter value and stash it in the event data when
a branch stack is requested. The hardware filter value is also saved in
per-CPU areas for use during event scheduling.

Hardware filtering is provided by the LBR Branch Select register. It has
bits which when set, suppress recording of the following types of branches:

  * CPL = 0 (Kernel only)
  * CPL > 0 (Userspace only)
  * Conditional Branches
  * Near Relative Calls
  * Near Indirect Calls
  * Near Returns
  * Near Indirect Jumps (excluding Near Indirect Calls and Near Returns)
  * Near Relative Jumps (excluding Near Relative Calls)
  * Far Branches

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