Skip to content
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

fix: rename page_size_kib to page_size #4948

Draft
wants to merge 1 commit into
base: main
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -261,7 +261,7 @@ and this project adheres to

- [#4449](https://github.com/firecracker-microvm/firecracker/pull/4449): Added
information about page size to the payload Firecracker sends to the UFFD
handler. Each memory region object now contains a `page_size_kib` field. See
handler. Each memory region object now contains a `page_size` field. See
also the [hugepages documentation](docs/hugepages.md).

- [#4498](https://github.com/firecracker-microvm/firecracker/pull/4498): Only
Expand Down
8 changes: 4 additions & 4 deletions src/firecracker/examples/uffd/uffd_utils.rs
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ pub struct GuestRegionUffdMapping {
/// Offset in the backend file/buffer where the region contents are.
pub offset: u64,
/// The configured page size for this memory region.
pub page_size_kib: usize,
pub page_size: usize,
}

#[derive(Debug, Clone, Copy)]
Expand Down Expand Up @@ -71,7 +71,7 @@ impl UffdHandler {
.expect("Cannot deserialize memory mappings.");
let memsize: usize = mappings.iter().map(|r| r.size).sum();
// Page size is the same for all memory regions, so just grab the first one
let page_size = mappings.first().unwrap().page_size_kib;
let page_size = mappings.first().unwrap().page_size;

// Make sure memory size matches backing data size.
assert_eq!(memsize, size);
Expand Down Expand Up @@ -341,7 +341,7 @@ mod tests {
base_host_virt_addr: 0,
size: 0x1000,
offset: 0,
page_size_kib: 4096,
page_size: 4096,
}];
let dummy_memory_region_json = serde_json::to_string(&dummy_memory_region).unwrap();

Expand Down Expand Up @@ -374,7 +374,7 @@ mod tests {
base_host_virt_addr: 0,
size: 0,
offset: 0,
page_size_kib: 4096,
page_size: 4096,
}];
let error_memory_region_json = serde_json::to_string(&error_memory_region).unwrap();
stream
Expand Down
13 changes: 5 additions & 8 deletions src/vmm/src/persist.rs
Original file line number Diff line number Diff line change
Expand Up @@ -105,7 +105,7 @@ pub struct GuestRegionUffdMapping {
/// Offset in the backend file/buffer where the region contents are.
pub offset: u64,
/// The configured page size for this memory region.
pub page_size_kib: usize,
pub page_size: usize,
}

/// Errors related to saving and restoring Microvm state.
Expand Down Expand Up @@ -586,7 +586,7 @@ fn create_guest_memory(
base_host_virt_addr: mem_region.as_ptr() as u64,
size: mem_region.size(),
offset: state_region.offset,
page_size_kib: huge_pages.page_size_kib(),
page_size: huge_pages.page_size(),
});
}

Expand Down Expand Up @@ -776,10 +776,7 @@ mod tests {
assert_eq!(uffd_regions.len(), 1);
assert_eq!(uffd_regions[0].size, 0x20000);
assert_eq!(uffd_regions[0].offset, 0x10000);
assert_eq!(
uffd_regions[0].page_size_kib,
HugePageConfig::None.page_size_kib()
);
assert_eq!(uffd_regions[0].page_size, HugePageConfig::None.page_size());
}

#[test]
Expand All @@ -789,13 +786,13 @@ mod tests {
base_host_virt_addr: 0,
size: 0x100000,
offset: 0,
page_size_kib: HugePageConfig::None.page_size_kib(),
page_size: HugePageConfig::None.page_size(),
},
GuestRegionUffdMapping {
base_host_virt_addr: 0x100000,
size: 0x200000,
offset: 0,
page_size_kib: HugePageConfig::Hugetlbfs2M.page_size_kib(),
page_size: HugePageConfig::Hugetlbfs2M.page_size(),
},
];

Expand Down
4 changes: 2 additions & 2 deletions src/vmm/src/vmm_config/machine_config.rs
Original file line number Diff line number Diff line change
Expand Up @@ -73,8 +73,8 @@ impl HugePageConfig {
matches!(self, HugePageConfig::Hugetlbfs2M)
}

/// Gets the page size in KiB of this [`HugePageConfig`].
pub fn page_size_kib(&self) -> usize {
/// Gets the page size in bytes of this [`HugePageConfig`].
pub fn page_size(&self) -> usize {
match self {
HugePageConfig::None => 4096,
HugePageConfig::Hugetlbfs2M => 2 * 1024 * 1024,
Expand Down
4 changes: 2 additions & 2 deletions tests/integration_tests/performance/test_huge_pages.py
Original file line number Diff line number Diff line change
Expand Up @@ -51,8 +51,8 @@ def check_hugetlbfs_in_use(pid: int, allocation_name: str):
cmd = f"cat /proc/{pid}/smaps | grep {allocation_name} -A 23 | grep KernelPageSize"
_, stdout, _ = utils.check_output(cmd)

kernel_page_size_kib = int(stdout.split()[1])
assert kernel_page_size_kib > 4
kernel_page_size = int(stdout.split()[1])
assert kernel_page_size > 4096
Comment on lines +54 to +55
Copy link
Contributor

Choose a reason for hiding this comment

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

Is this intended? the smaps file does report this value in kB:

KernelPageSize:        4 kB

I think this should be left as-is.

Copy link
Contributor

Choose a reason for hiding this comment

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

Other than that, it looks good to me. Thanks for your contribution! :)



def test_hugetlbfs_boot(uvm_plain):
Expand Down
Loading