mirror of
https://github.com/Motorhead1991/qemu.git
synced 2025-08-03 15:53:54 -06:00
virtio: use defer_call() in virtio_irqfd_notify()
virtio-blk and virtio-scsi invoke virtio_irqfd_notify() to send Used Buffer Notifications from an IOThread. This involves an eventfd write(2) syscall. Calling this repeatedly when completing multiple I/O requests in a row is wasteful. Use the defer_call() API to batch together virtio_irqfd_notify() calls made during thread pool (aio=threads), Linux AIO (aio=native), and io_uring (aio=io_uring) completion processing. Behavior is unchanged for emulated devices that do not use defer_call_begin()/defer_call_end() since defer_call() immediately invokes the callback when called outside a defer_call_begin()/defer_call_end() region. fio rw=randread bs=4k iodepth=64 numjobs=8 IOPS increases by ~9% with a single IOThread and 8 vCPUs. iodepth=1 decreases by ~1% but this could be noise. Detailed performance data and configuration specifics are available here: https://gitlab.com/stefanha/virt-playbooks/-/tree/blk_io_plug-irqfd This duplicates the BH that virtio-blk uses for batching. The next commit will remove it. Reviewed-by: Eric Blake <eblake@redhat.com> Signed-off-by: Stefan Hajnoczi <stefanha@redhat.com> Message-ID: <20230913200045.1024233-4-stefanha@redhat.com> Reviewed-by: Michael S. Tsirkin <mst@redhat.com> Reviewed-by: Kevin Wolf <kwolf@redhat.com> Signed-off-by: Kevin Wolf <kwolf@redhat.com>
This commit is contained in:
parent
433fcea40c
commit
84d61e5f36
5 changed files with 28 additions and 1 deletions
|
@ -15,6 +15,7 @@
|
|||
#include "qapi/error.h"
|
||||
#include "qapi/qapi-commands-virtio.h"
|
||||
#include "trace.h"
|
||||
#include "qemu/defer-call.h"
|
||||
#include "qemu/error-report.h"
|
||||
#include "qemu/log.h"
|
||||
#include "qemu/main-loop.h"
|
||||
|
@ -2445,6 +2446,16 @@ static bool virtio_should_notify(VirtIODevice *vdev, VirtQueue *vq)
|
|||
}
|
||||
}
|
||||
|
||||
/* Batch irqs while inside a defer_call_begin()/defer_call_end() section */
|
||||
static void virtio_notify_irqfd_deferred_fn(void *opaque)
|
||||
{
|
||||
EventNotifier *notifier = opaque;
|
||||
VirtQueue *vq = container_of(notifier, VirtQueue, guest_notifier);
|
||||
|
||||
trace_virtio_notify_irqfd_deferred_fn(vq->vdev, vq);
|
||||
event_notifier_set(notifier);
|
||||
}
|
||||
|
||||
void virtio_notify_irqfd(VirtIODevice *vdev, VirtQueue *vq)
|
||||
{
|
||||
WITH_RCU_READ_LOCK_GUARD() {
|
||||
|
@ -2471,7 +2482,7 @@ void virtio_notify_irqfd(VirtIODevice *vdev, VirtQueue *vq)
|
|||
* to an atomic operation.
|
||||
*/
|
||||
virtio_set_isr(vq->vdev, 0x1);
|
||||
event_notifier_set(&vq->guest_notifier);
|
||||
defer_call(virtio_notify_irqfd_deferred_fn, &vq->guest_notifier);
|
||||
}
|
||||
|
||||
static void virtio_irq(VirtQueue *vq)
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue