From patchwork Wed Jun 27 20:41:30 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Zhang Chen X-Patchwork-Id: 10492663 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 CB479601A0 for ; Wed, 27 Jun 2018 21:01:09 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id CE51A290B9 for ; Wed, 27 Jun 2018 21:01:09 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id C970A2A100; Wed, 27 Jun 2018 21:01:09 +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 5F6CF2A0F8 for ; Wed, 27 Jun 2018 21:01:09 +0000 (UTC) Received: from localhost ([::1]:33206 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1fYHYq-0001Ln-HN for patchwork-qemu-devel@patchwork.kernel.org; Wed, 27 Jun 2018 17:01:08 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:49896) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1fYHHK-0004Kc-S7 for qemu-devel@nongnu.org; Wed, 27 Jun 2018 16:43:03 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1fYHHK-0006km-1q for qemu-devel@nongnu.org; Wed, 27 Jun 2018 16:43:02 -0400 Received: from mail-pg0-x241.google.com ([2607:f8b0:400e:c05::241]:37538) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1fYHHJ-0006k3-Sh for qemu-devel@nongnu.org; Wed, 27 Jun 2018 16:43:02 -0400 Received: by mail-pg0-x241.google.com with SMTP id o11-v6so1427815pgv.4 for ; Wed, 27 Jun 2018 13:43:01 -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=WaxGjCXY9Ei05zOa9jv5htcGx2JnN5cSYbe3SQMjPPo=; b=my/xJkMOGmo2O1t792h4/qayC+ikzg/BqkVza1Vx9wY27HbXazdCwBOkR4yrLb+9Sd Tl1aBANqxjAU//UGAonCgxm/oobk2au0A12GZGJIxnUw9ofR3HB5YfO/au7a+RQJ8LpY hW3BHRdfBQDGW+8nrcJnI7lZxEPlCoI6iHMc5SDyzayt3VwrrmxzLHOKqdauUT4wrP0W CNuLKaX7Mg/tgkEa9hU43BTcm+z78HAjD5wGWgOyevpF/uZGIi21cRmDC0tjsH63uxUs UqpxBkcqhY4LCFDGk/gq8KozDOx+1mWgBXhuj5BhoZB3d2mkrRonuhlWokaG2u0FkGbx DM6A== 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=WaxGjCXY9Ei05zOa9jv5htcGx2JnN5cSYbe3SQMjPPo=; b=JfmkxcLqH1ksGReKazTXm/fTT5BZIfTzO0U2vK6sKQ5vevanDgyfkyJHOhoX/chqSM v79lcgS5PWC9KE3a7zt5+/t7K6vvC3dHN7YjN6nhqJtuGtEVbVsXrZSWtbXY4jtrZwv1 yYDxFWZf4P3ucu5fEPeS8Zs7oI5QOE91obuPdqkejkuS1nM/M7fYrghUErmVnlCM1a9S q3SpDiNf7kIM/jBM/POlK6Q90rLTK96lEU/RjwnhDXSdLtlQAaJZORc7pOzWVmlJh9gu pXivWI1H72uF6PgfIW4CWnfVucdi6xHSb9V6ypTK8JfO6euBH5W5LW8hcF0OLApwL6+h mCoQ== X-Gm-Message-State: APt69E0LZZR8PT1Wi9LtUk90BLAGGq+9mNmMfrlpRaa01Nv24ny83K2d HFTjgN9WwguXIgLkZtdcy+c+gg== X-Google-Smtp-Source: ADUXVKK0ru75GQUxhnHh2MbEKE21i195mgzBaihBLDVmwyPtJoFhVCrUZVdu0weIaWBJYBpTDXUZmQ== X-Received: by 2002:a65:60d2:: with SMTP id r18-v6mr6508371pgv.306.1530132180698; Wed, 27 Jun 2018 13:43:00 -0700 (PDT) Received: from localhost.localdomain (155.150.229.35.bc.googleusercontent.com. [35.229.150.155]) by smtp.gmail.com with ESMTPSA id c67-v6sm9690428pfj.173.2018.06.27.13.42.55 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Wed, 27 Jun 2018 13:42:59 -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: Thu, 28 Jun 2018 04:41:30 +0800 Message-Id: <20180627204136.4177-15-zhangckid@gmail.com> X-Mailer: git-send-email 2.17.0 In-Reply-To: <20180627204136.4177-1-zhangckid@gmail.com> References: <20180627204136.4177-1-zhangckid@gmail.com> X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 2607:f8b0:400e:c05::241 Subject: [Qemu-devel] [PATCH V9 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 4199d64ebd..fc0151cbfc 100644 --- a/migration/ram.c +++ b/migration/ram.c @@ -3125,6 +3125,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; @@ -3145,10 +3146,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) { @@ -3381,6 +3384,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);