From patchwork Fri Jan 19 13:44:41 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Zhang Chen X-Patchwork-Id: 10175351 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 9A9BE60386 for ; Fri, 19 Jan 2018 13:57:11 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 8A0E4285D1 for ; Fri, 19 Jan 2018 13:57:11 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 7CCD62869D; Fri, 19 Jan 2018 13:57:11 +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=-6.8 required=2.0 tests=BAYES_00, DKIM_ADSP_CUSTOM_MED, DKIM_SIGNED, FREEMAIL_FROM, 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 DB9B6285D1 for ; Fri, 19 Jan 2018 13:57:10 +0000 (UTC) Received: from localhost ([::1]:50608 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ecXAM-0004DI-4t for patchwork-qemu-devel@patchwork.kernel.org; Fri, 19 Jan 2018 08:57:10 -0500 Received: from eggs.gnu.org ([2001:4830:134:3::10]:46834) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ecX0N-00042g-LO for qemu-devel@nongnu.org; Fri, 19 Jan 2018 08:46:52 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1ecX0M-0003T6-Px for qemu-devel@nongnu.org; Fri, 19 Jan 2018 08:46:51 -0500 Received: from mail-pg0-x243.google.com ([2607:f8b0:400e:c05::243]:38425) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1ecX0M-0003RV-LQ for qemu-devel@nongnu.org; Fri, 19 Jan 2018 08:46:50 -0500 Received: by mail-pg0-x243.google.com with SMTP id y27so1469857pgc.5 for ; Fri, 19 Jan 2018 05:46:50 -0800 (PST) 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=01E7Obz5WZ86oldwAeTnu2Mgcuou9cRrEtdosWSVXT8=; b=MQKD1QMGG1DqTD0oB8hck46Zn4/Jm9JLxLLE0jAgvQxqEyQTG33MgoS2Ke3gVC/1rI HyrMZdSB6WX+8ZOqH2YsRmxsdKOAjQKzWXx7MhNNivXOi1coLwyZXHimrEAUwx7npZMf JE6HO7oYh5O0JUIwpWmJxLsawfQVAwnBH3Gj8o8ijCDUNyiLdusP5vaJxAGnSU+ddBXt mKcxR6+KGyZ4ry3gA4UBMHTGg8hQW8ip4XbbfSWeGbvbjHkQeg0PV3hTsQYQK3pxe8lp AC9aOW/MGZGNDOiSmZD16NEv9aZX7//6aBzfqR91dxbNvg4Ejsw9aF72T6dWGd3k4sfJ pM9g== 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=01E7Obz5WZ86oldwAeTnu2Mgcuou9cRrEtdosWSVXT8=; b=lTI459GLZ//X2/Ho2hFs0ZPwjEqmndWsPZ1+tsAdupP/3wlGz8P/g3O5PEVRGf5apk dyibJ7XT8E5A7sXzM3KgrIuEPOq1X58sCev6hFv+ZZ4Le86WD5bDYJmmFWmhk8QL/jun ioKyR/ArkQhHVlSslzIRKbWq+oXzB0nAFOJ4rOCm6CjoxWG/7TpPvPH6ide4uCQy6RXp 7hrGrPPxc8p8LmTT8nQqpIsy+6HDryogMefKX+y301Ic1MgKKg3nNZXDlmRAAi8CbXJT 8av8KLvxU/lV1fXkYrqnge+lFjuROXwBhetMfvbEQcQj1rxUoNFBdz7tJrS/4QJIklMC T/8A== X-Gm-Message-State: AKwxytevkr90oPkUhKQwx5d06gjpGgWEv2xMFJEfqu3CjA0D7XoFhUJF eHrpVm4S6mIIa7chZXstK+1c+8FG X-Google-Smtp-Source: ACJfBovQq5RLusYkEhPHq6NkBgbgm0zbIuJcq15UuietVfkKfUZJ1EfBX/mB+7TjaKbx3qADwU1bAA== X-Received: by 10.98.102.4 with SMTP id a4mr30156498pfc.210.1516369609451; Fri, 19 Jan 2018 05:46:49 -0800 (PST) Received: from localhost.localdomain (120.236.201.35.bc.googleusercontent.com. [35.201.236.120]) by smtp.gmail.com with ESMTPSA id r88sm14251865pfb.17.2018.01.19.05.46.45 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Fri, 19 Jan 2018 05:46:48 -0800 (PST) From: Zhang Chen To: qemu-devel@nongnu.org Date: Fri, 19 Jan 2018 21:44:41 +0800 Message-Id: <1516369485-5374-13-git-send-email-zhangckid@gmail.com> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1516369485-5374-1-git-send-email-zhangckid@gmail.com> References: <1516369485-5374-1-git-send-email-zhangckid@gmail.com> X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 2607:f8b0:400e:c05::243 Subject: [Qemu-devel] [PATCH V4 12/16] 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 , Juan Quintela , Jason Wang , "Dr . David Alan Gilbert" , Markus Armbruster , 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 --- migration/ram.c | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/migration/ram.c b/migration/ram.c index faee086..7f9ce60 100644 --- a/migration/ram.c +++ b/migration/ram.c @@ -2680,6 +2680,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; @@ -2700,10 +2701,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) { @@ -2920,6 +2923,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);