[tip:tools/kvm] kvm tools: Get multiple io events at a time

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Commit-ID:  60650f953b2eb5aa46e126676e796a4e6e5259bf
Gitweb:     http://git.kernel.org/tip/60650f953b2eb5aa46e126676e796a4e6e5259bf
Author:     Asias He <asias.hejun@xxxxxxxxx>
AuthorDate: Tue, 29 Nov 2011 21:04:04 +0800
Committer:  Pekka Enberg <penberg@xxxxxxxxxx>
CommitDate: Tue, 29 Nov 2011 20:07:30 +0200

kvm tools: Get multiple io events at a time

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@xxxxxxxxx>
Signed-off-by: Pekka Enberg <penberg@xxxxxxxxxx>
---
 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;
--
To unsubscribe from this list: send the line "unsubscribe linux-tip-commits" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[Index of Archives]     [Linux Stable Commits]     [Linux Stable Kernel]     [Linux Kernel]     [Linux USB Devel]     [Linux Video &Media]     [Linux Audio Users]     [Yosemite News]     [Linux SCSI]

  Powered by Linux