From patchwork Mon May 14 16:54:20 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Zhang Chen X-Patchwork-Id: 10398959 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id 64F8760216 for ; Mon, 14 May 2018 17:07:02 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 5534627D4A for ; Mon, 14 May 2018 17:07:02 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 4970E2834A; Mon, 14 May 2018 17:07:02 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-7.8 required=2.0 tests=BAYES_00, DKIM_ADSP_CUSTOM_MED, DKIM_SIGNED, FREEMAIL_FROM, MAILING_LIST_MULTI, RCVD_IN_DNSWL_HI, T_DKIM_INVALID autolearn=ham version=3.3.1 Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) (using TLSv1 with cipher AES256-SHA (256/256 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id A825E27D4A for ; Mon, 14 May 2018 17:07:01 +0000 (UTC) Received: from localhost ([::1]:47319 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1fIGw8-0001Vn-Tc for patchwork-qemu-devel@patchwork.kernel.org; Mon, 14 May 2018 13:07:00 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:33591) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1fIGlE-0008MB-ED for qemu-devel@nongnu.org; Mon, 14 May 2018 12:55:45 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1fIGlC-0005x3-Qi for qemu-devel@nongnu.org; Mon, 14 May 2018 12:55:44 -0400 Received: from mail-pf0-x244.google.com ([2607:f8b0:400e:c00::244]:40660) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1fIGlC-0005wP-K1 for qemu-devel@nongnu.org; Mon, 14 May 2018 12:55:42 -0400 Received: by mail-pf0-x244.google.com with SMTP id f189-v6so6306966pfa.7 for ; Mon, 14 May 2018 09:55:42 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=aX3sDwjfakqhtRP0Z49uFUz5sIyRodddMtGk3by/K9Y=; b=TKtcI3PKuvoSJkDXKDbpDjUUC47gLvuhVO16WZuHre5n4dm3XTHWPPD1m9zt9R+uzW fchrb4wcmtxOYgADjKVuif6Mpzjeet7MkhCngT2Jt/7lf8H/SRoF+bzM8SUwWStcA6mk DbjtbDKn5p2TfIIbasNN7oXP3JrJC2T8kbEgcZiTCf0mBSFzon6pPiq23fnZn1Lpnoo7 YvN6sPnIXb/VoKOP67ygRlNI797E4i2puma+0DPOUBIpkV7Y2c6cQ7N3dj5gt5hG/bV1 M5VKmG8DvQXuwF3B5TsXRbMAZAVAPUZIDoNNec0KT2Zsh2GVuq+kfw42IBE0R2d44TJr p1Tw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=aX3sDwjfakqhtRP0Z49uFUz5sIyRodddMtGk3by/K9Y=; b=tdGN+19jJlxTsznxd8EKyVI27sc+5BnP0V8T9v3WjG7F99XJMhltSegR5YLfBz2rM7 v6UyKwtheR3pa9x5qtmWF+mzmM8pcp+S0bERHlzx75Awq/O1Zl9k7NTm2BPbx0ueasHa InqyKIasAHehBDgLL2wxehF4fGIAlEKa600EB/bxMnrzWCqwaNgOERRlhcfMaH4Ht1zw A/096c0T3uUBmmPrP1laXSBoJxzPk5BSw5OjpdTIgs0WYbRQxo3Wgl8N5s/Q3WLjuYWu FkK926cWSrs78a9gE+pU/wuRqf9sxU6WBXEzMmRdgBEyXVUQZVV/sKme/bObXwJ2n5DG VQ0A== X-Gm-Message-State: ALKqPwcLRRoUfj5Ulit7sAFKomZWyc7IGA6SnxtWIdsAuBVUz+CZvulh XL5Hnrch2TfJF0lBdpPKuW3LKA== X-Google-Smtp-Source: AB8JxZpQyR0UNL7v7YFFoImwiJJ//uqqePh3taKMHH1zwETKiSUWwNd6vF4qgfJzeZqUBRRgL7PUPg== X-Received: by 2002:a63:6fc8:: with SMTP id k191-v6mr1107216pgc.153.1526316941277; Mon, 14 May 2018 09:55:41 -0700 (PDT) Received: from localhost.localdomain (109.227.199.104.bc.googleusercontent.com. [104.199.227.109]) by smtp.gmail.com with ESMTPSA id u69-v6sm631448pgb.42.2018.05.14.09.55.36 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Mon, 14 May 2018 09:55:40 -0700 (PDT) From: Zhang Chen To: qemu-devel@nongnu.org Date: Tue, 15 May 2018 00:54:20 +0800 Message-Id: <20180514165424.12884-14-zhangckid@gmail.com> X-Mailer: git-send-email 2.17.0 In-Reply-To: <20180514165424.12884-1-zhangckid@gmail.com> References: <20180514165424.12884-1-zhangckid@gmail.com> X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 2607:f8b0:400e:c00::244 Subject: [Qemu-devel] [PATCH V7 RESEND 13/17] COLO: flush host dirty ram from cache X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: zhanghailiang , Li Zhijian , Jason Wang , Markus Armbruster , "Dr . David Alan Gilbert" , Zhang Chen , Paolo Bonzini Errors-To: qemu-devel-bounces+patchwork-qemu-devel=patchwork.kernel.org@nongnu.org Sender: "Qemu-devel" X-Virus-Scanned: ClamAV using ClamSMTP From: zhanghailiang Don't need to flush all VM's ram from cache, only flush the dirty pages since last checkpoint Signed-off-by: Li Zhijian Signed-off-by: Zhang Chen Signed-off-by: zhanghailiang Reviewed-by: Dr. David Alan Gilbert --- migration/ram.c | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/migration/ram.c b/migration/ram.c index 4235a8f24d..21027c5b4d 100644 --- a/migration/ram.c +++ b/migration/ram.c @@ -2786,6 +2786,7 @@ int colo_init_ram_cache(void) } ram_state = g_new0(RAMState, 1); ram_state->migration_dirty_pages = 0; + memory_global_dirty_log_start(); return 0; @@ -2806,10 +2807,12 @@ void colo_release_ram_cache(void) { RAMBlock *block; + memory_global_dirty_log_stop(); QLIST_FOREACH_RCU(block, &ram_list.blocks, next) { g_free(block->bmap); block->bmap = NULL; } + rcu_read_lock(); QLIST_FOREACH_RCU(block, &ram_list.blocks, next) { if (block->colo_cache) { @@ -3042,6 +3045,15 @@ static void colo_flush_ram_cache(void) void *src_host; unsigned long offset = 0; + memory_global_dirty_log_sync(); + qemu_mutex_lock(&ram_state->bitmap_mutex); + rcu_read_lock(); + RAMBLOCK_FOREACH(block) { + migration_bitmap_sync_range(ram_state, block, 0, block->used_length); + } + rcu_read_unlock(); + qemu_mutex_unlock(&ram_state->bitmap_mutex); + trace_colo_flush_ram_cache_begin(ram_state->migration_dirty_pages); rcu_read_lock(); block = QLIST_FIRST_RCU(&ram_list.blocks);