From patchwork Thu Mar 26 05:29:18 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Zhanghailiang X-Patchwork-Id: 454866 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 1E653140083 for ; Thu, 26 Mar 2015 16:35:18 +1100 (AEDT) Received: from localhost ([::1]:42759 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Yb0Rn-00048I-W2 for incoming@patchwork.ozlabs.org; Thu, 26 Mar 2015 01:35:16 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:47086) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Yb0PG-0007u8-Fd for qemu-devel@nongnu.org; Thu, 26 Mar 2015 01:32:39 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1Yb0PF-0007Dy-Iw for qemu-devel@nongnu.org; Thu, 26 Mar 2015 01:32:38 -0400 Received: from szxga01-in.huawei.com ([58.251.152.64]:34535) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Yb0PE-0007Dk-Tm for qemu-devel@nongnu.org; Thu, 26 Mar 2015 01:32:37 -0400 Received: from 172.24.2.119 (EHLO szxeml431-hub.china.huawei.com) ([172.24.2.119]) by szxrg01-dlp.huawei.com (MOS 4.3.7-GA FastPath queued) with ESMTP id CLH92064; Thu, 26 Mar 2015 13:32:29 +0800 (CST) Received: from localhost (10.177.22.69) by szxeml431-hub.china.huawei.com (10.82.67.208) with Microsoft SMTP Server id 14.3.158.1; Thu, 26 Mar 2015 13:32:21 +0800 From: zhanghailiang To: Date: Thu, 26 Mar 2015 13:29:18 +0800 Message-ID: <1427347774-8960-13-git-send-email-zhang.zhanghailiang@huawei.com> X-Mailer: git-send-email 1.9.2.msysgit.0 In-Reply-To: <1427347774-8960-1-git-send-email-zhang.zhanghailiang@huawei.com> References: <1427347774-8960-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, david@gibson.dropbear.id.au Subject: [Qemu-devel] [RFC PATCH v4 12/28] arch_init: Start to trace dirty pages of SVM 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 we will use this dirty bitmap together with VM's cache RAM dirty bitmap to decide which page in cache should be flushed into VM's RAM. Signed-off-by: zhanghailiang --- arch_init.c | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/arch_init.c b/arch_init.c index e32d258..f3f2460 100644 --- a/arch_init.c +++ b/arch_init.c @@ -1277,6 +1277,7 @@ static int ram_load(QEMUFile *f, void *opaque, int version_id) void create_and_init_ram_cache(void) { RAMBlock *block; + int64_t ram_cache_pages = last_ram_offset() >> TARGET_PAGE_BITS; rcu_read_lock(); QLIST_FOREACH_RCU(block, &ram_list.blocks, next) { @@ -1286,6 +1287,14 @@ void create_and_init_ram_cache(void) rcu_read_unlock(); ram_cache_enable = true; + /* + * Start dirty log for slave VM, we will use this dirty bitmap together with + * VM's cache RAM dirty bitmap to decide which page in cache should be + * flushed into VM's RAM. + */ + migration_bitmap = bitmap_new(ram_cache_pages); + migration_dirty_pages = 0; + memory_global_dirty_log_start(); } void release_ram_cache(void) @@ -1294,6 +1303,12 @@ void release_ram_cache(void) ram_cache_enable = false; + if (migration_bitmap) { + memory_global_dirty_log_stop(); + g_free(migration_bitmap); + migration_bitmap = NULL; + } + rcu_read_lock(); QLIST_FOREACH_RCU(block, &ram_list.blocks, next) { g_free(block->host_cache);