kvm tools: Get multiple io events at a time
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.
Signed-off-by Asias He <[email protected]>
--- tools/kvm/disk/core.c | 11 ++++++----- 1 files changed, 6 insertions(+), 5 deletions(-)
tools/kvm/disk/core.c +6 -5
@@ -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, ¬ime) >0 ) - disk->disk_req_cb (event.data, event.res); + nr =io_getevents (disk->ctx,1 ,ARRAY_SIZE (event), event, ¬ime); +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
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.
Signed-off-by Asias He <[email protected]>
--- tools/kvm/disk/raw.c | 1 - 1 files changed, 0 insertions(+), 1 deletions(-)
tools/kvm/disk/raw.c +0 -1
@@ -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
PATCH 3/3 kvm tools: Drop write operation in ro_ops_nowrite
In reply to Asias HeIt is supposed to have no write ops in ro_ops_nowrite disk operation. However, there is one. Let's remove it.
Signed-off-by Asias He <[email protected]>
--- tools/kvm/disk/raw.c | 1 - 1 files changed, 0 insertions(+), 1 deletions(-)
tools/kvm/disk/raw.c +0 -1
@@ -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