From bf9f79081af4d48596c2773656d074e6325ff820 Mon Sep 17 00:00:00 2001 From: Rob Bradford Date: Mon, 25 Apr 2022 16:21:34 +0100 Subject: [PATCH] vmm: Only create ACPI memory manager DSDT when resizable If using the ACPI based hotplug only memory can be added so if the hotplug RAM size is the same as the boot RAM size then do not include the memory manager DSDT entries. Also: this change simplifies the code marginally by making the HotplugMethod enum Copyable. This was identified from the following perf output: 1.78% 0.00% vmm cloud-hypervisor [.] ::append_aml_bytes | ---::append_aml_bytes ::append_aml_bytes acpi_tables::aml::Name::new ::append_aml_bytes __libc_malloc Signed-off-by: Rob Bradford --- vmm/src/config.rs | 2 +- vmm/src/memory_manager.rs | 10 +++++----- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/vmm/src/config.rs b/vmm/src/config.rs index c61920aef..c3a9c9d8a 100644 --- a/vmm/src/config.rs +++ b/vmm/src/config.rs @@ -419,7 +419,7 @@ impl<'a> VmParams<'a> { } } -#[derive(Clone, Debug, PartialEq, Deserialize, Serialize)] +#[derive(Clone, Copy, Debug, PartialEq, Deserialize, Serialize)] pub enum HotplugMethod { Acpi, VirtioMem, diff --git a/vmm/src/memory_manager.rs b/vmm/src/memory_manager.rs index 51a2499bb..20d168e8f 100644 --- a/vmm/src/memory_manager.rs +++ b/vmm/src/memory_manager.rs @@ -1023,9 +1023,10 @@ impl MemoryManager { #[cfg(feature = "tdx")] let dynamic = !tdx_enabled; - let hotplug_method = config.hotplug_method.clone(); - - let acpi_address = if dynamic && hotplug_method == HotplugMethod::Acpi { + let acpi_address = if dynamic + && config.hotplug_method == HotplugMethod::Acpi + && (config.hotplug_size.unwrap_or_default() > 0) + { Some( allocator .lock() @@ -1054,7 +1055,7 @@ impl MemoryManager { selected_slot, mergeable: config.mergeable, allocator, - hotplug_method, + hotplug_method: config.hotplug_method, boot_ram, current_ram, next_hotplug_slot, @@ -1068,7 +1069,6 @@ impl MemoryManager { snapshot_memory_ranges: MemoryRangeTable::default(), memory_zones, guest_ram_mappings: Vec::new(), - acpi_address, log_dirty: dynamic, // Cannot log dirty pages on a TD arch_mem_regions,