qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
* [Qemu-devel] [PATCH] qemu_aio_poll optimize
@ 2008-09-12 10:12 Wei Kong
  2008-09-12 13:52 ` Anthony Liguori
  0 siblings, 1 reply; 2+ messages in thread
From: Wei Kong @ 2008-09-12 10:12 UTC (permalink / raw)
  To: qemu-devel; +Cc: Wei Kong, Kevin Wolf, Jim Fehlig

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.

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 <wkong@novell.com>
---

--- 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.  */

^ permalink raw reply	[flat|nested] 2+ messages in thread

* Re: [Qemu-devel] [PATCH] qemu_aio_poll optimize
  2008-09-12 10:12 [Qemu-devel] [PATCH] qemu_aio_poll optimize Wei Kong
@ 2008-09-12 13:52 ` Anthony Liguori
  0 siblings, 0 replies; 2+ messages in thread
From: Anthony Liguori @ 2008-09-12 13:52 UTC (permalink / raw)
  To: qemu-devel; +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 <wkong@novell.com>
> ---
>
> --- 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.  */
>
>
>   

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2008-09-12 13:53 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2008-09-12 10:12 [Qemu-devel] [PATCH] qemu_aio_poll optimize Wei Kong
2008-09-12 13:52 ` Anthony Liguori

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).