From patchwork Thu May 21 08:13:16 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Zhanghailiang X-Patchwork-Id: 474869 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from lists.gnu.org (lists.gnu.org [IPv6:2001:4830:134:3::11]) (using TLSv1 with cipher AES256-SHA (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 9E94814077C for ; Thu, 21 May 2015 18:23:34 +1000 (AEST) Received: from localhost ([::1]:55881 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1YvLlM-00005p-8O for incoming@patchwork.ozlabs.org; Thu, 21 May 2015 04:23:32 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:52551) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1YvLcy-0002dY-RB for qemu-devel@nongnu.org; Thu, 21 May 2015 04:14:53 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1YvLcv-0002mp-6x for qemu-devel@nongnu.org; Thu, 21 May 2015 04:14:52 -0400 Received: from szxga01-in.huawei.com ([58.251.152.64]:55349) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1YvLcu-0002mD-Dl for qemu-devel@nongnu.org; Thu, 21 May 2015 04:14:49 -0400 Received: from 172.24.2.119 (EHLO SZXEML429-HUB.china.huawei.com) ([172.24.2.119]) by szxrg01-dlp.huawei.com (MOS 4.3.7-GA FastPath queued) with ESMTP id COD57736; Thu, 21 May 2015 16:14:46 +0800 (CST) Received: from localhost (10.177.22.69) by SZXEML429-HUB.china.huawei.com (10.82.67.184) with Microsoft SMTP Server id 14.3.158.1; Thu, 21 May 2015 16:14:35 +0800 From: zhanghailiang To: Date: Thu, 21 May 2015 16:13:16 +0800 Message-ID: <1432196001-10352-25-git-send-email-zhang.zhanghailiang@huawei.com> X-Mailer: git-send-email 1.9.2.msysgit.0 In-Reply-To: <1432196001-10352-1-git-send-email-zhang.zhanghailiang@huawei.com> References: <1432196001-10352-1-git-send-email-zhang.zhanghailiang@huawei.com> MIME-Version: 1.0 X-Originating-IP: [10.177.22.69] X-CFilter-Loop: Reflected X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.4.x-2.6.x [generic] X-Received-From: 58.251.152.64 Cc: lizhijian@cn.fujitsu.com, quintela@redhat.com, yunhong.jiang@intel.com, eddie.dong@intel.com, peter.huangpeng@huawei.com, dgilbert@redhat.com, zhanghailiang , arei.gonglei@huawei.com, amit.shah@redhat.com, Yang Hongyang , david@gibson.dropbear.id.au Subject: [Qemu-devel] [PATCH COLO-Frame v5 24/29] COLO: Improve checkpoint efficiency by do additional periodic checkpoint 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 Besides normal checkpoint which according to the result of net packets comparing, We do additional checkpoint periodically, it will reduce the number of dirty pages when do one checkpoint, if we don't do checkpoint for a long time (This is a special case when the net packets is always consistent). Signed-off-by: zhanghailiang Signed-off-by: Yang Hongyang --- migration/colo.c | 29 +++++++++++++++++++++-------- 1 file changed, 21 insertions(+), 8 deletions(-) diff --git a/migration/colo.c b/migration/colo.c index a7cead9..195973a 100644 --- a/migration/colo.c +++ b/migration/colo.c @@ -10,6 +10,7 @@ * later. See the COPYING file in the top-level directory. */ +#include "qemu/timer.h" #include "sysemu/sysemu.h" #include "migration/migration-colo.h" #include "trace.h" @@ -24,6 +25,13 @@ */ #define CHECKPOINT_MIN_PERIOD 100 /* unit: ms */ +/* + * force checkpoint timer: unit ms + * this is large because COLO checkpoint will mostly depend on + * COLO compare module. + */ +#define CHECKPOINT_MAX_PEROID 10000 + enum { COLO_CHECPOINT_READY = 0x46, @@ -336,14 +344,7 @@ static void *colo_thread(void *opaque) proxy_checkpoint_req = colo_proxy_compare(); if (proxy_checkpoint_req < 0) { goto out; - } else if (!proxy_checkpoint_req) { - /* - * No checkpoint is needed, wait for 1ms and then - * check if we need checkpoint again - */ - g_usleep(1000); - continue; - } else { + } else if (proxy_checkpoint_req) { int64_t interval; current_time = qemu_clock_get_ms(QEMU_CLOCK_HOST); @@ -352,8 +353,20 @@ static void *colo_thread(void *opaque) /* Limit the min time between two checkpoint */ g_usleep((1000*(CHECKPOINT_MIN_PERIOD - interval))); } + goto do_checkpoint; + } + + /* + * No proxy checkpoint is request, wait for 100ms + * and then check if we need checkpoint again. + */ + current_time = qemu_clock_get_ms(QEMU_CLOCK_HOST); + if (current_time - checkpoint_time < CHECKPOINT_MAX_PEROID) { + g_usleep(100000); + continue; } +do_checkpoint: /* start a colo checkpoint */ if (colo_do_checkpoint_transaction(s, colo_control)) { goto out;