From patchwork Fri Mar 30 07:51:25 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Xiao Guangrong X-Patchwork-Id: 10317323 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 24A6860383 for ; Fri, 30 Mar 2018 07:55:36 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 1AFDF2A466 for ; Fri, 30 Mar 2018 07:55:36 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 0F8532A55F; Fri, 30 Mar 2018 07:55:36 +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 809152A466 for ; Fri, 30 Mar 2018 07:55:35 +0000 (UTC) Received: from localhost ([::1]:40909 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1f1oso-0005wx-MY for patchwork-qemu-devel@patchwork.kernel.org; Fri, 30 Mar 2018 03:55:34 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:56359) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1f1oot-00022F-Qh for qemu-devel@nongnu.org; Fri, 30 Mar 2018 03:51:32 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1f1oos-0007fS-Sj for qemu-devel@nongnu.org; Fri, 30 Mar 2018 03:51:31 -0400 Received: from mail-pg0-x242.google.com ([2607:f8b0:400e:c05::242]:40031) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1f1oos-0007fH-Md for qemu-devel@nongnu.org; Fri, 30 Mar 2018 03:51:30 -0400 Received: by mail-pg0-x242.google.com with SMTP id h3so605482pgq.7 for ; Fri, 30 Mar 2018 00:51:30 -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=/ZZQLnC9y24MXAI8Da5LGtqV6MHDiGUV+fTyxg3VeSw=; b=VAiKecXbrcjVXQ2ok143KSidvX2BvjimmqOX0TUWc9hZVzBFReONLXLPL7klX9UdVo zuNumchQTk5KlVmyTVd86dFTx/f4EpCmqxLl96ZAT4IjUQuf2XdU2oLs8+BB3BnavqIG tcJAhyI5nePqWB1SL0rTRp4n76UewSTtbizPc3RCrQjQgbPPQSdSrrPmkGOYuSKlYMOP NNbxZhjCbjSWnsCpOy5XAafeDCbRGkemwGEAMJ+GaVgUhzGM1bqzeUKjM6v8JJQkqhSI suQF8jGut7wkT6toOFhinajQTPZNG8D9ZESuzbjsjboYQfFumeupHsyKCit5WQDIGXPp tYaw== 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=/ZZQLnC9y24MXAI8Da5LGtqV6MHDiGUV+fTyxg3VeSw=; b=M47NX6MvePyhXcPpblZNsuYYj7Pz8z1kxQG7MvZcLi8Q6QdUU3y3TdlIlEduAH9+s5 IKAxRhq0aJGDzg5NfRVWbNP2pmVqLxTgYyYwMlul80DPaEOcvAfex1LL5K/+eSt8KC2i CLtgwbfYPYJHzTAfnqGZB31G3FamdJjsrhQOtDhIR7HWU3vqmSiFlxBg5M9bv0kHlaAP SMQACmO8g4ov0RjQDREPgIjqqCHy5rbf0g48320FcydLGEChx7b9CNbIX7rdF6TZRUHA +JYqGIrxdp3gPgx5Y1w+6MC25M/FrErKxAFtlbxkLzGlxNQvQglVfxv+emw3jGSVJAPX jyDQ== X-Gm-Message-State: AElRT7G4Cv4GjLoCtZ6plNz/hKJ30vxOfQMn6EyHqResgP79XYJpRq+u yeYTo+vcxKfmns55swa7piU= X-Google-Smtp-Source: AIpwx499QewCw8XsiB+XE4Ny9hS7XIFQeNNQg93yKU0F1VYeZ78Nl1FMDWOt2yEl8CdItfDSY8FLdg== X-Received: by 2002:a17:902:7003:: with SMTP id y3-v6mr1544141plk.212.1522396289858; Fri, 30 Mar 2018 00:51:29 -0700 (PDT) Received: from localhost.localdomain ([203.205.141.38]) by smtp.gmail.com with ESMTPSA id r75sm16557107pfb.98.2018.03.30.00.51.26 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Fri, 30 Mar 2018 00:51:29 -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: Fri, 30 Mar 2018 15:51:25 +0800 Message-Id: <20180330075128.26919-8-xiaoguangrong@tencent.com> X-Mailer: git-send-email 2.14.3 In-Reply-To: <20180330075128.26919-1-xiaoguangrong@tencent.com> References: <20180330075128.26919-1-xiaoguangrong@tencent.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 v3 07/10] 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: kvm@vger.kernel.org, Xiao Guangrong , qemu-devel@nongnu.org, peterx@redhat.com, dgilbert@redhat.com, wei.w.wang@intel.com, jiang.biao2@zte.com.cn 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 Reviewed-by: Peter Xu Signed-off-by: Xiao Guangrong --- migration/ram.c | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/migration/ram.c b/migration/ram.c index c3628b020e..e0caf7182b 100644 --- a/migration/ram.c +++ b/migration/ram.c @@ -1037,10 +1037,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) { @@ -1198,10 +1194,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 @@ -1489,6 +1481,14 @@ err: static int ram_save_target_page(RAMState *rs, PageSearchStatus *pss, bool last_stage) { + RAMBlock *block = pss->block; + ram_addr_t offset = pss->page << TARGET_PAGE_BITS; + int res; + + if (control_save_page(rs, block, offset, &res)) { + return res; + } + /* * If xbzrle is on, stop using the data compression after first * round of migration even if compression is enabled. In theory,