From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mailman by lists.gnu.org with tmda-scanned (Exim 4.43) id 1Ke95D-0002GT-Oh for qemu-devel@nongnu.org; Fri, 12 Sep 2008 09:53:11 -0400 Received: from exim by lists.gnu.org with spam-scanned (Exim 4.43) id 1Ke95C-0002G0-8m for qemu-devel@nongnu.org; Fri, 12 Sep 2008 09:53:11 -0400 Received: from [199.232.76.173] (port=47010 helo=monty-python.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1Ke95C-0002Fv-35 for qemu-devel@nongnu.org; Fri, 12 Sep 2008 09:53:10 -0400 Received: from mail-gx0-f19.google.com ([209.85.217.19]:59687) by monty-python.gnu.org with esmtp (Exim 4.60) (envelope-from ) id 1Ke95B-0002mC-QH for qemu-devel@nongnu.org; Fri, 12 Sep 2008 09:53:10 -0400 Received: by gxk12 with SMTP id 12so18813614gxk.10 for ; Fri, 12 Sep 2008 06:53:08 -0700 (PDT) Message-ID: <48CA7411.2020609@codemonkey.ws> Date: Fri, 12 Sep 2008 08:52:17 -0500 From: Anthony Liguori MIME-Version: 1.0 Subject: Re: [Qemu-devel] [PATCH] qemu_aio_poll optimize References: <48CACD2D0200006D0000249A@victor.provo.novell.com> In-Reply-To: <48CACD2D0200006D0000249A@victor.provo.novell.com> Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit Reply-To: qemu-devel@nongnu.org List-Id: qemu-devel.nongnu.org List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: qemu-devel@nongnu.org Cc: Wei Kong , Kevin Wolf , Jim Fehlig Wei Kong wrote: > qemu_aio_poll() exhaust 50% cpu utilization rate in whole qemu running, > due to it scan RawAIOCB chain list loop and loop, especially when > these RawAIOCB are still in EINPROGRESS at IO flood. > Have you tested this with the very latest QEMU SVN? The recent change (yesterday) makes it so that qemu_aio_poll is not called in every CPU iteration. Regards, Anthony Liguori > This tune will reduce 2.2% ~ 2.5% total cpu utilization rate, > qemu_aio_poll() will exhaust 5% cpu in whole qemu running > and a little increase the IO through. > > Signed-off-by: Wei Kong > --- > > --- a/block-raw-posix.c > +++ b/block-raw-posix.c > @@ -289,40 +289,36 @@ void qemu_aio_poll(void) > RawAIOCB *acb, **pacb; > int ret; > > + pacb = &first_aio; > for(;;) { > - pacb = &first_aio; > - for(;;) { > - acb = *pacb; > - if (!acb) > - goto the_end; > - ret = aio_error(&acb->aiocb); > - if (ret == ECANCELED) { > - /* remove the request */ > - *pacb = acb->next; > - qemu_aio_release(acb); > - } else if (ret != EINPROGRESS) { > - /* end of aio */ > - if (ret == 0) { > - ret = aio_return(&acb->aiocb); > - if (ret == acb->aiocb.aio_nbytes) > - ret = 0; > - else > - ret = -EINVAL; > - } else { > - ret = -ret; > - } > - /* remove the request */ > - *pacb = acb->next; > - /* call the callback */ > - acb->common.cb(acb->common.opaque, ret); > - qemu_aio_release(acb); > - break; > + acb = *pacb; > + if (!acb) > + break; > + ret = aio_error(&acb->aiocb); > + if (ret == EINPROGRESS) { > + break; > + } else if (ret != ECANCELED) { > + /* end of aio */ > + if (ret == 0) { > + ret = aio_return(&acb->aiocb); > + if (ret == acb->aiocb.aio_nbytes) > + ret = 0; > + else > + ret = -EINVAL; > } else { > - pacb = &acb->next; > + ret = -ret; > } > - } > + /* remove the request */ > + *pacb = acb->next; > + /* call the callback */ > + acb->common.cb(acb->common.opaque, ret); > + qemu_aio_release(acb); > + } else { > + /* remove the request */ > + *pacb = acb->next; > + qemu_aio_release(acb); > + } > } > - the_end: ; > } > > /* Wait for all IO requests to complete. */ > > >