Re: [PATCH 3/6] KVM: Support poll() on coalesced mmio buffer fds

Paul Durrant
2024-07-12T13:26:35Z

On 10/07/2024 10:52, Ilias Stamatis wrote:
> There is no direct way for userspace to be notified about coalesced MMIO
> writes when using KVM_REGISTER_COALESCED_MMIO. If the next MMIO exit is
> when the ring buffer has filled then a substantial (and unbounded)
> amount of time may have passed since the first coalesced MMIO.
>
> To improve this, make it possible for userspace to use poll() and
> select() on the fd returned by the KVM_CREATE_COALESCED_MMIO_BUFFER
> ioctl. This way a userspace VMM could have dedicated threads that deal
> with writes to specific MMIO zones.
>
> For example, a common use of MMIO, particularly in the realm of network
> devices, is as a doorbell. A write to a doorbell register will trigger
> the device to initiate a DMA transfer.
>
> When a network device is emulated by userspace a write to a doorbell
> register would typically result in an MMIO exit so that userspace can
> emulate the DMA transfer in a timely manner. No further processing can
> be done until userspace performs the necessary emulation and re-invokes
> KVM_RUN. Even if userspace makes use of another thread to emulate the
> DMA transfer such MMIO exits are disruptive to the vCPU and they may
> also be quite frequent if, for example, the vCPU is sending a sequence
> of short packets to the network device.
>
> By supporting poll() on coalesced buffer fds, userspace can have
> dedicated threads wait for new doorbell writes and avoid the performance
> hit of userspace exits on the main vCPU threads.
>
> Signed-off-by: Ilias Stamatis <ilstam@amazon.com>
> ---
> virt/kvm/coalesced_mmio.c | 20 ++++++++++++++++++++
> virt/kvm/coalesced_mmio.h | 1 +
> 2 files changed, 21 insertions(+)
>

Reviewed-by: Paul Durrant <paul@xen.org>