AMD Branch Sampling "BRS" Feature To Land With Linux 5.19

Written by Michael Larabel in AMD on 5 April 2022 at 03:40 PM EDT. Add A Comment
AMD
While there are many new features with Linux 5.18 with its merge window having just ended days ago, feature code is already beginning to accumulate within the various "-next" branches for what will be Linux 5.19 this summer. Patches merged today get AMD Branch Sampling (BRS) functionality in place for Zen 3 processors with that next kernel cycle.

Last year I wrote about Google engineers working on AMD Branch Sampling support for Linux with Zen 3 processors. This is about making use of the processor-exposed information about branches taken during code execution. In turn this AMD Branch Sampling information will be exposed via Linux's perf subsystem for collection. This AMD Branch Sampling support can be leveraged for better compiler optimizations on AMD processors by analyzing the collected hardware data for making more informed/accurate optimization decisions like with AutoFDO. See the aforelinked article for more commentary.

While it's been some months since last talking about the AMD Branch Sampling support, based on the information within the public AMD programmer reference manual they were able to get the support ironed out and is now ready for mainlining. After re-basing against Linux 5.18-rc1, pulled into TIP's perf/core branch is the AMD Zen 3 Branch Sampling code. In turn these perf/core patches along with whatever patches accumulate over the next month and a half will in turn be submitted for the Linux 5.19 merge window when that kicks off around the end of May.


With Zen 3 processors there is 16-deep branch sampling accessible via CPU MSR registers. With the perf tool the RETIRED_BRANCH_INSTRUCTIONS can be used for matching the BRS behavior or the new branch-brs event. The AMD Zen 3 BRS support is going to be an opt-in feature with the Linux CONFIG_PERF_EVENTS_AMD_BRS switch at build-time. It's great that AMD BRS is now being exposed under Linux but unfortunate it's taken so long after Zen 3 CPUs premiered with this feature, at least it should still prove useful with Zen 4 and beyond for profiling / AutoFDO-like optimizing.
Related News
About The Author
Michael Larabel

Michael Larabel is the principal author of Phoronix.com and founded the site in 2004 with a focus on enriching the Linux hardware experience. Michael has written more than 20,000 articles covering the state of Linux hardware support, Linux performance, graphics drivers, and other topics. Michael is also the lead developer of the Phoronix Test Suite, Phoromatic, and OpenBenchmarking.org automated benchmarking software. He can be followed via Twitter, LinkedIn, or contacted via MichaelLarabel.com.

Popular News This Week