From b7355b4e8ed63f2c6d315c88733e41a06d767550 Mon Sep 17 00:00:00 2001 From: acsmyth <54330152+acsmyth@users.noreply.github.com> Date: Fri, 6 Dec 2024 12:57:19 +0000 Subject: [PATCH] fix: rename page_size_kib to page_size Signed-off-by: acsmyth <54330152+acsmyth@users.noreply.github.com> --- CHANGELOG.md | 2 +- src/firecracker/examples/uffd/uffd_utils.rs | 8 ++++---- src/vmm/src/persist.rs | 13 +++++-------- src/vmm/src/vmm_config/machine_config.rs | 4 ++-- .../performance/test_huge_pages.py | 4 ++-- 5 files changed, 14 insertions(+), 17 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 6e7be8f518f..082af86be8d 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -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 diff --git a/src/firecracker/examples/uffd/uffd_utils.rs b/src/firecracker/examples/uffd/uffd_utils.rs index 52d33765bd8..ce09d216247 100644 --- a/src/firecracker/examples/uffd/uffd_utils.rs +++ b/src/firecracker/examples/uffd/uffd_utils.rs @@ -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)] @@ -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); @@ -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(); @@ -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 diff --git a/src/vmm/src/persist.rs b/src/vmm/src/persist.rs index 3479e0b6309..42decce8d92 100644 --- a/src/vmm/src/persist.rs +++ b/src/vmm/src/persist.rs @@ -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. @@ -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(), }); } @@ -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] @@ -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(), }, ]; diff --git a/src/vmm/src/vmm_config/machine_config.rs b/src/vmm/src/vmm_config/machine_config.rs index 8eee91c88be..c070ecd0421 100644 --- a/src/vmm/src/vmm_config/machine_config.rs +++ b/src/vmm/src/vmm_config/machine_config.rs @@ -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, diff --git a/tests/integration_tests/performance/test_huge_pages.py b/tests/integration_tests/performance/test_huge_pages.py index 8437d78c7d3..37db574741c 100644 --- a/tests/integration_tests/performance/test_huge_pages.py +++ b/tests/integration_tests/performance/test_huge_pages.py @@ -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 def test_hugetlbfs_boot(uvm_plain):