AMD Posts Linux Patches For "LbrExtV2" Zen 4 CPU Feature
LbrExtV2 is their shorthand for an updated Last Branch Record (LBR) implementation coming with Zen 4 CPUs. Last Branch Record is used for determining/analyzing the control flow of software by logging branch information to registers in real-time. The LBR information can be used for determining of hot code paths and useful for areas like profile-guided compiler optimizations and other tuning based on being able to analyze the branches frequently taken in software.
AMD Last Branch Record Extension Version 2 adds new features like LBR-Freeze-on-PMI for better correlation with PMC overflow events. There is also new hardware branch filtering support for recording just specific types of branches. The LbrExtV2 filtering includes being able to suppress branches for just kernel-only, user-space only, conditional branches, near relative calls, near indirect calls, near returns, near indirect jumps, near relative jumps, and far branches.
LbrExtV2 also extends the Linux perf user-space API to provide branch speculation information with Zen 4 CPUs now able to provide branch speculation details. The speculation information includes whether the correct path was taken for the branch and if speculation was involved or whether the wrong path was taken.
The nearly thousand lines of new code working out the AMD Last Branch Record Extension Version 2 handling for Zen 4 can be found now for review on the kernel mailing list. Meanwhile this secondary patch series adds speculation information to the Linux perf tooling.
While Zen 4 CPUs are launching later this quarter, the timing of these patches mean they won't be mainlined until at least Linux 6.1 that in turn won't be out as stable until around end of year -- granted, for the vast majority of users they won't care about LbrExtV2 Linux perf integration unless engaging in heavy system profiling and tuning.