This patch reduces the number of calls to io_getevents() by getting
multiple io events at a time instead of one in disk image thread.

Signed-off-by: Asias He <asias.he...@gmail.com>
---
 tools/kvm/disk/core.c |   11 ++++++-----
 1 files changed, 6 insertions(+), 5 deletions(-)

diff --git a/tools/kvm/disk/core.c b/tools/kvm/disk/core.c
index cc2a1f6..4915efd 100644
--- a/tools/kvm/disk/core.c
+++ b/tools/kvm/disk/core.c
@@ -13,14 +13,15 @@ int debug_iodelay;
 static void *disk_image__thread(void *param)
 {
        struct disk_image *disk = param;
+       struct io_event event[AIO_MAX];
+       struct timespec notime = {0};
+       int nr, i;
        u64 dummy;
 
        while (read(disk->evt, &dummy, sizeof(dummy)) > 0) {
-               struct io_event event;
-               struct timespec notime = {0};
-
-               while (io_getevents(disk->ctx, 1, 1, &event, &notime) > 0)
-                       disk->disk_req_cb(event.data, event.res);
+               nr = io_getevents(disk->ctx, 1, ARRAY_SIZE(event), event, 
&notime);
+               for (i = 0; i < nr; i++)
+                       disk->disk_req_cb(event[i].data, event[i].res);
        }
 
        return NULL;
-- 
1.7.7.3

--
To unsubscribe from this list: send the line "unsubscribe kvm" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html

Reply via email to