From patchwork Sun Jun 3 05:05:42 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Zhang Chen X-Patchwork-Id: 10445127 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 3DD94603B4 for ; Sun, 3 Jun 2018 05:12:53 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 2C51128A0A for ; Sun, 3 Jun 2018 05:12:53 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 1EDC428AFB; Sun, 3 Jun 2018 05:12:53 +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 AACB228A0A for ; Sun, 3 Jun 2018 05:12:52 +0000 (UTC) Received: from localhost ([::1]:33656 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1fPLJx-00049O-Ul for patchwork-qemu-devel@patchwork.kernel.org; Sun, 03 Jun 2018 01:12:49 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:57912) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1fPLER-0000Or-26 for qemu-devel@nongnu.org; Sun, 03 Jun 2018 01:07:08 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1fPLEQ-0000xr-2J for qemu-devel@nongnu.org; Sun, 03 Jun 2018 01:07:07 -0400 Received: from mail-pg0-x242.google.com ([2607:f8b0:400e:c05::242]:33230) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1fPLEP-0000xG-Qb for qemu-devel@nongnu.org; Sun, 03 Jun 2018 01:07:06 -0400 Received: by mail-pg0-x242.google.com with SMTP id e11-v6so3796530pgq.0 for ; Sat, 02 Jun 2018 22:07:05 -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=FIEdOS4Qpk/MgP0vNCirmcAoGj2mB4cFvrpVJXmUrvY=; b=kGERQzHX+8DtAXscdefDY9H9ZdbyS166WXpkEZ9I9m+r6nH9kjxuy2Ry1S/pvYVJff LXjeXqjL+WYoAWk6Ydc/zdJuA52IGYPfDKNUNmT5YrosmpTmK9t2lt3BjcGTC0m9TbFu oJQtVoJcBz+acVjSiOT1hdTuHrUdUq5UMyS39oemhqM0hNMaQR0NkHYcO29bblIVkIIo 6vLdnGa8F+l/j9ZStxQdkdspOCnz61IFWd6u8zkMOyx/PjVzW/m80qMwMCTECZAMjjYu NE1Sr1oirdUPD6teekSqawQ06JC3IMxAkWh4sBUvseQlfF1M0NWFgYvrmeg8jdueXiLG DTMg== 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=FIEdOS4Qpk/MgP0vNCirmcAoGj2mB4cFvrpVJXmUrvY=; b=WcTnxuvFhGimLGL2OVlZTW2Eg3QuDTti3gUyWlnBnGiXmqdE6AlGK/YjBLDtMDHbxO UeESwAJ05s4H68c+Y5+aArh9Y7Zaoe39H7lTApIiSGtlLZIipix85aSbx3C1FOuMAsag P3/4FIdUY+I30EOx7pedF4KzIOyYOOsX7ggb8rgVdC9Mp2soNhSSGKWtAUzLPfsP3Jep 1m7PEPZq4XKTHPjp3JOGQoXQiUmd8k96OehVDCAMSiq69bnj8w2eoq1ySGNvf5hIrfHv AnjXNxCL/hFRwnRHQjArUOZVDXpUy1pGWKivDmSfxFLOFFR4XxfN5WfU7RM+3sFn2dNw IW+w== X-Gm-Message-State: ALKqPwfCgrhsAZweSkcC/XwPs6zPKNmFcYGTCq6EHBWrVTRQZ2qTh9cP NTZsIIDgci4sdBjhCGnaT+PunA== X-Google-Smtp-Source: ADUXVKJy+mK/8DTnIC6yNisfrdwxyOR2RUnvWO03p355lBIcZtnaNppD5XAF3oxpMxA1PpocFgt5xg== X-Received: by 2002:a63:7b07:: with SMTP id w7-v6mr12958521pgc.199.1528002424705; Sat, 02 Jun 2018 22:07:04 -0700 (PDT) Received: from localhost.localdomain (197.225.229.35.bc.googleusercontent.com. [35.229.225.197]) by smtp.gmail.com with ESMTPSA id 10-v6sm45841595pgb.40.2018.06.02.22.06.59 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Sat, 02 Jun 2018 22:07:03 -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, 3 Jun 2018 13:05:42 +0800 Message-Id: <20180603050546.6827-14-zhangckid@gmail.com> X-Mailer: git-send-email 2.17.0 In-Reply-To: <20180603050546.6827-1-zhangckid@gmail.com> References: <20180603050546.6827-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::242 Subject: [Qemu-devel] [PATCH V8 13/17] 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 927436bd12..e34a015785 100644 --- a/migration/ram.c +++ b/migration/ram.c @@ -3087,6 +3087,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; @@ -3107,10 +3108,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) { @@ -3343,6 +3346,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(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);