From patchwork Tue Apr 23 01:55:31 2013 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: mrhines@linux.vnet.ibm.com X-Patchwork-Id: 238712 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) (using TLSv1 with cipher AES256-SHA (256/256 bits)) (Client did not present a certificate) by ozlabs.org (Postfix) with ESMTPS id E3FC32C00A8 for ; Tue, 23 Apr 2013 11:57:59 +1000 (EST) Received: from localhost ([::1]:57946 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1UUSUY-0007b3-12 for incoming@patchwork.ozlabs.org; Mon, 22 Apr 2013 21:57:58 -0400 Received: from eggs.gnu.org ([208.118.235.92]:57472) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1UUSSW-0004nM-Ff for qemu-devel@nongnu.org; Mon, 22 Apr 2013 21:55:57 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1UUSST-0001Eb-Dk for qemu-devel@nongnu.org; Mon, 22 Apr 2013 21:55:52 -0400 Received: from e7.ny.us.ibm.com ([32.97.182.137]:38655) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1UUSST-0001EW-8f for qemu-devel@nongnu.org; Mon, 22 Apr 2013 21:55:49 -0400 Received: from /spool/local by e7.ny.us.ibm.com with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted for from ; Mon, 22 Apr 2013 21:55:48 -0400 Received: from d01dlp03.pok.ibm.com (9.56.250.168) by e7.ny.us.ibm.com (192.168.1.107) with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted; Mon, 22 Apr 2013 21:55:46 -0400 Received: from d01relay04.pok.ibm.com (d01relay04.pok.ibm.com [9.56.227.236]) by d01dlp03.pok.ibm.com (Postfix) with ESMTP id 0D80EC9001A for ; Mon, 22 Apr 2013 21:55:46 -0400 (EDT) Received: from d03av06.boulder.ibm.com (d03av06.boulder.ibm.com [9.17.195.245]) by d01relay04.pok.ibm.com (8.13.8/8.13.8/NCO v10.0) with ESMTP id r3N1tjGC223122 for ; Mon, 22 Apr 2013 21:55:46 -0400 Received: from d03av06.boulder.ibm.com (loopback [127.0.0.1]) by d03av06.boulder.ibm.com (8.14.4/8.13.1/NCO v10.0 AVout) with ESMTP id r3N1wbbO012802 for ; Mon, 22 Apr 2013 19:58:37 -0600 Received: from mrhinesdev.klabtestbed.com (klinux.watson.ibm.com [9.2.208.21]) by d03av06.boulder.ibm.com (8.14.4/8.13.1/NCO v10.0 AVin) with ESMTP id r3N1wWQA012600; Mon, 22 Apr 2013 19:58:36 -0600 From: mrhines@linux.vnet.ibm.com To: quintela@redhat.com Date: Mon, 22 Apr 2013 21:55:31 -0400 Message-Id: <1366682139-22122-5-git-send-email-mrhines@linux.vnet.ibm.com> X-Mailer: git-send-email 1.7.10.4 In-Reply-To: <1366682139-22122-1-git-send-email-mrhines@linux.vnet.ibm.com> References: <1366682139-22122-1-git-send-email-mrhines@linux.vnet.ibm.com> X-TM-AS-MML: No X-Content-Scanned: Fidelis XPS MAILER x-cbid: 13042301-5806-0000-0000-000020D4035A X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.4.x-2.6.x [generic] X-Received-From: 32.97.182.137 Cc: aliguori@us.ibm.com, qemu-devel@nongnu.org, owasserm@redhat.com, abali@us.ibm.com, mrhines@us.ibm.com, gokul@us.ibm.com, pbonzini@redhat.com Subject: [Qemu-devel] [PATCH v5 04/12] rdma: introduce qemu_get_max_size() X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Sender: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org From: "Michael R. Hines" This functions allows you to perform your own per-QEMUFileOps calculation for the value of 'max_size'. For RDMA, this calculation artificially limits migration throughput and needs to be done differently for high-throughput links. Signed-off-by: Michael R. Hines --- include/migration/qemu-file.h | 12 ++++++++++++ migration.c | 3 ++- savevm.c | 19 +++++++++++++++++++ 3 files changed, 33 insertions(+), 1 deletion(-) diff --git a/include/migration/qemu-file.h b/include/migration/qemu-file.h index 70eb9bd..1803aeb 100644 --- a/include/migration/qemu-file.h +++ b/include/migration/qemu-file.h @@ -57,12 +57,22 @@ typedef int (QEMUFileGetFD)(void *opaque); typedef ssize_t (QEMUFileWritevBufferFunc)(void *opaque, struct iovec *iov, int iovcnt, int64_t pos); +/* + * This function allows override of how to calculate max_size + * after each iteration. + */ +typedef size_t (QEMUFileMaxSizeFunc)(QEMUFile *f, void *opaque, + uint64_t transferred_bytes, + uint64_t time_spent, + uint64_t max_downtime); + typedef struct QEMUFileOps { QEMUFilePutBufferFunc *put_buffer; QEMUFileGetBufferFunc *get_buffer; QEMUFileCloseFunc *close; QEMUFileGetFD *get_fd; QEMUFileWritevBufferFunc *writev_buffer; + QEMUFileMaxSizeFunc *get_max_size; } QEMUFileOps; QEMUFile *qemu_fopen_ops(void *opaque, const QEMUFileOps *ops); @@ -81,6 +91,8 @@ void qemu_put_byte(QEMUFile *f, int v); */ void qemu_put_buffer_async(QEMUFile *f, const uint8_t *buf, int size); double qemu_get_mbps(void); +size_t qemu_get_max_size(QEMUFile *f, uint64_t transferred_bytes, + uint64_t time_spent, uint64_t max_downtime); static inline void qemu_put_ubyte(QEMUFile *f, unsigned int v) diff --git a/migration.c b/migration.c index e2d73c4..48b5174 100644 --- a/migration.c +++ b/migration.c @@ -545,7 +545,8 @@ static void *migration_thread(void *opaque) uint64_t transferred_bytes = qemu_ftell(s->file) - initial_bytes; uint64_t time_spent = current_time - initial_time - sleep_time; double bandwidth = transferred_bytes / time_spent; - max_size = bandwidth * migrate_max_downtime() / 1000000; + max_size = qemu_get_max_size(s->file, transferred_bytes, + time_spent, migrate_max_downtime()); DPRINTF("transferred %" PRIu64 " time_spent %" PRIu64 " bandwidth %g max_size %" PRId64 "\n", diff --git a/savevm.c b/savevm.c index 6fcad19..60776e5 100644 --- a/savevm.c +++ b/savevm.c @@ -647,6 +647,25 @@ int qemu_get_fd(QEMUFile *f) return -1; } +size_t qemu_get_max_size(QEMUFile *f, uint64_t transferred_bytes, + uint64_t time_spent, uint64_t max_downtime) +{ + if (time_spent) { + mbps = (((double) transferred_bytes * 8.0) / + ((double) time_spent / 1000.0)) / 1000.0 / 1000.0; + } else { + mbps = -1.0; + } + + if (f->ops->get_max_size) { + return f->ops->get_max_size(f, f->opaque, + transferred_bytes, time_spent, max_downtime); + } + + return ((double) (transferred_bytes / (double) time_spent)) * + (double) max_downtime / 1000000.0; +} + /** Closes the file * * Returns negative error value if any error happened on previous operations or