Clang Profile Guided Optimizations Support Sent In For Linux 5.14

Written by Michael Larabel in LLVM on 29 June 2021 at 12:00 AM EDT. 9 Comments
LLVM
Compiling the Linux kernel with LLVM's Clang code compiler continues to be more featureful with plumbing now being added to handle profile-guided optimizations (PGO) to help in achieving greater performance for optimizing kernel builds for targeted workloads.

Earlier this month I wrote about Clang PGO likely coming for Linux 5.14 and indeed the pull request was sent in on Monday. While GCC PGO for the Linux kernel was previously shot down, it looks like this new infrastructure will make it in for this new cycle.

This Clang PGO support for the kernel was worked on by Google engineers, similar to the many other LLVM/Clang build improvements for the Linux kernel. Compiler profile-guided optimizations (PGO) allows first building the software (in this case, the kernel) with profiling bits enabled so the developer/administrator can then run their desired workloads while generating a profile. A second build of the same software is then conducted afterwards while leveraging that profile data so the compiler can make more educated decisions in the name of achieving greater performance for the workloads targeted during that profile generation.

The Clang PGO infrastructure allows for raw profile data to be collected via /sys/kernel/debug/pgo/profraw. That raw profile data then needs to be processed using the llvm-profdata tool at which stage multiple profiles can also be merged. When rebuilding for the PGO-optimized kernel, the processed profile data can be passed back in via the compiler flags, such as make LLVM=1 KCFLAGS=-fprofile-use=vmlinux.profdata.

With the code submitted on Monday, the Clang PGO support is only for the main kernel image. Patches are still in the works for allowing individual kernel modules to utilize PGO.

Also sent in as part of Monday's pull was extending the Clang x86_64 LTO (Link Time Optimization) support merged the prior cycle to now also work for 32-bit x86 kernel builds.

More details on these LLVM/Clang compiler support improvements for Linux 5.14 via this PR.
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