From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([2001:4830:134:3::10]:38465) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1c9DzL-0001tC-4o for qemu-devel@nongnu.org; Tue, 22 Nov 2016 11:32:11 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1c9DzJ-0004Ee-El for qemu-devel@nongnu.org; Tue, 22 Nov 2016 11:32:07 -0500 Received: from mx1.redhat.com ([209.132.183.28]:50988) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1c9DzJ-0004EL-6S for qemu-devel@nongnu.org; Tue, 22 Nov 2016 11:32:05 -0500 From: Stefan Hajnoczi Date: Tue, 22 Nov 2016 16:31:43 +0000 Message-Id: <1479832306-26440-8-git-send-email-stefanha@redhat.com> In-Reply-To: <1479832306-26440-1-git-send-email-stefanha@redhat.com> References: <1479832306-26440-1-git-send-email-stefanha@redhat.com> Subject: [Qemu-devel] [PATCH v3 07/10] linux-aio: poll ring for completions List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: qemu-devel@nongnu.org Cc: borntraeger@de.ibm.com, Paolo Bonzini , Karl Rister , Fam Zheng , Stefan Hajnoczi 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 --- block/linux-aio.c | 17 ++++++++++++++++- 1 file changed, 16 insertions(+), 1 deletion(-) diff --git a/block/linux-aio.c b/block/linux-aio.c index 69c4ed5..03ab741 100644 --- a/block/linux-aio.c +++ b/block/linux-aio.c @@ -255,6 +255,20 @@ static void qemu_laio_completion_cb(EventNotifier *e) } } +static bool qemu_laio_poll_cb(void *opaque) +{ + EventNotifier *e = opaque; + LinuxAioState *s = container_of(e, LinuxAioState, e); + struct io_event *events; + + if (!io_getevents_peek(s->ctx, &events)) { + return false; + } + + qemu_laio_process_completions_and_submit(s); + return true; +} + static void laio_cancel(BlockAIOCB *blockacb) { struct qemu_laiocb *laiocb = (struct qemu_laiocb *)blockacb; @@ -448,7 +462,8 @@ 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_event_notifier(new_context, &s->e, false, - qemu_laio_completion_cb, NULL); + qemu_laio_completion_cb, + qemu_laio_poll_cb); } LinuxAioState *laio_init(void) -- 2.7.4