From patchwork Thu Nov 18 02:32:51 2010 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Wen Congyang X-Patchwork-Id: 72031 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from lists.gnu.org (lists.gnu.org [199.232.76.165]) (using TLSv1 with cipher DHE-RSA-AES256-SHA (256/256 bits)) (Client did not present a certificate) by ozlabs.org (Postfix) with ESMTPS id 23A2EB7198 for ; Thu, 18 Nov 2010 13:33:48 +1100 (EST) Received: from localhost ([127.0.0.1]:52008 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1PIuJl-0005bz-Q5 for incoming@patchwork.ozlabs.org; Wed, 17 Nov 2010 21:33:45 -0500 Received: from [140.186.70.92] (port=35136 helo=eggs.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1PIuIT-00054i-6o for qemu-devel@nongnu.org; Wed, 17 Nov 2010 21:32:26 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1PIuIR-00006I-Nq for qemu-devel@nongnu.org; Wed, 17 Nov 2010 21:32:25 -0500 Received: from [222.73.24.84] (port=57802 helo=song.cn.fujitsu.com) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1PIuIR-0008Vp-9e for qemu-devel@nongnu.org; Wed, 17 Nov 2010 21:32:23 -0500 Received: from tang.cn.fujitsu.com (tang.cn.fujitsu.com [10.167.250.3]) by song.cn.fujitsu.com (Postfix) with ESMTP id 1FD67170080 for ; Thu, 18 Nov 2010 10:32:10 +0800 (CST) Received: from mailserver.fnst.cn.fujitus.com (tang.cn.fujitsu.com [127.0.0.1]) by tang.cn.fujitsu.com (8.14.3/8.13.1) with ESMTP id oAI2RhcE019027 for ; Thu, 18 Nov 2010 10:27:43 +0800 Received: from [10.167.225.226] ([10.167.225.226]) by mailserver.fnst.cn.fujitus.com (Lotus Domino Release 8.5.1FP4) with ESMTP id 2010111810323259-42208 ; Thu, 18 Nov 2010 10:32:32 +0800 Message-ID: <4CE49053.3000608@cn.fujitsu.com> Date: Thu, 18 Nov 2010 10:32:51 +0800 From: Wen Congyang User-Agent: Mozilla/5.0 (X11; U; Linux x86_64; en-US; rv:1.9.1.9) Gecko/20100413 Fedora/3.0.4-2.fc13 Thunderbird/3.0.4 MIME-Version: 1.0 To: qemu-devel X-MIMETrack: Itemize by SMTP Server on mailserver/fnst(Release 8.5.1FP4|July 25, 2010) at 2010-11-18 10:32:32, Serialize by Router on mailserver/fnst(Release 8.5.1FP4|July 25, 2010) at 2010-11-18 10:32:33, Serialize complete at 2010-11-18 10:32:33 X-detected-operating-system: by eggs.gnu.org: FreeBSD 6.x (1) Subject: [Qemu-devel] [PATCH] stop the iteration when too many pages is transferred X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: qemu-devel.nongnu.org List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Errors-To: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org When the total sent page size is larger than max_factor times of the size of guest OS's memory, stop the iteration. The default value of max_factor is 3. This is similar to XEN. Signed-off-by: Wen Congyang --- arch_init.c | 13 ++++++++++++- 1 files changed, 12 insertions(+), 1 deletions(-) diff --git a/arch_init.c b/arch_init.c index 4486925..67e90f8 100644 --- a/arch_init.c +++ b/arch_init.c @@ -212,6 +212,14 @@ uint64_t ram_bytes_total(void) return total; } +static uint64_t ram_blocks_total(void) +{ + return ram_bytes_total() / TARGET_PAGE_SIZE; +} + +static uint64_t blocks_transferred = 0; +static int max_factor = 3; + int ram_save_live(Monitor *mon, QEMUFile *f, int stage, void *opaque) { ram_addr_t addr; @@ -234,6 +242,7 @@ int ram_save_live(Monitor *mon, QEMUFile *f, int stage, void *opaque) bytes_transferred = 0; last_block = NULL; last_offset = 0; + blocks_transferred = 0; /* Make sure all dirty bits are set */ QLIST_FOREACH(block, &ram_list.blocks, next) { @@ -266,6 +275,7 @@ int ram_save_live(Monitor *mon, QEMUFile *f, int stage, void *opaque) bytes_sent = ram_save_block(f); bytes_transferred += bytes_sent; + blocks_transferred += !!bytes_sent; if (bytes_sent == 0) { /* no more blocks */ break; } @@ -295,7 +305,8 @@ int ram_save_live(Monitor *mon, QEMUFile *f, int stage, void *opaque) expected_time = ram_save_remaining() * TARGET_PAGE_SIZE / bwidth; - return (stage == 2) && (expected_time <= migrate_max_downtime()); + return (stage == 2) && ((expected_time <= migrate_max_downtime()) + || (blocks_transferred > ram_blocks_total() * max_factor)); } static inline void *host_from_stream_offset(QEMUFile *f,