Skip to content

Commit 06b9ab9

Browse files
committed
Send page size information to UFFD handler during handshake
When using a page-size agnostic UFFD handler, orchestration becomes easier if Firecracker tells the UFFD handler about page size (instead of some orchestrator having to tell both Firecracker and the UFFD handler about the page size independently). Thus, send along the page size in the initial payload that Firecracker sends to the UFFD handler (e.g. the one also containing information about the memory regions). We send the page size information for each region (even though Firecracker does not support per-region configuration of huge pages) for backward compatibility reasons (changing the top-level json object from a list of region to a dictionary would be a breaking change, but adding a field to each list entry is not). Signed-off-by: Patrick Roy <[email protected]>
1 parent f3549ec commit 06b9ab9

File tree

2 files changed

+11
-0
lines changed

2 files changed

+11
-0
lines changed

src/vmm/src/persist.rs

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -102,6 +102,8 @@ pub struct GuestRegionUffdMapping {
102102
pub size: usize,
103103
/// Offset in the backend file/buffer where the region contents are.
104104
pub offset: u64,
105+
/// The configured page size for this memory region.
106+
pub page_size_kib: usize,
105107
}
106108

107109
/// Errors related to saving and restoring Microvm state.
@@ -542,6 +544,7 @@ fn guest_memory_from_uffd(
542544
base_host_virt_addr: host_base_addr as u64,
543545
size,
544546
offset: state_region.offset,
547+
page_size_kib: huge_pages.page_size_kib(),
545548
});
546549
}
547550

src/vmm/src/vmm_config/machine_config.rs

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -84,6 +84,14 @@ impl HugePageConfig {
8484
pub fn is_hugetlbfs(&self) -> bool {
8585
matches!(self, HugePageConfig::Hugetlbfs2M)
8686
}
87+
88+
/// Gets the page size in KiB of this [`HugePageConfig`].
89+
pub fn page_size_kib(&self) -> usize {
90+
match self {
91+
HugePageConfig::None => 4096,
92+
HugePageConfig::Hugetlbfs2M => 2 * 1024 * 1024,
93+
}
94+
}
8795
}
8896

8997
impl From<HugePageConfig> for Option<memfd::HugetlbSize> {

0 commit comments

Comments
 (0)