From patchwork Tue Mar 13 07:57:36 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Xiao Guangrong X-Patchwork-Id: 10277887 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 11050602BD for ; Tue, 13 Mar 2018 08:03:57 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 0214F28BA3 for ; Tue, 13 Mar 2018 08:03:57 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id EAB5028E99; Tue, 13 Mar 2018 08:03:56 +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=unavailable 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 87C0E28BA3 for ; Tue, 13 Mar 2018 08:03:56 +0000 (UTC) Received: from localhost ([::1]:37465 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1eveuZ-0007qN-RR for patchwork-qemu-devel@patchwork.kernel.org; Tue, 13 Mar 2018 04:03:55 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:42989) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1eveoz-0002yi-Pa for qemu-devel@nongnu.org; Tue, 13 Mar 2018 03:58:12 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1eveoy-0007f5-Un for qemu-devel@nongnu.org; Tue, 13 Mar 2018 03:58:09 -0400 Received: from mail-pf0-x22d.google.com ([2607:f8b0:400e:c00::22d]:34464) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1eveoy-0007eP-Ou for qemu-devel@nongnu.org; Tue, 13 Mar 2018 03:58:08 -0400 Received: by mail-pf0-x22d.google.com with SMTP id j20so5540949pfi.1 for ; Tue, 13 Mar 2018 00:58:08 -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=+cgEGzYx+EI4jtofU/Be0YPAm0jsFU8XENuzH7MI8Bs=; b=Bq9FSyJKUackhWGsxDuLgsePvi+ywphA5WALwVytOYnLGE7LhoKt9jtu0XHw3bnuiS IjwNNg+Eg5qXTesgzZIj0oY0G3DlGq30t/jPDJxYKopzi3SMX/b2y4W7fURvyux9y/2e 19Nf75EqHCSWYryJPJbkB5hBSatwH283aVidJoyqAsWocfgma5gkNoyyTZtVjCezg5Sx JsgHkbNCZd2rDVRhKHPUQsQSNWwYYAGIG74efLXpOmJW5EgTb+u80Tkv0zRz6c2EDa6A aALMfKR9IYoPyrKNcLBU90Bs9SrHxkxnb0XbEuSF+k3vDqMmDbo312Oc/YIuQM8cwObm BQPQ== 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=+cgEGzYx+EI4jtofU/Be0YPAm0jsFU8XENuzH7MI8Bs=; b=FuhhMlNaE+V0yptS/QdRYxWwL+dpbXFAuNYoqNqX2IqzHEvWEbRPBo9/dvkXbhHXD6 CbFYxq7SAGzmmHrzCAFwc1RzS0jgpXkjIEIhW26rFoKdN92mejFRJ2/7EBYPHQb3tXbL AiuGE2BInD58j/ansnx9sHRLYm6SKECawhfH351GVluH4AAZuKXdNqTrJ5CENVgCgp1K YgLorO9dPCwW10Ck0NrQODvP5+eHnqerFcY0fMHOhWdywVkTvAVlgApGjCo2vu88uibP BfJAM1zmKV64JsWN6MRTePONVEtKJ6xJ77WayqwBwNFqrNWMlnG59wOT4WKoIc8+1+W9 TDdA== X-Gm-Message-State: AElRT7FayLARvMHrFFakAKWMM+b2L/EVKxxZpEW7aNs0W4jo9PmwmRqG l61IzNfTKUqttAQF90um1wA= X-Google-Smtp-Source: AG47ELud9LMLtGgZLWvFHvs5oV8fGRcNYCr3yeWXvSLUFHzwISVbcsWS3YbiNO9A+NeanTHo4C79qw== X-Received: by 10.99.111.130 with SMTP id k124mr9170164pgc.236.1520927887868; Tue, 13 Mar 2018 00:58:07 -0700 (PDT) Received: from localhost.localdomain ([203.205.141.35]) by smtp.gmail.com with ESMTPSA id x4sm16756537pgv.72.2018.03.13.00.58.05 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Tue, 13 Mar 2018 00:58:07 -0700 (PDT) From: guangrong.xiao@gmail.com X-Google-Original-From: xiaoguangrong@tencent.com To: pbonzini@redhat.com, mst@redhat.com, mtosatti@redhat.com Date: Tue, 13 Mar 2018 15:57:36 +0800 Message-Id: <20180313075739.11194-6-xiaoguangrong@tencent.com> X-Mailer: git-send-email 2.14.3 In-Reply-To: <20180313075739.11194-1-xiaoguangrong@tencent.com> References: <20180313075739.11194-1-xiaoguangrong@tencent.com> X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 2607:f8b0:400e:c00::22d Subject: [Qemu-devel] [PATCH 5/8] migration: move calling control_save_page to the common place 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: Xiao Guangrong , qemu-devel@nongnu.org, kvm@vger.kernel.org Errors-To: qemu-devel-bounces+patchwork-qemu-devel=patchwork.kernel.org@nongnu.org Sender: "Qemu-devel" X-Virus-Scanned: ClamAV using ClamSMTP From: Xiao Guangrong The function is called by both ram_save_page and ram_save_target_page, so move it to the common caller to cleanup the code Signed-off-by: Xiao Guangrong Reviewed-by: Peter Xu --- migration/ram.c | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/migration/ram.c b/migration/ram.c index e7b8b14c3c..839665d866 100644 --- a/migration/ram.c +++ b/migration/ram.c @@ -1020,10 +1020,6 @@ static int ram_save_page(RAMState *rs, PageSearchStatus *pss, bool last_stage) p = block->host + offset; trace_ram_save_page(block->idstr, (uint64_t)offset, p); - if (control_save_page(rs, block, offset, &pages)) { - return pages; - } - XBZRLE_cache_lock(); pages = save_zero_page(rs, block, offset); if (pages > 0) { @@ -1176,10 +1172,6 @@ static int ram_save_compressed_page(RAMState *rs, PageSearchStatus *pss, p = block->host + offset; - if (control_save_page(rs, block, offset, &pages)) { - return pages; - } - /* When starting the process of a new block, the first page of * the block should be sent out before other pages in the same * block, and all the pages in last block should have been sent @@ -1472,6 +1464,13 @@ static int ram_save_target_page(RAMState *rs, PageSearchStatus *pss, /* Check the pages is dirty and if it is send it */ if (migration_bitmap_clear_dirty(rs, pss->block, pss->page)) { + RAMBlock *block = pss->block; + ram_addr_t offset = pss->page << TARGET_PAGE_BITS; + + if (control_save_page(rs, block, offset, &res)) { + goto page_saved; + } + /* * If xbzrle is on, stop using the data compression after first * round of migration even if compression is enabled. In theory, @@ -1484,6 +1483,7 @@ static int ram_save_target_page(RAMState *rs, PageSearchStatus *pss, res = ram_save_page(rs, pss, last_stage); } +page_saved: if (res < 0) { return res; }