From patchwork Thu Jan 4 06:01:11 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Zhang Chen X-Patchwork-Id: 10143907 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 870786034B for ; Thu, 4 Jan 2018 06:13:03 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 7A9DA283FF for ; Thu, 4 Jan 2018 06:13:03 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 6F7C728417; Thu, 4 Jan 2018 06:13:03 +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 ECEAE28419 for ; Thu, 4 Jan 2018 06:13:02 +0000 (UTC) Received: from localhost ([::1]:47509 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1eWylx-00058t-U7 for patchwork-qemu-devel@patchwork.kernel.org; Thu, 04 Jan 2018 01:13:01 -0500 Received: from eggs.gnu.org ([2001:4830:134:3::10]:37071) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1eWybh-0003wX-BG for qemu-devel@nongnu.org; Thu, 04 Jan 2018 01:02:26 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1eWybg-0004OX-BJ for qemu-devel@nongnu.org; Thu, 04 Jan 2018 01:02:25 -0500 Received: from mail-pg0-x241.google.com ([2607:f8b0:400e:c05::241]:38755) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1eWybg-0004Nh-5I for qemu-devel@nongnu.org; Thu, 04 Jan 2018 01:02:24 -0500 Received: by mail-pg0-x241.google.com with SMTP id t67so340181pgc.5 for ; Wed, 03 Jan 2018 22:02:23 -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=wP8rHc4oFD+B8t44XYNoggnsjnE/CVGhsI5u5C2EMxU=; b=kD0SP7CvisLof87Dsy1E4KYni8mOsOV86lR4M/uJ4k4whL7olw2RGy5j6iSj9lhrj5 AKoJQOJ9PZL/NI5rghFfaPSurLpMgcnx2oT61G54L1XHS39w2Qy8d3ayuYzXe4ikOHWv nyJzIe/C4k7RPxHTJoF/S3mQMi+roijVSbZhhlPxjXB2zCRAl2CP/AAQxIkUB0ht2/Gy Kf55Hx8P5GLwVv/05v1QtSlMcmQIxQ97I77Lf1XuXhwppss9kY2/dDTyMvUIT6dCXIwp IaxPhuS0hAyt9qtlIRzxC5BxFkle5Xgvwni2hf7392xIparpNx7cuMobc2Yj35urhhy5 c2Mw== 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=wP8rHc4oFD+B8t44XYNoggnsjnE/CVGhsI5u5C2EMxU=; b=gkYqRFA3GXYMKM+fQahiMp1kex3Z4VPiw1XsZBqmE4K8SfjMZwgklYQLD0WStyBKgu wz+K/EA2ZXkNb0UBug/6uppYrfdciPvfJw54Bc6xAqgAjuh8ywR5dY5bd3JFNv5nC/fL Z0D77Mc+hKdzrBwGBFA2O9pJZGqK66gLfr0fzJhiB7ryZa234x9gY3LZIMokJOxzYUSK UxBDrff7B5tkJKmcqPVVQO2NKCMRrPWkw9aAIDGSbWnwnvQiM657OB+BaXJ2zEtJk7x/ P08wbDJHevwHuM2idC3yQvWJ6J4XSOw9r/3EGHRneDz0T++KU8dbEVLI+wDEYewlCATL 9qPw== X-Gm-Message-State: AKGB3mInR4L3OcrbwLUlIWZ71HkIW1QPYZdUnb3owOCEMWi75bakepzJ VsrLji9+GPM2K+Vx7w/a4KmyBboZ X-Google-Smtp-Source: ACJfBov3cUqY7snVN2Mpb6zMrdBdr54rQBV74z4mPipNHuBpplUWp+m8+ymzQFPSI7GmG1ddxX/J8w== X-Received: by 10.99.121.207 with SMTP id u198mr3198649pgc.32.1515045742857; Wed, 03 Jan 2018 22:02:22 -0800 (PST) Received: from localhost.localdomain (120.236.201.35.bc.googleusercontent.com. [35.201.236.120]) by smtp.gmail.com with ESMTPSA id w5sm6214775pfi.74.2018.01.03.22.02.19 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Wed, 03 Jan 2018 22:02:21 -0800 (PST) From: Zhang Chen To: qemu devel Date: Thu, 4 Jan 2018 14:01:11 +0800 Message-Id: <1515045675-6993-13-git-send-email-zhangckid@gmail.com> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1515045675-6993-1-git-send-email-zhangckid@gmail.com> References: <1515045675-6993-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::241 Subject: [Qemu-devel] [PATCH RESEND V3 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: Zhang Chen , zhanghailiang , Li Zhijian , Juan Quintela 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 Cc: Juan Quintela 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 23c67e0..0188712 100644 --- a/migration/ram.c +++ b/migration/ram.c @@ -2679,6 +2679,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; @@ -2699,10 +2700,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) { @@ -2919,6 +2922,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);