]> git.karo-electronics.de Git - karo-tx-linux.git/commitdiff
kvm tools: Get multiple io events at a time
authorAsias He <asias.hejun@gmail.com>
Tue, 29 Nov 2011 13:04:04 +0000 (21:04 +0800)
committerPekka Enberg <penberg@kernel.org>
Tue, 29 Nov 2011 18:07:30 +0000 (20:07 +0200)
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.hejun@gmail.com>
Signed-off-by: Pekka Enberg <penberg@kernel.org>
tools/kvm/disk/core.c

index cc2a1f67a896f10423e5ded80a83496cd5fa3808..4915efdc190cd3133a3e9c6c9701f1b3713d00f3 100644 (file)
@@ -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;