From: Paolo Bonzini <pbonzini@redhat.com>
To: Emanuele Giuseppe Esposito <eesposit@redhat.com>, qemu-devel@nongnu.org
Cc: "Eduardo Habkost" <eduardo@habkost.net>,
"Marcel Apfelbaum" <marcel.apfelbaum@gmail.com>,
"Philippe Mathieu-Daudé" <philmd@linaro.org>,
"Yanan Wang" <wangyanan55@huawei.com>,
kvm@vger.kernel.org, "David Hildenbrand" <david@redhat.com>
Subject: Re: [RFC PATCH 3/3] kvm: Atomic memslot updates
Date: Tue, 8 Nov 2022 17:25:36 +0100 [thread overview]
Message-ID: <8e3bd959-bf0b-9104-2ca2-b745c0d9ff48@redhat.com> (raw)
In-Reply-To: <20221104151454.136551-4-eesposit@redhat.com>
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
prev parent reply other threads:[~2022-11-08 16:26 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2022-11-04 15:14 [RFC PATCH 0/3] KVM: allow listener to stop all vcpus before Emanuele Giuseppe Esposito
2022-11-04 15:14 ` [RFC PATCH 1/3] KVM: keep track of running ioctls Emanuele Giuseppe Esposito
2022-11-04 15:14 ` [RFC PATCH 2/3] KVM: keep track of running vcpu ioctls Emanuele Giuseppe Esposito
2022-11-04 15:14 ` [RFC PATCH 3/3] kvm: Atomic memslot updates Emanuele Giuseppe Esposito
2022-11-08 16:25 ` Paolo Bonzini [this message]
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=8e3bd959-bf0b-9104-2ca2-b745c0d9ff48@redhat.com \
--to=pbonzini@redhat.com \
--cc=david@redhat.com \
--cc=eduardo@habkost.net \
--cc=eesposit@redhat.com \
--cc=kvm@vger.kernel.org \
--cc=marcel.apfelbaum@gmail.com \
--cc=philmd@linaro.org \
--cc=qemu-devel@nongnu.org \
--cc=wangyanan55@huawei.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
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).