vmm: Set reserve=on by default when hugepages=on - #8770
Conversation
rbradford
left a comment
There was a problem hiding this comment.
Thanks but this is wrong. We talk about the CLI as a shorthand but we also need to cover the API boot. Also we need to be clever and use Option type for compatibility.
|
Thanks @rbradford for the feedback, let me try to cover them. will update you. |
|
Hi @rbradford , |
rbradford
left a comment
There was a problem hiding this comment.
Thank you for taking my feedback onboard.
| impl MemoryZoneConfig { | ||
| pub fn reserve(&self) -> bool { | ||
| self.reserve.unwrap_or(self.hugepages && !self.prefault) | ||
| } | ||
| } | ||
|
|
There was a problem hiding this comment.
Not quite right. Apply the policy only in MemoryManager
| impl MemoryConfig { | ||
| pub fn reserve(&self) -> bool { | ||
| self.reserve.unwrap_or(self.hugepages && !self.prefault) | ||
| } | ||
| } | ||
|
|
| hugepage_size: None, | ||
| prefault: false, | ||
| reserve: false, | ||
| reserve: None, |
There was a problem hiding this comment.
Should be rolled into the commit that broke the build. Every commit needs to be buildable.
|
Thanks. Will work on it and update you. |
|
Hi, I have made the changes as suggested by you. Please take a look. Thanks. |
|
Sorry for the mess. Will correct and update by tomorrow. Thanks for feedback. |
|
Hi Rob, Thanks for all the feedback. I've squashed all 4 commits into one and moved the reserve default policy so it's applied only in MemoryManager, with the config structs keeping Option for API compatibility. Apologies for the messy history — appreciate your patience. Could you please take another look? |
rbradford
left a comment
There was a problem hiding this comment.
You should still keep the separate commit for making reserve an Option<bool>
| hugepage_size: Some(2 << 20), | ||
| size: 1 << 30, | ||
| hugepages: true, | ||
| // reserve is None; the effective default is computed in MemoryManager |
| region_size as usize, | ||
| prefault.unwrap_or(zone.prefault), | ||
| zone.reserve, | ||
| zone.reserve.unwrap_or(zone.hugepages && !zone.prefault), |
There was a problem hiding this comment.
Do you actually need the !zone.prefault ? How does this affect the flags in create_ram_region_raw() does it even matter?
|
I would look into |
|
Thanks, will update by tomorrow. |
Hi @rbradford , Need your little guidance here. I am planning to have two commits
I have Question:
Do you think this would be correct approach. Thanks. |
|
I
I don't know why you think you need to reference these old commits. Instead just split the commit you already had? Why would feel you need to add the helper when you can just to I took 5 minutes and updated the PR with the appropriate structure. Hope you don't mind. I think were were going around in circles over something which should be very simple. |
Make specifying this optional rather than a default of false so as to allow differentiating from intentionally included and false vs ambivalent. This prepares for enabling reserve when hugepages is enabled when the user does not intentionally disable reserve. See: cloud-hypervisor#8742 Signed-off-by: Shatrughan Rai <[email protected]> Signed-off-by: Rob Bradford <[email protected]>
|
I had to rebase and address some issues due to #8581 landing. |
Don't map with MADV_NORESERVE when hugepages are enabled unless the user has explicitly disabled reserving. Fixes: cloud-hypervisor#8742 Signed-off-by: Shatrughan Rai <[email protected]> Signed-off-by: Rob Bradford <[email protected]>
Good to hear. Hope you can understand why this split makes sense. In this case: 1. prep (and yes that meant adding |
Thanks for the explanation, The two-step split makes complete sense. Thanks. |
When hugepages=on but reserve isn't explicitly set, default reserve to on. This ensures the kernel reserves physical RAM for huge pages at boot time, exposing memory shortages early as a configuration error rather than later via a random SIGBUS mid-flight.
prefault=on takes precedence and is not affected, since prefaulting already implies reservation. Users can still explicitly set reserve=off.
Fixes #8742