Skip to content

[BOLT] Add writing support for Linux kernel ORC #80950

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

Merged
merged 2 commits into from
Feb 16, 2024
Merged

Conversation

maksfb
Copy link
Contributor

@maksfb maksfb commented Feb 7, 2024

Update ORC information based on the new code layout and emit
corresponding ORC sections for the Linux kernel.

We rewrite ORC sections in place, which puts a limit on the size of new
section contents. Since ORC info changes for the new code layout and the
number of ORC entries can become larger, we free up space in the tables
by removing redundant ORC terminators. As a result, we effectively emit
fewer entries and have to add duplicate terminators at the end to match
the original section sizes. Ideally, we need to update ORC boundaries to
reflect the reduced size and optimize runtime lookup, but we will need
relocations for this, and the benefits will be marginal, if any.

@maksfb
Copy link
Contributor Author

maksfb commented Feb 7, 2024

Depends on #80922 to work.

Update ORC information based on the new code layout and emit
corresponding ORC sections for the Linux kernel.
Copy link
Member

@dcci dcci left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Several comments but this looks fine after reading about ORC

Copy link
Member

@dcci dcci left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM, no need to go through an additional round for me.

@maksfb maksfb merged commit 5a29887 into llvm:main Feb 16, 2024
@maksfb maksfb deleted the gh-orc branch February 16, 2024 23:41
// Older kernels could contain unsorted tables in the file as the tables were
// sorted during boot time.
llvm::sort(ORCEntries);
outs() << "BOLT-INFO: parsed " << NumORCEntries << " ORC entries\n";
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sorry about late comment but we should be using BC.outs() after #81524

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LinuxKernelRewriter was still using old streams. #82195 includes the change.

@whentojump
Copy link
Member

Hi @maksfb Thanks for your great work!

I'm newbie here and have a naive question: this is designed to work with the sampling mode, not instrumentation mode. Right?
Also may I ask where I can find the steps of trying and reproducing some of the BOLT-kernel results? Much appreciated!

@maksfb
Copy link
Contributor Author

maksfb commented Feb 19, 2024

Hi @maksfb Thanks for your great work!

I'm newbie here and have a naive question: this is designed to work with the sampling mode, not instrumentation mode. Right? Also may I ask where I can find the steps of trying and reproducing some of the BOLT-kernel results? Much appreciated!

Hi @whentojump, in theory, it shouldn't matter how the profile for the kernel was collected. At the moment though, we don't have instrumentation support, so you have to use sampling.

For now, not all patches are in the main branch. Originally, there will be a constraint on the kernel config and version than are supported by BOLT. Once I upstream the first set, I'll publish the instructions.

@whentojump
Copy link
Member

whentojump commented Feb 19, 2024

Hi @whentojump, in theory, it shouldn't matter how the profile for the kernel was collected. At the moment though, we don't have instrumentation support, so you have to use sampling.

For now, not all patches are in the main branch. Originally, there will be a constraint on the kernel config and version than are supported by BOLT. Once I upstream the first set, I'll publish the instructions.

Thanks for the explanations! I look forward to the more complete work :))

we don't have instrumentation support

I suppose one reason is, on the kernel side we don't have a way of exporting the profile? If that's true, then we are in a similar stage as PGO. Both are actually something nice to have.

maksfb added a commit to maksfb/llvm-project that referenced this pull request Feb 21, 2024
The change in llvm#80950 exposed a memory leak in BinarySection. Let
BinarySection manage memory passed via updateContents() unless a valid
SectionID is set indicating that the contents are managed by JITLink.
maksfb added a commit that referenced this pull request Feb 21, 2024
The change in #80950 exposed a memory leak in BinarySection. Let
BinarySection manage memory passed via updateContents() unless a valid
SectionID is set indicating that the contents are managed by JITLink.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants