qemu-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Qemu-devel] [RFC 3/3] linux-aio: poll ring for completions


From: Stefan Hajnoczi
Subject: [Qemu-devel] [RFC 3/3] linux-aio: poll ring for completions
Date: Wed, 9 Nov 2016 17:13:22 +0000

The Linux AIO userspace ABI includes a ring that is shared with the
kernel.  This allows userspace programs to process completions without
system calls.

Add an AioContext poll handler to check for completions in the ring.

Signed-off-by: Stefan Hajnoczi <address@hidden>
---
 block/linux-aio.c | 17 +++++++++++++++++
 1 file changed, 17 insertions(+)

diff --git a/block/linux-aio.c b/block/linux-aio.c
index 1685ec2..58446dc 100644
--- a/block/linux-aio.c
+++ b/block/linux-aio.c
@@ -255,6 +255,21 @@ static void qemu_laio_completion_cb(EventNotifier *e)
     }
 }
 
+static bool laio_poll(void *opaque)
+{
+    LinuxAioState *s = opaque;
+    struct io_event *events;
+
+    return io_getevents_peek(s->ctx, &events);
+}
+
+static void laio_poll_handler(void *opaque)
+{
+    LinuxAioState *s = opaque;
+
+    qemu_laio_process_completions_and_submit(s);
+}
+
 static void laio_cancel(BlockAIOCB *blockacb)
 {
     struct qemu_laiocb *laiocb = (struct qemu_laiocb *)blockacb;
@@ -440,6 +455,7 @@ BlockAIOCB *laio_submit(BlockDriverState *bs, LinuxAioState 
*s, int fd,
 void laio_detach_aio_context(LinuxAioState *s, AioContext *old_context)
 {
     aio_set_event_notifier(old_context, &s->e, false, NULL);
+    aio_set_poll_handler(old_context, laio_poll, NULL, s);
     qemu_bh_delete(s->completion_bh);
 }
 
@@ -447,6 +463,7 @@ void laio_attach_aio_context(LinuxAioState *s, AioContext 
*new_context)
 {
     s->aio_context = new_context;
     s->completion_bh = aio_bh_new(new_context, qemu_laio_completion_bh, s);
+    aio_set_poll_handler(new_context, laio_poll, laio_poll_handler, s);
     aio_set_event_notifier(new_context, &s->e, false,
                            qemu_laio_completion_cb);
 }
-- 
2.7.4




reply via email to

[Prev in Thread] Current Thread [Next in Thread]