forked from cloud-hypervisor/cloud-hypervisor
-
Notifications
You must be signed in to change notification settings - Fork 2
docs: CPU Profile generation #121
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
Open
olivereanderson
wants to merge
1
commit into
cyberus-technology:gardenlinux
Choose a base branch
from
olivereanderson:cpu-profile-generation-documentation
base: gardenlinux
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,54 @@ | ||
| # CPU Profile Generation | ||
|
|
||
| ## Generating a CPU profile for a new target | ||
|
|
||
| To generate a new CPU profile you start by executing the following command | ||
|
|
||
| ```shell | ||
| $ cargo run --release -p arch --bin generate-cpu-profile --features="cpu_profile_generation" "<Your chosen name for the CPU profile>" | ||
|
|
||
| ``` | ||
| on the machine you want to create a CPU profile for. This creates four new files in the `arch/src/x86_64/cpu_profiles` directory: | ||
| - `<your chosen name in lower case with spaces replaced by underscore (_)>.cpuid.json` | ||
| - `<your chosen name in lower case with spaces replaced by underscore (_)>.msr.json` | ||
| - one license file for each of the two files listed above | ||
|
|
||
| check them in to git and then extend the `arch::x86_64::CpuProfile` enum with a new variant for your freshly generated profile. | ||
|
|
||
| The final step is then to adapt `arch::x86_64::CpuProfile::cpuid_data` and `arch::x86_64::CpuProfile::msr_data` mutatis mutandis | ||
| to load the cpuid and msr JSON files we created above. | ||
|
|
||
| ## Can existing CPU profiles be updated? | ||
|
|
||
| More recent KVM versions may introduce more support for already existing hardware features. When this happens it is of course | ||
| tempting to run the CPU profile generation tool again with the new KVM version as we then get a profile supporting more CPU | ||
| functionality. Doing this without giving the CPU profile a new name is however a breaking change and thus not permitted. | ||
| Such PRs will **not be accepted**. Instead we encourage you add a `V2` (or higher number if `V<i>` already exists) suffix | ||
| when generating the profile. | ||
|
|
||
| ## Outlook | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I see your idea and the writeup is valuabe! I think however this belongs to an issue. Outlook section may link to an issue, tho. |
||
|
|
||
| We intend to improve both CPU profile support in Cloud hypervisor as well as the CPU profile generation tool. Here is a | ||
| list of ideas that we want to consider. | ||
|
|
||
| ### Buildscript: Full automation and (de-) compression | ||
|
|
||
| We will include a build script that automatically extends the `CpuProfile` enum and updates the `cpuid_data` and `msr_data` | ||
| methods accordingly. | ||
|
|
||
| While we are at it we can also make the build script compress the JSON files and place those bytes into the binary instead | ||
| of the full JSON files as we currently do. | ||
|
|
||
| ### CPU Profile upload endpoint | ||
|
|
||
| It would not be much effort to adapt CHV to permit end users to specify their own JSON files instead of those associated | ||
| with a profile name. | ||
|
|
||
| This way users can run the CPU profile generation tool on their own hardware and use the resulting CPU profile without | ||
| involving upstream. | ||
|
|
||
| Advanced users also get a lot of control to adjust CPU profiles to satisfy their needs as they can now manipulate several | ||
| CPUID and/or MSR-based features themselves. | ||
|
|
||
| Before we go ahead with this however, we need to clearly document which changes Cloud hypervisor makes itself regardless | ||
| of the selected CPU profile. | ||
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Maybe it is just me but I had to google the meaning of
mutatis mutandisUh oh!
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I will try to find a simpler formulation. As always there is no need to be unnecessarily fancy. I just don't know of any other concise way to say exactly that, but it doesn't hurt to spend a few more words here anyway 🙂