From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([2001:4830:134:3::10]:53812) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1c4WRI-0000Gh-Ex for qemu-devel@nongnu.org; Wed, 09 Nov 2016 12:13:33 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1c4WRH-0000ZI-BT for qemu-devel@nongnu.org; Wed, 09 Nov 2016 12:13:32 -0500 Received: from mx1.redhat.com ([209.132.183.28]:55438) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1c4WRH-0000Yy-6a for qemu-devel@nongnu.org; Wed, 09 Nov 2016 12:13:31 -0500 Received: from int-mx14.intmail.prod.int.phx2.redhat.com (int-mx14.intmail.prod.int.phx2.redhat.com [10.5.11.27]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 8B2AB800 for ; Wed, 9 Nov 2016 17:13:30 +0000 (UTC) From: Stefan Hajnoczi Date: Wed, 9 Nov 2016 17:13:22 +0000 Message-Id: <1478711602-12620-4-git-send-email-stefanha@redhat.com> In-Reply-To: <1478711602-12620-1-git-send-email-stefanha@redhat.com> References: <1478711602-12620-1-git-send-email-stefanha@redhat.com> Subject: [Qemu-devel] [RFC 3/3] linux-aio: poll ring for completions List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: qemu-devel@nongnu.org Cc: 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, 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