Skip to contentSkip to conversation

kvm tools: Get multiple io events at a time

PATCH New Asias He 1 participant 3 messages Nov 29, 2011 KVM

lore
Share & tools
lore

Asias He

author
#0 lore raw

PATCH 1/3 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.

---
 tools/kvm/disk/core.c |   11 ++++++-----
 1 files changed, 6 insertions(+), 5 deletions(-)
tools/kvm/disk/core.c +6 -5
index cc2a1f6..4915efd 100644
@@ -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;
Signature · 1 line
1.7.7.3
author
#1 lore raw

PATCH 2/3 kvm tools: Remove unnecessary assignment in disk/raw.c

ro_ops is never used after the assignment, so no need to do the assignment.

---
 tools/kvm/disk/raw.c |    1 -
 1 files changed, 0 insertions(+), 1 deletions(-)
tools/kvm/disk/raw.c +0 -1
index 9e5e86f..bdcd047 100644
@@ -118,7 +118,6 @@ struct disk_image *raw_image__probe(int fd, struct stat *st, bool readonly)
 
 		disk = disk_image__new(fd, st->st_size, &ro_ops, DISK_IMAGE_MMAP);
 		if (disk == NULL) {
-			ro_ops = raw_image_regular_ops;
 
 			disk = disk_image__new(fd, st->st_size, &ro_ops_nowrite, DISK_IMAGE_REGULAR);
 #ifdef CONFIG_HAS_AIO
Signature · 1 line
1.7.7.3
author
#2 lore raw

PATCH 3/3 kvm tools: Drop write operation in ro_ops_nowrite

In reply to Asias He

It is supposed to have no write ops in ro_ops_nowrite disk operation. However, there is one. Let's remove it.

---
 tools/kvm/disk/raw.c |    1 -
 1 files changed, 0 insertions(+), 1 deletions(-)
tools/kvm/disk/raw.c +0 -1
index bdcd047..caa023c 100644
@@ -102,7 +102,6 @@ struct disk_image_operations ro_ops = {
 
 struct disk_image_operations ro_ops_nowrite = {
 	.read_sector	= raw_image__read_sector,
-	.write_sector	= raw_image__write_sector,
 };
 
 struct disk_image *raw_image__probe(int fd, struct stat *st, bool readonly)
Signature · 1 line
1.7.7.3