From: Asias He Subject: [PATCH 1/3] kvm tools: Get multiple io events at a time Date: Tue, 29 Nov 2011 21:04:04 +0800 Message-ID: <1322571846-17232-1-git-send-email-asias.hejun@gmail.com> Cc: Sasha Levin , Cyrill Gorcunov , Ingo Molnar , kvm@vger.kernel.org, Asias He To: Pekka Enberg Return-path: Received: from mail-iy0-f174.google.com ([209.85.210.174]:37337 "EHLO mail-iy0-f174.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1754356Ab1K2NHK (ORCPT ); Tue, 29 Nov 2011 08:07:10 -0500 Received: by iage36 with SMTP id e36so10595182iag.19 for ; Tue, 29 Nov 2011 05:07:09 -0800 (PST) Sender: kvm-owner@vger.kernel.org List-ID: 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 --- 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, ¬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; -- 1.7.7.3