kvm.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [RFC PATCH 0/1] accel/kvm: implement KVM_SET_USER_MEMORY_REGION_LIST
@ 2022-09-09 11:00 Emanuele Giuseppe Esposito
  2022-09-09 11:00 ` [RFC PATCH 1/1] kvm/kvm-all.c: implement KVM_SET_USER_MEMORY_REGION_LIST ioctl Emanuele Giuseppe Esposito
  0 siblings, 1 reply; 2+ messages in thread
From: Emanuele Giuseppe Esposito @ 2022-09-09 11:00 UTC (permalink / raw)
  To: qemu-devel
  Cc: Paolo Bonzini, Cornelia Huck, Peter Xu, David Hildenbrand,
	Maxim Levitsky, kvm, Emanuele Giuseppe Esposito

Use the new KVM ioctl KVM_SET_USER_MEMORY_REGION_LIST.
Based on my QEMU serie "[RFC PATCH v2 0/3] accel/kvm: extend kvm memory listener to support".

Based-on: 20220909081150.709060-1-eesposit@redhat.com

Requires my KVM serie "[RFC PATCH 0/9] kvm: implement atomic memslot updates"
https://lkml.org/lkml/2022/9/9/533

Emanuele Giuseppe Esposito (1):
  kvm/kvm-all.c: implement KVM_SET_USER_MEMORY_REGION_LIST ioctl

 accel/kvm/kvm-all.c | 25 ++++++++++---------------
 1 file changed, 10 insertions(+), 15 deletions(-)

-- 
2.31.1


^ permalink raw reply	[flat|nested] 2+ messages in thread

* [RFC PATCH 1/1] kvm/kvm-all.c: implement KVM_SET_USER_MEMORY_REGION_LIST ioctl
  2022-09-09 11:00 [RFC PATCH 0/1] accel/kvm: implement KVM_SET_USER_MEMORY_REGION_LIST Emanuele Giuseppe Esposito
@ 2022-09-09 11:00 ` Emanuele Giuseppe Esposito
  0 siblings, 0 replies; 2+ messages in thread
From: Emanuele Giuseppe Esposito @ 2022-09-09 11:00 UTC (permalink / raw)
  To: qemu-devel
  Cc: Paolo Bonzini, Cornelia Huck, Peter Xu, David Hildenbrand,
	Maxim Levitsky, kvm, Emanuele Giuseppe Esposito

Instead of sending memslot updates in each callback, kvm listener
already takes care of sending them in the commit phase, as multiple
ioctls.

Using the new KVM_SET_USER_MEMORY_REGION_LIST, we just need a single
call containing all memory regions to update.

Signed-off-by: Emanuele Giuseppe Esposito <eesposit@redhat.com>
---
 accel/kvm/kvm-all.c | 25 ++++++++++---------------
 1 file changed, 10 insertions(+), 15 deletions(-)

diff --git a/accel/kvm/kvm-all.c b/accel/kvm/kvm-all.c
index 9780f3d2da..6a7f7b4567 100644
--- a/accel/kvm/kvm-all.c
+++ b/accel/kvm/kvm-all.c
@@ -1547,30 +1547,25 @@ static void kvm_commit(MemoryListener *listener)
     KVMMemoryListener *kml = container_of(listener, KVMMemoryListener,
                                           listener);
     KVMState *s = kvm_state;
-    int i;
+    int i, ret;
 
     for (i = 0; i < kml->mem_array.list->nent; i++) {
         struct kvm_userspace_memory_region_entry *mem;
-        int ret;
 
         mem = &kml->mem_array.list->entries[i];
 
-        /*
-         * Note that mem is struct kvm_userspace_memory_region_entry, while the
-         * kernel expects a kvm_userspace_memory_region, so it will currently
-         * ignore mem->invalidate_slot and mem->padding.
-         */
-        ret = kvm_vm_ioctl(s, KVM_SET_USER_MEMORY_REGION, mem);
-
         trace_kvm_set_user_memory(mem->slot, mem->flags, mem->guest_phys_addr,
                                   mem->memory_size, mem->userspace_addr, 0);
+    }
 
-        if (ret < 0) {
-            error_report("%s: KVM_SET_USER_MEMORY_REGION failed, slot=%d,"
-                         " start=0x%" PRIx64 ": %s",
-                         __func__, mem->slot,
-                         (uint64_t)mem->memory_size, strerror(errno));
-        }
+    ret = kvm_vm_ioctl(s, KVM_SET_USER_MEMORY_REGION_LIST, kml->mem_array.list);
+
+    if (ret < 0) {
+        error_report("%s: KVM_SET_USER_MEMORY_REGION_LIST failed, size=0x%"
+                     PRIx64 " flags=0x%" PRIx64 ": %s",
+                     __func__, (uint64_t)kml->mem_array.list->nent,
+                     (uint64_t)kml->mem_array.list->flags,
+                     strerror(errno));
     }
 
     kml->mem_array.list->nent = 0;
-- 
2.31.1


^ permalink raw reply related	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2022-09-09 11:02 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-09-09 11:00 [RFC PATCH 0/1] accel/kvm: implement KVM_SET_USER_MEMORY_REGION_LIST Emanuele Giuseppe Esposito
2022-09-09 11:00 ` [RFC PATCH 1/1] kvm/kvm-all.c: implement KVM_SET_USER_MEMORY_REGION_LIST ioctl Emanuele Giuseppe Esposito

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).