From patchwork Mon Sep 3 04:38:55 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Zhang Chen X-Patchwork-Id: 10585429 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 23F13174C for ; Mon, 3 Sep 2018 04:52:05 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 0D33129124 for ; Mon, 3 Sep 2018 04:52:05 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id F372729533; Mon, 3 Sep 2018 04:52:04 +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 8401829124 for ; Mon, 3 Sep 2018 04:52:04 +0000 (UTC) Received: from localhost ([::1]:43421 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1fwgqJ-0002za-61 for patchwork-qemu-devel@patchwork.kernel.org; Mon, 03 Sep 2018 00:52:03 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:56510) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1fwgga-0000kZ-OD for qemu-devel@nongnu.org; Mon, 03 Sep 2018 00:42:01 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1fwgga-0005v9-1Z for qemu-devel@nongnu.org; Mon, 03 Sep 2018 00:42:00 -0400 Received: from mail-pf1-x444.google.com ([2607:f8b0:4864:20::444]:39344) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1fwggZ-0005uF-R5 for qemu-devel@nongnu.org; Mon, 03 Sep 2018 00:41:59 -0400 Received: by mail-pf1-x444.google.com with SMTP id j8-v6so8108538pff.6 for ; Sun, 02 Sep 2018 21:41:59 -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=peHDRWSd9yuYJ9BNLfmqLKO/zt2uBcH7yOGqyg6XRrc=; b=qfudZ6zJuoPH6V2fdwlNEzEKMYkpYQS4vC0aAmz2xr2UzgvACZ2qFwn7iEFwH4fneb blOceGbYlgqXedg3My/RVBKuG5KJPKQ6GBG/3C+9VwPxPJ6mfhuxcPmsvy7l/Y0IgbvL CA8RFQ7VVnV71oiDJKmk+q91BGGQBwlIpuBMKgNd2nB4d4WM1h7RdWA/lOz3bpQChDeH uT3zgzsERP7Ar8ONY6Ar8/jdhwfSU6a32ZCwyPyruu9u0dAba9YGZF+54R9jd9djKHkw F338nKb87MLySjtyb3fhj8pAM8urHNJGMkQGPz0clZzApWNq3P9n10Flva66VkMM7zAG KwDA== 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=peHDRWSd9yuYJ9BNLfmqLKO/zt2uBcH7yOGqyg6XRrc=; b=sjJkPM3p818U5d8dBcUdVgcbfruv/+uKfNq0NrVRWErg3CgJZ+9hGKyNeSSClPWWUg bbLJlmA+s7U/ZOLrNCq0eC8zH8oRAALTG1yaH295bTIyEqKhdU407YOvtYx3ZfCg9asT v0tfh84CzxCrZ5EE16UN5ZBAJvrpwjn23oDaTaHyku53xWIZIiSASZLomKJBxQBVnB07 BUgoLPrz8Ze0+yF1ISEasELJpm3/bOyfTlnLeVw119TAbXLgGEvluWF9Vl3DSfWrfbyK xy8VirF0mDQpju6dKu8M3WrXq3GiRngkNuf0bNK9I/gjZSjCgFaCG+ycLg1mSwsyWx79 ZMWw== X-Gm-Message-State: APzg51BT/CvrkC9Mh2OHErg0AiGGKRBltdVhNgtamHXBplozKjU2kvjD eKqyDqU2v+Xftnt9YYy14kjtroMZ X-Google-Smtp-Source: ANB0VdaQep5H6irPAJ9PCD7K8+N1Dvly2gzy+i0LzfZrEqMnZrwyTjhiAVZz/wmwdqUyYNJQp2p2Lg== X-Received: by 2002:a62:d74e:: with SMTP id v14-v6mr24098957pfl.88.1535949718715; Sun, 02 Sep 2018 21:41:58 -0700 (PDT) Received: from localhost.localdomain (155.150.229.35.bc.googleusercontent.com. [35.229.150.155]) by smtp.gmail.com with ESMTPSA id g6-v6sm32738308pfb.11.2018.09.02.21.41.52 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Sun, 02 Sep 2018 21:41:57 -0700 (PDT) From: Zhang Chen To: qemu-devel@nongnu.org, Paolo Bonzini , Juan Quintela , "Dr . David Alan Gilbert" , Jason Wang , Eric Blake , Markus Armbruster Date: Mon, 3 Sep 2018 12:38:55 +0800 Message-Id: <20180903043900.28592-15-zhangckid@gmail.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20180903043900.28592-1-zhangckid@gmail.com> References: <20180903043900.28592-1-zhangckid@gmail.com> X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 2607:f8b0:4864:20::444 Subject: [Qemu-devel] [PATCH V12 14/19] 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: Zhang Chen , zhanghailiang , Li Zhijian , Zhang Chen 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: Zhang Chen Signed-off-by: zhanghailiang Reviewed-by: Dr. David Alan Gilbert --- migration/ram.c | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/migration/ram.c b/migration/ram.c index a478d85740..739458be5b 100644 --- a/migration/ram.c +++ b/migration/ram.c @@ -3665,6 +3665,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; @@ -3686,6 +3687,7 @@ void colo_release_ram_cache(void) { RAMBlock *block; + memory_global_dirty_log_stop(); RAMBLOCK_FOREACH_MIGRATABLE(block) { g_free(block->bmap); block->bmap = NULL; @@ -3936,6 +3938,13 @@ static void colo_flush_ram_cache(void) void *src_host; unsigned long offset = 0; + memory_global_dirty_log_sync(); + rcu_read_lock(); + RAMBLOCK_FOREACH_MIGRATABLE(block) { + migration_bitmap_sync_range(ram_state, block, 0, block->used_length); + } + rcu_read_unlock(); + trace_colo_flush_ram_cache_begin(ram_state->migration_dirty_pages); rcu_read_lock(); block = QLIST_FIRST_RCU(&ram_list.blocks);