qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
* [PATCH v3 0/3] KVM: allow listener to stop all vcpus before
@ 2022-11-11 15:47 Emanuele Giuseppe Esposito
  2022-11-11 15:47 ` [PATCH v3 1/3] accel: introduce accelerator blocker API Emanuele Giuseppe Esposito
                   ` (2 more replies)
  0 siblings, 3 replies; 13+ messages in thread
From: Emanuele Giuseppe Esposito @ 2022-11-11 15:47 UTC (permalink / raw)
  To: qemu-devel
  Cc: Paolo Bonzini, Richard Henderson, Eduardo Habkost,
	Marcel Apfelbaum, Philippe Mathieu-Daudé, Yanan Wang, kvm,
	Emanuele Giuseppe Esposito

QEMU needs to perform memslots operations like merging and splitting,
and each operation requires more than a single ioctl.
Therefore if a vcpu is concurrently reading the same memslots,
it could end up reading something that was temporarly deleted.
For example, merging two memslots into one would imply:
DELETE(m1)
DELETE(m2)
CREATE(m1+m2)

And a vcpu could attempt to read m2 right after it is deleted, but
before the new one is created.

This approach is 100% QEMU-based. No KVM API modification is involved,
but implies that QEMU must make sure no new ioctl is running and all
vcpus are stopped.

The logic and code are basically taken from David Hildenbrand
proposal given a while ago while reviewing a previous attempt where
I suggested to solve the above problem directly in KVM by extending
its API.

This is the original code:
https://github.com/davidhildenbrand/qemu/commit/86b1bf546a8d00908e33f7362b0b61e2be8dbb7a

I just split the patch in three smaller patches, and used a
QemuLockCnt instead of counter + mutex.

RHBZ: https://bugzilla.redhat.com/show_bug.cgi?id=1979276

Emanuele
---
v3:
* minor fixes on comments and docs
* improved accel_ioctl_inhibit_begin
* drop QSIMPLEQ_REMOVE from kvm_commit

v2:
* use QemuEvent instead of spinning in ioctl_inhibit_begin
* move the blocker API in a separate file and header, so that other accel can
  use it if they want.

David Hildenbrand (1):
  kvm: Atomic memslot updates

Emanuele Giuseppe Esposito (2):
  accel: introduce accelerator blocker API
  KVM: keep track of running ioctls

 accel/accel-blocker.c          | 154 +++++++++++++++++++++++++++++++++
 accel/kvm/kvm-all.c            | 108 ++++++++++++++++++++---
 accel/meson.build              |   2 +-
 hw/core/cpu-common.c           |   2 +
 include/hw/core/cpu.h          |   3 +
 include/sysemu/accel-blocker.h |  56 ++++++++++++
 include/sysemu/kvm_int.h       |   8 ++
 7 files changed, 321 insertions(+), 12 deletions(-)
 create mode 100644 accel/accel-blocker.c
 create mode 100644 include/sysemu/accel-blocker.h

-- 
2.31.1



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

end of thread, other threads:[~2022-12-02 14:33 UTC | newest]

Thread overview: 13+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2022-11-11 15:47 [PATCH v3 0/3] KVM: allow listener to stop all vcpus before Emanuele Giuseppe Esposito
2022-11-11 15:47 ` [PATCH v3 1/3] accel: introduce accelerator blocker API Emanuele Giuseppe Esposito
2022-11-18  7:32   ` Philippe Mathieu-Daudé
2022-11-18  7:35     ` Philippe Mathieu-Daudé
2022-12-02  6:56   ` Robert Hoo
2022-11-11 15:47 ` [PATCH v3 2/3] KVM: keep track of running ioctls Emanuele Giuseppe Esposito
2022-11-17 19:27   ` David Hildenbrand
2022-11-18  9:53     ` Emanuele Giuseppe Esposito
2022-12-02  6:54   ` Robert Hoo
2022-12-02 12:03     ` Emanuele Giuseppe Esposito
2022-12-02 13:32       ` Robert Hoo
2022-12-02 14:32         ` Emanuele Giuseppe Esposito
2022-11-11 15:47 ` [PATCH v3 3/3] kvm: Atomic memslot updates 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).