From patchwork Sun Jul 22 19:33:44 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Zhang Chen X-Patchwork-Id: 10539403 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 E3DB4112B for ; Sun, 22 Jul 2018 19:51:18 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id C963E28420 for ; Sun, 22 Jul 2018 19:51:18 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id BA9FC28434; Sun, 22 Jul 2018 19:51:18 +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 67A9128420 for ; Sun, 22 Jul 2018 19:51:18 +0000 (UTC) Received: from localhost ([::1]:57299 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1fhKNx-0007Im-LK for patchwork-qemu-devel@patchwork.kernel.org; Sun, 22 Jul 2018 15:51:17 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:37875) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1fhK8i-0003BF-2J for qemu-devel@nongnu.org; Sun, 22 Jul 2018 15:35:32 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1fhK8e-0000w7-Sr for qemu-devel@nongnu.org; Sun, 22 Jul 2018 15:35:32 -0400 Received: from mail-pg1-x544.google.com ([2607:f8b0:4864:20::544]:42144) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1fhK8e-0000vj-Lg for qemu-devel@nongnu.org; Sun, 22 Jul 2018 15:35:28 -0400 Received: by mail-pg1-x544.google.com with SMTP id y4-v6so10650374pgp.9 for ; Sun, 22 Jul 2018 12:35:28 -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=fAD/xEZYoJ4wnieoIOg5YBGlf+BOX1RbOrN8PsBOmkY=; b=cqDA7XJkyeAF1caWjtFc6zvbs/SG8kKAhAQT3tMqD85YegwS8vFAN15oQ6h96wBGMK 9Teao68rnxsdiUfyD9zgSEgz7xLZiAegQM0Ydi68dmN7jNN6LW38IiD4vYaLnxGB1mxS q2HMfeYCTRmFbo+0lLrVeDAlNQ/v+fYX9fRwklkL4xJQ6F0WNrp0kvqo1vZ+gn0ORW6r WpWi+aiY3Q7U+FM7g4mZ1LS59qMVA5fKTC3QsMnU6rAvJCdOuJHmmLZbPoWJefWjHoae mwW3GCZMBNGkL+djiOVGYRJ5aCmSnK2qruaCGR4QyjdZ6Ncz2d32FfLMIpzDHLN42GvC Gy4w== 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=fAD/xEZYoJ4wnieoIOg5YBGlf+BOX1RbOrN8PsBOmkY=; b=XSy0UsOjBGJdcXjo9rpLKT2dKU00AkvnR2WSsnPzW2AhHVnxre+Lqr2DpyqX7v4LqL vXtaCJS/FlavCSWU/f4i/RwCnUbQtve7my1Vl021Sa0HJrnugmnJggQTeRTvJrcS2IZd VGsVKLMqjz5SyMT6Wd5qRoIWmKZJunL+Ik+LDm/7qDaUYrN0Gof9M4opWOLcR4CXi/V2 nEz93bOMOhes5nspYlnwiH8Sdk9DNteEr4J5erZbiBU3YEvvT3rJvgVRozTNYIBAR/pC NuOQLtjmVJvMe+s7tTJJgxL9W9aehAlw0Mn1iecp4WjXTOJ9oiXlg7j4bNfLq7TI6P0x H2Dw== X-Gm-Message-State: AOUpUlE67m/8BWlakalj0+DfQ3D/X59PKps6mFopEydBhNu23xSnnDS4 3b9KQEynTlO/Ffo8ouDO4u2fvSsW X-Google-Smtp-Source: AAOMgpc+jI/Z45wfWhALNuR2JEnMaTvQ6LLgVJUt/NEc4aRo4A5QnGim/lddtc+1ex3VE7YGMS8OfA== X-Received: by 2002:a62:ff0e:: with SMTP id b14-v6mr10385544pfn.135.1532288127454; Sun, 22 Jul 2018 12:35:27 -0700 (PDT) Received: from localhost.localdomain (155.150.229.35.bc.googleusercontent.com. [35.229.150.155]) by smtp.gmail.com with ESMTPSA id 87-v6sm14215353pfn.103.2018.07.22.12.35.22 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Sun, 22 Jul 2018 12:35:26 -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, 23 Jul 2018 03:33:44 +0800 Message-Id: <20180722193350.6028-15-zhangckid@gmail.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20180722193350.6028-1-zhangckid@gmail.com> References: <20180722193350.6028-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::544 Subject: [Qemu-devel] [PATCH V10 14/20] 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 , 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: zhanghailiang Reviewed-by: Dr. David Alan Gilbert --- migration/ram.c | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/migration/ram.c b/migration/ram.c index 4df85d69c1..32bc141a2e 100644 --- a/migration/ram.c +++ b/migration/ram.c @@ -3581,6 +3581,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; @@ -3601,10 +3602,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) { @@ -3841,6 +3844,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);