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

If AMD Last Branch Record Extension Version 2 (LbrExtV2) is detected,
enable it alongside LBR Freeze on PMI when an event requests branch stack
i.e. PERF_SAMPLE_BRANCH_STACK.

Each branch record is represented by a pair of registers, LBR From and LBR
To. The freeze feature prevents any updates to these registers once a PMC
overflows. The contents remain unchanged until the freeze bit is cleared by
the PMI handler.

The branch records are read and copied to sample data before unfreezing.
However, only valid entries are copied. There is no additional register to
denote which of the register pairs represent the top of the stack (TOS)
since internal register renaming always ensures that the first pair (i.e.
index 0) is the one representing the most recent branch and so on.

The LBR registers are per-thread resources and are cleared explicitly
whenever a new task is scheduled in. There are no special implications on
the contents of these registers when transitioning to deep C-states.

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