From patchwork Sat Aug 11 20:59:18 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Zhang Chen X-Patchwork-Id: 10563567 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 663351510 for ; Sat, 11 Aug 2018 21:11:48 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 58A10298D9 for ; Sat, 11 Aug 2018 21:11:48 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 4BC4629915; Sat, 11 Aug 2018 21:11:48 +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 BE2AE298D9 for ; Sat, 11 Aug 2018 21:11:47 +0000 (UTC) Received: from localhost ([::1]:33230 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1fobAo-0006x1-VE for patchwork-qemu-devel@patchwork.kernel.org; Sat, 11 Aug 2018 17:11:46 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:48265) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1fob0L-0005MI-6o for qemu-devel@nongnu.org; Sat, 11 Aug 2018 17:00:58 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1fob0I-0001XI-5w for qemu-devel@nongnu.org; Sat, 11 Aug 2018 17:00:57 -0400 Received: from mail-pg1-x543.google.com ([2607:f8b0:4864:20::543]:45671) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1fob0H-0001Wy-W1 for qemu-devel@nongnu.org; Sat, 11 Aug 2018 17:00:54 -0400 Received: by mail-pg1-x543.google.com with SMTP id f1-v6so5849141pgq.12 for ; Sat, 11 Aug 2018 14:00:53 -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=FQkHD0iF4ZCPUwLAsj1ShX86lwX7Htt016788pFu0iI=; b=PFxyjeqfK9uYnfvUVQuBhAshiTyQwFanwnQ5KtDX6VJYiaIEVUOhLuntYKBIzm9qzB Uh5KOdRwHv74j9OXmvobZNfnRlQ2pmaUzJOlgNs9Y1P27hz2nTaVWgNS24Xo4tHqanXf UDPOVqIYZFy4ldwrABj2kF6+bKgDlGj6tlhRBS4C9hx2ijdEonJ6y4AZ8qVKgRGABOob awjLF8EY5T8FrC9iB0QzxpQ1+y8WAlLUfBhDYlwhP2Gf1ZNRX3W07+JFCD+yqDhHbJUx 97Lw6d2cLm0zTRBfMQ5/jwrngC/jmwR6dPw7IqSM8lgL4zDI3IBxF47QTmsPwYjE0Nu5 5moA== 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=FQkHD0iF4ZCPUwLAsj1ShX86lwX7Htt016788pFu0iI=; b=Bh8CRWsGyveVO60SmhmyY5Gl6yvafv3iuU6YoL2Y2RVvgUWzGk7uKD3+lIlpvCECOS 8sTZM/PbuEX5XN7XNZ19/86YijCZBa4hT1MNtG9gg9m2apvB4GFdZvP750cb6Yx+SJKQ XTIrlc4Ti3H0bBL+XenMaXmyh9DHPkOw+SVDuwraloys5NJMK/yj9Or2kBlBEFUMGLOK 4Lw546jOk2GiHg3YnFW873kFn987yId8FtSky9aI3s2CSeradCX1XvrN+ns9NJaRE9IR ooYpbVOiou7CR8ICHy38fU6ebP9Bl3+aJmNo9P00fPWqoIcbHkZYS1Tj+4dc8HkaR+UO 6bcQ== X-Gm-Message-State: AOUpUlFoXbOuP4h6czPzfiYR7qyAM8oKc5L4uzJfAe8azJvYjXHhqinL tSaX8OfdX3b0keirQ33gwEjtR3sQ X-Google-Smtp-Source: AA+uWPwnUBdTBFvnVbDeJfKgUagCDS8rMdgTs0bJJzSeQjtXpy9owfLgoh0W/uHtoXhW/xl3qsucDg== X-Received: by 2002:a62:8d84:: with SMTP id p4-v6mr12796371pfk.251.1534021252661; Sat, 11 Aug 2018 14:00:52 -0700 (PDT) Received: from localhost.localdomain (155.150.229.35.bc.googleusercontent.com. [35.229.150.155]) by smtp.gmail.com with ESMTPSA id h24-v6sm23502641pfk.113.2018.08.11.14.00.47 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Sat, 11 Aug 2018 14:00:51 -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: Sun, 12 Aug 2018 04:59:18 +0800 Message-Id: <20180811205924.4113-15-zhangckid@gmail.com> X-Mailer: git-send-email 2.17.0 In-Reply-To: <20180811205924.4113-1-zhangckid@gmail.com> References: <20180811205924.4113-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::543 Subject: [Qemu-devel] [PATCH V11 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: 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 b4cbcf783f..734e944a21 100644 --- a/migration/ram.c +++ b/migration/ram.c @@ -3588,6 +3588,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; @@ -3609,6 +3610,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; @@ -3852,6 +3854,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);