[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[PATCH v3 15/49] kvm/memory: Make memory type private by default if it h
From: |
Michael Roth |
Subject: |
[PATCH v3 15/49] kvm/memory: Make memory type private by default if it has guest memfd backend |
Date: |
Wed, 20 Mar 2024 03:39:11 -0500 |
From: Xiaoyao Li <xiaoyao.li@intel.com>
KVM side leaves the memory to shared by default, while may incur the
overhead of paging conversion on the first visit of each page. Because
the expectation is that page is likely to private for the VMs that
require private memory (has guest memfd).
Explicitly set the memory to private when memory region has valid
guest memfd backend.
Signed-off-by: Xiaoyao Li <xiaoyao.li@intel.com>
Signed-off-by: Michael Roth <michael.roth@amd.com>
---
accel/kvm/kvm-all.c | 10 ++++++++++
1 file changed, 10 insertions(+)
diff --git a/accel/kvm/kvm-all.c b/accel/kvm/kvm-all.c
index 9a8b365a69..53ce4f091e 100644
--- a/accel/kvm/kvm-all.c
+++ b/accel/kvm/kvm-all.c
@@ -1451,6 +1451,16 @@ static void kvm_set_phys_mem(KVMMemoryListener *kml,
strerror(-err));
abort();
}
+
+ if (memory_region_has_guest_memfd(mr)) {
+ err = kvm_set_memory_attributes_private(start_addr, slot_size);
+ if (err) {
+ error_report("%s: failed to set memory attribute private:
%s\n",
+ __func__, strerror(-err));
+ exit(1);
+ }
+ }
+
start_addr += slot_size;
ram_start_offset += slot_size;
ram += slot_size;
--
2.25.1
- Re: [PATCH v3 10/49] kvm: Introduce support for memory_attributes, (continued)
- [PATCH v3 12/49] kvm: handle KVM_EXIT_MEMORY_FAULT, Michael Roth, 2024/03/20
- [PATCH v3 13/49] [FIXUP] "kvm: handle KVM_EXIT_MEMORY_FAULT": drop qemu_host_page_size, Michael Roth, 2024/03/20
- [PATCH v3 14/49] trace/kvm: Add trace for page convertion between shared and private, Michael Roth, 2024/03/20
- [PATCH v3 15/49] kvm/memory: Make memory type private by default if it has guest memfd backend,
Michael Roth <=
- [PATCH v3 16/49] memory: Introduce memory_region_init_ram_guest_memfd(), Michael Roth, 2024/03/20
- [PATCH v3 17/49] pci-host/q35: Move PAM initialization above SMRAM initialization, Michael Roth, 2024/03/20
- [PATCH v3 18/49] q35: Introduce smm_ranges property for q35-pci-host, Michael Roth, 2024/03/20
- [PATCH v3 19/49] kvm: Make kvm_convert_memory() obey ram_block_discard_is_enabled(), Michael Roth, 2024/03/20
- [PATCH v3 20/49] trace/kvm: Add trace for KVM_EXIT_MEMORY_FAULT, Michael Roth, 2024/03/20
- [PATCH v3 01/49] Revert "linux-headers hack" from sevinit2 base tree, Michael Roth, 2024/03/20
- [PATCH v3 21/49] i386/sev: Introduce "sev-common" type to encapsulate common SEV state, Michael Roth, 2024/03/20