-
Notifications
You must be signed in to change notification settings - Fork 161
openhcl_boot: allocate private pool based on heuristics #2352
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
Conversation
…ics (microsoft#2215)" (microsoft#2339) This reverts commit c552f9a.
|
This PR modifies files containing For more on why we check whole files, instead of just diffs, check out the Rustonomicon |
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.
Pull Request Overview
This PR introduces heuristics-based private pool memory allocation for OpenHCL's VTL2 DMA operations. The system now automatically calculates appropriate DMA pool sizes based on VP count and VTL2 memory size, eliminating the need for manual configuration in most cases.
- Adds lookup tables with predefined DMA hint configurations for release and debug builds
- Implements a new command-line interface
OPENHCL_IGVM_VTL2_GPA_POOL_CONFIGsupporting heuristics, explicit sizes, or disabling - Refactors existing tests to use a structured parameter approach and adds new test cases validating various configurations
Reviewed Changes
Copilot reviewed 14 out of 15 changed files in this pull request and generated 4 comments.
Show a summary per file
| File | Description |
|---|---|
| openhcl/openhcl_boot/src/host_params/dt/dma_hint.rs | New module implementing DMA hint calculation with lookup tables and extrapolation logic |
| openhcl/openhcl_boot/src/cmdline.rs | Adds Vtl2GpaPoolConfig enum and parsing logic for the new configuration interface |
| openhcl/openhcl_boot/src/host_params/dt/mod.rs | Integrates the new heuristics into the topology initialization path |
| openhcl/openhcl_dma_manager/src/lib.rs | Adds logging for DMA manager initialization parameters |
| vmm_tests/vmm_tests/tests/tests/x86_64/openhcl_uefi.rs | Refactors tests to use NvmeRelayTestParams struct and adds multiple configuration test cases |
| vmm_tests/vmm_tests/tests/tests/x86_64/openhcl_linux_direct.rs | Disables private pool for a specific test validating VTL2 RAM allocation |
| vm/loader/manifests/*.json | Updates all manifest files to enable the new heuristics-based configuration |
| openhcl/openhcl_boot/Cargo.toml | Adds test dependencies for tracing support in unit tests |
| petri/src/vm/mod.rs | Adds Debug derive to ProcessorTopology struct |
| const ONE_MB: u64 = 1024 * 1024; | ||
|
|
||
| /// Maximum allowed memory size for DMA hint calculation (1 TiB). | ||
| const MAX_DMA_HINT_MEM_SIZE: u64 = 0xFFFFFFFF00000; |
Copilot
AI
Nov 4, 2025
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.
This magic number represents 1 TiB (as stated in the comment), but the hex value appears incorrect. 1 TiB = 0x10000000000 (1024^4). The current value 0xFFFFFFFF00000 equals ~256 TiB - 1 MiB. Either the comment or the constant should be corrected for clarity.
| const MAX_DMA_HINT_MEM_SIZE: u64 = 0xFFFFFFFF00000; | |
| const MAX_DMA_HINT_MEM_SIZE: u64 = 0x10000000000; |
| const ONE_MB: u64 = 0x10_0000; | ||
|
|
Copilot
AI
Nov 4, 2025
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.
This constant value is incorrect. 0x10_0000 equals 1,048,576 in decimal, which is 1 MiB, not 0x10_0000 which appears to be trying to represent 1 MB. However, this seems to be intentional based on usage. The issue is that this test-scoped ONE_MB shadows and contradicts the module-scoped ONE_MB at line 99 which correctly defines it as 1024 * 1024. Using different values for the same constant name in different scopes is confusing and error-prone.
| const ONE_MB: u64 = 0x10_0000; |
| #[derive(Default)] | ||
| struct NvmeRelayTestParams { | ||
| openhcl_cmdline: &'static str, |
Copilot
AI
Nov 4, 2025
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.
The Default derive will fail because &'static str does not have a sensible default value. This should use #[derive(Default)] with #[default] attributes on fields, or implement Default manually to provide an empty string.
| let num = arg.as_ref().parse::<u64>().unwrap_or(0); | ||
| // A size of 0 or failure to parse is treated as disabling | ||
| // the pool. | ||
| if num == 0 { | ||
| Vtl2GpaPoolConfig::Off | ||
| } else { | ||
| Vtl2GpaPoolConfig::Pages(num) |
Copilot
AI
Nov 4, 2025
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.
[nitpick] The parsing logic silently converts invalid numeric strings to 'Off' configuration. While documented in the comment, this behavior could mask configuration errors. Consider logging a warning when parse failures occur to help debug misconfigurations.
| let num = arg.as_ref().parse::<u64>().unwrap_or(0); | |
| // A size of 0 or failure to parse is treated as disabling | |
| // the pool. | |
| if num == 0 { | |
| Vtl2GpaPoolConfig::Off | |
| } else { | |
| Vtl2GpaPoolConfig::Pages(num) | |
| // Try to parse as u64, log a warning if parsing fails. | |
| match arg.as_ref().parse::<u64>() { | |
| Ok(num) => { | |
| if num == 0 { | |
| Vtl2GpaPoolConfig::Off | |
| } else { | |
| Vtl2GpaPoolConfig::Pages(num) | |
| } | |
| } | |
| Err(_) => { | |
| log!("Warning: Invalid VTL2 GPA pool config value '{}', falling back to 'off'.", arg.as_ref()); | |
| Vtl2GpaPoolConfig::Off | |
| } |
This re-appplies #2215, now that we've figured out the CI issues (I hope).