Skip to content

[BOLT][perf2bolt] BOLTing the Linux Kernel, perf2bolt stage fails #138957

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
MichaelDeets opened this issue May 7, 2025 · 2 comments
Closed

[BOLT][perf2bolt] BOLTing the Linux Kernel, perf2bolt stage fails #138957

MichaelDeets opened this issue May 7, 2025 · 2 comments
Labels

Comments

@MichaelDeets
Copy link

MichaelDeets commented May 7, 2025

I'm trying to BOLT my Linux Kernel. I've run a quick perf, then, while attempting to convert into a usable BOLT profile using perf2bolt, it results in this error:

Linux kernel version is unknown

I attempted to circumvent by patching bolt/lib/Rewrite/LinuxKernelRewriter.cpp and removed the check, which then, after re-running perf2bolt, results in this error:

BOLT-ERROR: while running linux-kernel-rewriter in pre-CFG state: invalid target of static keys jump at 0xffffffff81321c9c : 0xffffffff8120556e

Which stumped me for a while, as this is my first attempt at using BOLT and I'm unfamiliar with most things regarding it. What worked for me, was setting the "CONFIG_JUMP_LABEL=n" option in my Linux Kernel's configuration. I'm also using LTO, which might've contribute to this problem. I'll upload my full kernel configuration for reference.

I just hadn't seen anything regarding "CONFIG_JUMP_LABEL=n" being a requirement, and couldn't find anyone else online with similar issues, hence this bug report. Apologies in advanced if I had missed an existing bug report regarding this problem. I'm happy to attach anything else required, please let me know!

For all my LLVM related packages, I have them installed using my package manager (Portage), but for BOLT I simply build using 20.1.4 source, and also attempted the latest git version, but no changes between them.

Steps that resulted in the error:

Using https://github.com/llvm/llvm-project/blob/main/bolt/docs/OptimizingLinux.md as the guide:

1: Built the Linux Kernel with various options, like LTO, AutoFDO, Propeller, etc. enabled, all built using LLVM/Clang 20.1.4

2: Performed a perf using the command perf record -a -e cycles -j any,k -F 5000 -- sleep 600

3: Ran the command perf2bolt -p perf.data -o perf.fdata, which returned the first error.

I repeated the same steps after patching this out, and received the second error.

Only after setting "CONFIG_JUMP_LABEL=n", rebuilding the kernel, then repeating the steps, would it result in the perf.fdata file.

I have included the output from perf2bolt on the second error, but I'm using a different vmlinux binary so it might appear somewhat off, but it results in the same error.

perf2bolt.log

config.txt

@llvmbot
Copy link
Member

llvmbot commented May 7, 2025

@llvm/issue-subscribers-bolt

Author: deets (MichaelDeets)

I'm trying to BOLT my Linux Kernel. I've run a quick perf, then, while attempting to convert into a usable BOLT profile using perf2bolt, it results in this error:

Linux kernel version is unknown

I attempted to circumvent by patching bolt/lib/Rewrite/LinuxKernelRewriter.cpp and removed the check, which then, after re-running perf2bolt, results in this error:

BOLT-ERROR: while running linux-kernel-rewriter in pre-CFG state: invalid target of static keys jump at 0xffffffff81321c9c : 0xffffffff8120556e

Which stumped me for a while, as this is my first attempt at using BOLT and I'm unfamiliar with most things regarding it. What worked for me, was setting the "CONFIG_JUMP_LABEL=n" option in my Linux Kernel's configuration. I'm also using LTO, which might've contribute to this problem. I'll upload my full kernel configuration for reference.

I just hadn't seen anything regarding "CONFIG_JUMP_LABEL=n" being a requirement, and couldn't find anyone else online with similar issues, hence this bug report. Apologies in advanced if I had missed an existing bug report regarding this problem. I'm happy to attach anything else required, please let me know!

For all my LLVM related packages, I have them installed using my package manager (Portage), but for BOLT I simply build using 20.1.4 source, and also attempted the latest git version, but no changes between them.

Steps that resulted in the error:

Using https://github.com/llvm/llvm-project/blob/main/bolt/docs/OptimizingLinux.md as the guide:

1: Built the Linux Kernel with various options, like LTO, AutoFDO, Propeller, etc. enabled, all built using LLVM/Clang 20.1.4

2: Performed a perf using the command perf record -a -e cycles -j any,k -F 5000 -- sleep 600

3: Ran the command perf2bolt -p perf.data -o perf.fdata, which returned the first error.

I repeated the same steps after patching this out, and received the second error.

Only after setting "CONFIG_JUMP_LABEL=n", rebuilding the kernel, then repeating the steps, would it result in the perf.fdata file.

I have included the output from perf2bolt on the second error, but I'm using a different vmlinux binary so it might appear somewhat off, but it results in the same error.

perf2bolt.log

kernel-config.txt

@MichaelDeets MichaelDeets changed the title [BOLT][X86] BOLTing the Linux Kernel, perf2bolt stage fails [BOLT][perf2bolt] BOLTing the Linux Kernel, perf2bolt stage fails May 8, 2025
@MichaelDeets
Copy link
Author

MichaelDeets commented May 12, 2025

After updating to 6.15-rc6, I rebased all my patches and it now works. I believe it was some old stale patch I had floating around that caused this issue. Will reopen if I come across again.

EDIT: Spoke too soon. It's probably something wrong with my configuration. Will do more tests before reopening.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

3 participants