[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [RFC PATCH 3/3] kvm: Atomic memslot updates
From: |
Paolo Bonzini |
Subject: |
Re: [RFC PATCH 3/3] kvm: Atomic memslot updates |
Date: |
Tue, 8 Nov 2022 17:25:36 +0100 |
User-agent: |
Mozilla/5.0 (X11; Linux x86_64; rv:102.0) Gecko/20100101 Thunderbird/102.4.0 |
On 11/4/22 16:14, Emanuele Giuseppe Esposito wrote:
+ g_assert(qemu_mutex_iothread_locked());
Please add a comment here:
/* Block further invocations of the ioctls outside the BQL. */
+ CPU_FOREACH(cpu) {
+ qemu_lockcnt_lock(&cpu->in_ioctl_lock);
+ }
+ qemu_lockcnt_lock(&kvm_in_ioctl_lock);
- kvm_set_phys_mem(kml, section, false);
- memory_region_unref(section->mr);
+ /* Inhibiting happens rarely, we can keep things simple and spin here. */
Not making it spin is pretty easy. You can add a qemu_event_set to
kvm_set_in_ioctl() and kvm_cpu_set_in_ioctl(), and here something like:
if (in_kvm_ioctls()) {
qemu_event_reset(&kvm_in_ioctl_event);
if (in_kvm_ioctls()) {
qemu_event_wait(&kvm_in_ioctl_event);
}
}
where in_kvm_ioctls() returns true if any (vCPU or KVM) lockcnt has a
nonzero count.
Also please create a new header sysemu/accel-blocker.h and
accel/blocker.c or something like that with all the functions, because
this code can potentially be used by all KVM-like accelerators.
Paolo