From 5163156676e84845de854677b2dc7a38b06e10a9 Mon Sep 17 00:00:00 2001 From: Fupan Li Date: Thu, 12 Jun 2025 22:00:41 +0800 Subject: [PATCH] runtime-rs: add the memory prealloc support for cloud-hypervisor Add the memory prealloc support for cloud hypervisor too. Signed-off-by: Fupan Li --- .../config/configuration-cloud-hypervisor.toml.in | 9 +++++++++ .../crates/hypervisor/ch-config/src/convert.rs | 2 ++ 2 files changed, 11 insertions(+) diff --git a/src/runtime-rs/config/configuration-cloud-hypervisor.toml.in b/src/runtime-rs/config/configuration-cloud-hypervisor.toml.in index 7eac48c100..daa86edf01 100644 --- a/src/runtime-rs/config/configuration-cloud-hypervisor.toml.in +++ b/src/runtime-rs/config/configuration-cloud-hypervisor.toml.in @@ -177,6 +177,15 @@ block_device_driver = "virtio-blk-pci" # Default false #block_device_cache_direct = true +# Enable pre allocation of VM RAM, default false +# Enabling this will result in lower container density +# as all of the memory will be allocated and locked +# This is useful when you want to reserve all the memory +# upfront or in the cases where you want memory latencies +# to be very predictable +# Default false +#enable_mem_prealloc = true + # Enable huge pages for VM RAM, default false # Enabling this will result in the VM memory # being allocated using huge pages. diff --git a/src/runtime-rs/crates/hypervisor/ch-config/src/convert.rs b/src/runtime-rs/crates/hypervisor/ch-config/src/convert.rs index 09443323c5..09c14d7b67 100644 --- a/src/runtime-rs/crates/hypervisor/ch-config/src/convert.rs +++ b/src/runtime-rs/crates/hypervisor/ch-config/src/convert.rs @@ -285,6 +285,8 @@ impl TryFrom<(MemoryInfo, GuestProtection)> for MemoryConfig { hotplug_size, + prefault: mem.enable_mem_prealloc, + ..Default::default() };