public inbox for kvm@vger.kernel.org
 help / color / mirror / Atom feed
From: Ilias Stamatis <ilstam@amazon.com>
To: <kvm@vger.kernel.org>, <pbonzini@redhat.com>
Cc: <pdurrant@amazon.co.uk>, <dwmw@amazon.co.uk>,
	<Laurent.Vivier@bull.net>, <ghaskins@novell.com>,
	<avi@redhat.com>, <mst@redhat.com>, <levinsasha928@gmail.com>,
	<peng.hao2@zte.com.cn>, <nh-open-source@amazon.com>
Subject: [PATCH 0/6] KVM: Improve MMIO Coalescing API
Date: Wed, 10 Jul 2024 09:52:53 +0100	[thread overview]
Message-ID: <20240710085259.2125131-1-ilstam@amazon.com> (raw)

The current MMIO coalescing design has a few drawbacks which limit its
usefulness. Currently all coalesced MMIO zones use the same ring buffer.
That means that upon a userspace exit we have to handle potentially
unrelated MMIO writes synchronously. And a VM-wide lock needs to be
taken in the kernel when an MMIO exit occurs.

Additionally, there is no direct way for userspace to be notified about
coalesced MMIO writes. If the next MMIO exit to userspace is when the
ring buffer has filled then a substantial (and unbounded) amount of time
may have passed since the first coalesced MMIO.

This series adds new ioctls to KVM that allow for greater control by
making it possible to associate different MMIO zones with different ring
buffers. It also allows userspace to use poll() to check for coalesced
writes in order to avoid userspace exits in vCPU threads (see patch 3
for why this can be useful).

The idea of improving the API in this way originally came from Paul
Durrant (pdurrant@amazon.co.uk) but the implementation is mine.

The first patch in the series is a bug in the existing code that I
discovered while writing a selftest and can be merged independently.

Ilias Stamatis (6):
  KVM: Fix coalesced_mmio_has_room()
  KVM: Add KVM_CREATE_COALESCED_MMIO_BUFFER ioctl
  KVM: Support poll() on coalesced mmio buffer fds
  KVM: Add KVM_(UN)REGISTER_COALESCED_MMIO2 ioctls
  KVM: Documentation: Document v2 of coalesced MMIO API
  KVM: selftests: Add coalesced_mmio_test

 Documentation/virt/kvm/api.rst                |  91 +++++
 include/linux/kvm_host.h                      |   1 +
 include/uapi/linux/kvm.h                      |  18 +
 tools/testing/selftests/kvm/Makefile          |   1 +
 .../selftests/kvm/coalesced_mmio_test.c       | 310 ++++++++++++++++++
 virt/kvm/coalesced_mmio.c                     | 202 +++++++++++-
 virt/kvm/coalesced_mmio.h                     |  17 +-
 virt/kvm/kvm_main.c                           |  40 ++-
 8 files changed, 659 insertions(+), 21 deletions(-)
 create mode 100644 tools/testing/selftests/kvm/coalesced_mmio_test.c

-- 
2.34.1


             reply	other threads:[~2024-07-10  8:54 UTC|newest]

Thread overview: 17+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-07-10  8:52 Ilias Stamatis [this message]
2024-07-10  8:52 ` [PATCH 1/6] KVM: Fix coalesced_mmio_has_room() Ilias Stamatis
2024-07-12 13:13   ` Paul Durrant
2024-07-12 15:55   ` Roman Kagan
2024-07-12 19:03     ` Stamatis, Ilias
2024-07-15  9:30       ` Kagan, Roman
2024-07-10  8:52 ` [PATCH 2/6] KVM: Add KVM_CREATE_COALESCED_MMIO_BUFFER ioctl Ilias Stamatis
2024-07-12 13:22   ` Paul Durrant
2024-07-10  8:52 ` [PATCH 3/6] KVM: Support poll() on coalesced mmio buffer fds Ilias Stamatis
2024-07-12 13:26   ` Paul Durrant
2024-07-10  8:52 ` [PATCH 4/6] KVM: Add KVM_(UN)REGISTER_COALESCED_MMIO2 ioctls Ilias Stamatis
2024-07-13  6:19   ` Paul Durrant
2024-07-13 14:15   ` kernel test robot
2024-07-13 20:48   ` kernel test robot
2024-07-10  8:52 ` [PATCH 5/6] KVM: Documentation: Document v2 of coalesced MMIO API Ilias Stamatis
2024-07-13  6:19   ` Paul Durrant
2024-07-10  8:52 ` [PATCH 6/6] KVM: selftests: Add coalesced_mmio_test Ilias Stamatis

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=20240710085259.2125131-1-ilstam@amazon.com \
    --to=ilstam@amazon.com \
    --cc=Laurent.Vivier@bull.net \
    --cc=avi@redhat.com \
    --cc=dwmw@amazon.co.uk \
    --cc=ghaskins@novell.com \
    --cc=kvm@vger.kernel.org \
    --cc=levinsasha928@gmail.com \
    --cc=mst@redhat.com \
    --cc=nh-open-source@amazon.com \
    --cc=pbonzini@redhat.com \
    --cc=pdurrant@amazon.co.uk \
    --cc=peng.hao2@zte.com.cn \
    /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