From patchwork Tue Apr 16 02:44:44 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: 236829 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 8C6322C00EB for ; Tue, 16 Apr 2013 13:01:18 +1000 (EST) Received: from localhost ([::1]:42985 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1URvvm-0006aU-Eu for incoming@patchwork.ozlabs.org; Mon, 15 Apr 2013 22:47:38 -0400 Received: from eggs.gnu.org ([208.118.235.92]:58168) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1URvtR-0003NK-CJ for qemu-devel@nongnu.org; Mon, 15 Apr 2013 22:45:17 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1URvtM-0001JP-6z for qemu-devel@nongnu.org; Mon, 15 Apr 2013 22:45:13 -0400 Received: from e7.ny.us.ibm.com ([32.97.182.137]:35183) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1URvtM-0001J5-2d for qemu-devel@nongnu.org; Mon, 15 Apr 2013 22:45:08 -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, 15 Apr 2013 22:45:07 -0400 Received: from d01dlp02.pok.ibm.com (9.56.250.167) by e7.ny.us.ibm.com (192.168.1.107) with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted; Mon, 15 Apr 2013 22:45:05 -0400 Received: from d01relay04.pok.ibm.com (d01relay04.pok.ibm.com [9.56.227.236]) by d01dlp02.pok.ibm.com (Postfix) with ESMTP id B70666E8048 for ; Mon, 15 Apr 2013 22:45:01 -0400 (EDT) Received: from d01av03.pok.ibm.com (d01av03.pok.ibm.com [9.56.224.217]) by d01relay04.pok.ibm.com (8.13.8/8.13.8/NCO v10.0) with ESMTP id r3G2j457341538 for ; Mon, 15 Apr 2013 22:45:04 -0400 Received: from d01av03.pok.ibm.com (loopback [127.0.0.1]) by d01av03.pok.ibm.com (8.14.4/8.13.1/NCO v10.0 AVout) with ESMTP id r3G2j4t9014905 for ; Mon, 15 Apr 2013 23:45:04 -0300 Received: from mrhinesdev.klabtestbed.com (klinux.watson.ibm.com [9.2.208.21]) by d01av03.pok.ibm.com (8.14.4/8.13.1/NCO v10.0 AVin) with ESMTP id r3G2j15M014657; Mon, 15 Apr 2013 23:45:03 -0300 From: mrhines@linux.vnet.ibm.com To: qemu-devel@nongnu.org Date: Mon, 15 Apr 2013 22:44:44 -0400 Message-Id: <1366080286-9288-7-git-send-email-mrhines@linux.vnet.ibm.com> X-Mailer: git-send-email 1.7.10.4 In-Reply-To: <1366080286-9288-1-git-send-email-mrhines@linux.vnet.ibm.com> References: <1366080286-9288-1-git-send-email-mrhines@linux.vnet.ibm.com> X-TM-AS-MML: No X-Content-Scanned: Fidelis XPS MAILER x-cbid: 13041602-5806-0000-0000-000020BE2FA6 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, mst@redhat.com, owasserm@redhat.com, abali@us.ibm.com, mrhines@us.ibm.com, gokul@us.ibm.com, pbonzini@redhat.com Subject: [Qemu-devel] [PULL 6/8] rdma: send pc.ram 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 takes advantages of the previous patches: 1. use the new QEMUFileOps hook 'save_page' 2. call out to the right accessor methods to invoke the iteration hooks defined in QEMUFileOps Signed-off-by: Michael R. Hines --- arch_init.c | 35 +++++++++++++++++++++++++++++++++-- 1 file changed, 33 insertions(+), 2 deletions(-) diff --git a/arch_init.c b/arch_init.c index e272852..8d3f8a5 100644 --- a/arch_init.c +++ b/arch_init.c @@ -115,6 +115,7 @@ const uint32_t arch_type = QEMU_ARCH; #define RAM_SAVE_FLAG_EOS 0x10 #define RAM_SAVE_FLAG_CONTINUE 0x20 #define RAM_SAVE_FLAG_XBZRLE 0x40 +/* 0x80 is reserved in migration.h start with 0x100 next */ static struct defconfig_file { @@ -454,8 +455,15 @@ static int ram_save_block(QEMUFile *f, bool last_stage) p = memory_region_get_ram_ptr(mr) + offset; /* In doubt sent page as normal */ - bytes_sent = -1; - if (is_zero_page(p)) { + bytes_sent = ram_control_save_page(f, block->offset, + offset, TARGET_PAGE_SIZE); + if (bytes_sent >= 0) { + if (bytes_sent) { + acct_info.norm_pages++; + } else { + acct_info.dup_pages++; + } + } else if (is_zero_page(p)) { acct_info.dup_pages++; if (!ram_bulk_stage) { bytes_sent = save_block_hdr(f, block, offset, cont, @@ -598,6 +606,15 @@ static int ram_save_setup(QEMUFile *f, void *opaque) } qemu_mutex_unlock_ramlist(); + + /* + * Please leave in place. These calls generate reserved messages in + * the RDMA protocol in order to pre-register RDMA memory in the + * future to before the bulk round begins. + */ + ram_control_before_iterate(f, RAM_CONTROL_SETUP); + ram_control_after_iterate(f, RAM_CONTROL_SETUP); + qemu_put_be64(f, RAM_SAVE_FLAG_EOS); return 0; @@ -616,6 +633,8 @@ static int ram_save_iterate(QEMUFile *f, void *opaque) reset_ram_globals(); } + ram_control_before_iterate(f, RAM_CONTROL_ROUND); + t0 = qemu_get_clock_ns(rt_clock); i = 0; while ((ret = qemu_file_rate_limit(f)) == 0) { @@ -646,6 +665,12 @@ static int ram_save_iterate(QEMUFile *f, void *opaque) qemu_mutex_unlock_ramlist(); + /* + * Must occur before EOS (or any QEMUFile operation) + * because of RDMA protocol. + */ + ram_control_after_iterate(f, RAM_CONTROL_ROUND); + if (ret < 0) { bytes_transferred += total_sent; return ret; @@ -663,6 +688,8 @@ static int ram_save_complete(QEMUFile *f, void *opaque) qemu_mutex_lock_ramlist(); migration_bitmap_sync(); + ram_control_before_iterate(f, RAM_CONTROL_FINISH); + /* try transferring iterative blocks of memory */ /* flush all remaining blocks regardless of rate limiting */ @@ -676,6 +703,8 @@ static int ram_save_complete(QEMUFile *f, void *opaque) } bytes_transferred += bytes_sent; } + + ram_control_after_iterate(f, RAM_CONTROL_FINISH); migration_end(); qemu_mutex_unlock_ramlist(); @@ -872,6 +901,8 @@ static int ram_load(QEMUFile *f, void *opaque, int version_id) ret = -EINVAL; goto done; } + } else if (flags & RAM_SAVE_FLAG_HOOK) { + ram_control_load_hook(f, RAM_CONTROL_HOOK); } error = qemu_file_get_error(f); if (error) {