From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([2001:4830:134:3::10]:44318) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1XCdUg-00030D-AO for qemu-devel@nongnu.org; Wed, 30 Jul 2014 19:41:19 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1XCdUa-0007XX-Kc for qemu-devel@nongnu.org; Wed, 30 Jul 2014 19:41:14 -0400 Received: from mail-wg0-x229.google.com ([2a00:1450:400c:c00::229]:57770) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1XCdUa-0007XT-9j for qemu-devel@nongnu.org; Wed, 30 Jul 2014 19:41:08 -0400 Received: by mail-wg0-f41.google.com with SMTP id z12so1969420wgg.24 for ; Wed, 30 Jul 2014 16:41:07 -0700 (PDT) Sender: Paolo Bonzini Message-ID: <53D9828F.9040208@redhat.com> Date: Thu, 31 Jul 2014 01:41:03 +0200 From: Paolo Bonzini MIME-Version: 1.0 References: <1406720388-18671-1-git-send-email-ming.lei@canonical.com> <1406720388-18671-10-git-send-email-ming.lei@canonical.com> <53D8FA3C.6080906@redhat.com> In-Reply-To: Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 7bit Subject: Re: [Qemu-devel] [PATCH 09/15] linux-aio: fix submit aio as a batch List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: Ming Lei Cc: Kevin Wolf , Peter Maydell , Fam Zheng , "Michael S. Tsirkin" , qemu-devel , Stefan Hajnoczi Il 30/07/2014 19:32, Ming Lei ha scritto: > On Wed, Jul 30, 2014 at 9:59 PM, Paolo Bonzini wrote: >> Il 30/07/2014 13:39, Ming Lei ha scritto: >>> In the enqueue path, we can't complete request, otherwise >>> "Co-routine re-entered recursively" may be caused, so this >>> patch fixes the issue with below ideas: >>> >>> - for -EAGAIN or partial completion, retry the submission by >>> an introduced event handler >>> - for part of completion, also update the io queue >>> - for other failure, return the failure if in enqueue path, >>> otherwise, abort all queued I/O >>> >>> Signed-off-by: Ming Lei >>> --- >>> block/linux-aio.c | 90 ++++++++++++++++++++++++++++++++++++++++------------- >>> 1 file changed, 68 insertions(+), 22 deletions(-) >>> >>> diff --git a/block/linux-aio.c b/block/linux-aio.c >>> index 7ac7e8c..5eb9c92 100644 >>> --- a/block/linux-aio.c >>> +++ b/block/linux-aio.c >>> @@ -51,6 +51,7 @@ struct qemu_laio_state { >>> >>> /* io queue for submit at batch */ >>> LaioQueue io_q; >>> + EventNotifier retry; /* handle -EAGAIN and partial completion */ >>> }; >>> >>> static inline ssize_t io_event_ret(struct io_event *ev) >>> @@ -154,45 +155,80 @@ static void ioq_init(LaioQueue *io_q) >>> io_q->plugged = 0; >>> } >>> >>> -static int ioq_submit(struct qemu_laio_state *s) >>> +static void abort_queue(struct qemu_laio_state *s) >>> +{ >>> + int i; >>> + for (i = 0; i < s->io_q.idx; i++) { >>> + struct qemu_laiocb *laiocb = container_of(s->io_q.iocbs[i], >>> + struct qemu_laiocb, >>> + iocb); >>> + laiocb->ret = -EIO; >>> + qemu_laio_process_completion(s, laiocb); >>> + } >>> +} >>> + >>> +static int ioq_submit(struct qemu_laio_state *s, bool enqueue) >>> { >>> int ret, i = 0; >>> int len = s->io_q.idx; >>> + int j = 0; >>> >>> - do { >>> - ret = io_submit(s->ctx, len, s->io_q.iocbs); >>> - } while (i++ < 3 && ret == -EAGAIN); >>> + if (!len) { >>> + return 0; >>> + } >>> >>> - /* empty io queue */ >>> - s->io_q.idx = 0; >>> + ret = io_submit(s->ctx, len, s->io_q.iocbs); >>> + if (ret == -EAGAIN) { >>> + event_notifier_set(&s->retry); >> >> Retrying immediately (and just doing a couple of system calls to waste >> time) is not an improvement. The right place to retry is in >> qemu_laio_completion_cb, after io_getevents has been called and >> presumably the queue depth has decreased. > > Good point. > >> >> If !s->io_q.plugged but io_submit fails you can call ioq_enqueue and it > > When will the queued I/O be submitted? That will introduce extra > complexity definitely. It will be submitted when qemu_laio_completion_cb is called. > It is a change for !s->io_q.plugged case, and it isn't good to do that in > this patch, IMO. I agree with you that this series is doing too many things at a single time. You can submit separate series for 1) no-coroutine fast path, 2) full queue, 3) multiqueue. If you do things properly you won't have a single conflict, since they affect respectively block.c, block/linux-aio.c and hw/block/. Paolo