From patchwork Tue Mar 27 09:10:40 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Xiao Guangrong X-Patchwork-Id: 10312567 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 5551E60212 for ; Wed, 28 Mar 2018 09:10:54 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 47E7829B23 for ; Wed, 28 Mar 2018 09:10:54 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 39A5329C01; Wed, 28 Mar 2018 09:10:54 +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=-5.7 required=2.0 tests=BAYES_00, DATE_IN_PAST_24_48, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,FREEMAIL_FROM,RCVD_IN_DNSWL_HI autolearn=ham version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id B550729B23 for ; Wed, 28 Mar 2018 09:10:53 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752125AbeC1JKv (ORCPT ); Wed, 28 Mar 2018 05:10:51 -0400 Received: from mail-pf0-f193.google.com ([209.85.192.193]:36261 "EHLO mail-pf0-f193.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752105AbeC1JKq (ORCPT ); Wed, 28 Mar 2018 05:10:46 -0400 Received: by mail-pf0-f193.google.com with SMTP id g14so742848pfh.3 for ; Wed, 28 Mar 2018 02:10:45 -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=a4yJQ70gbcmr1a7GEjaWfWJaZjMnfyFa6mdz4JKGZqA=; b=mglAyVAjsravC+VR+USAPRf3Jabk4fGPO3Opva7Cm2f/xRw/U0BecIh7ET7ajt5Wfd U5Y5Xr/5nkdCKC3PizrMpHIOXomEjgGMomq8K+DJ1hBYdiFaE3m5VKO5Nkl5T8Qlc7m2 q4w9odSfBMBEJ9Z/dDspcaZ0tWQ8tMKvUthx6Vx0Ir6EkuiUAAdgOtstkvmjtOqxW0Pq 2xOHN3OfJ12hR/V1k3HbCetKKlDwS2kGy+YrZX6FIoXyZWqU/YtZn8nz7jSGE6V0KYzp ysRQcaJeL6KLB3OCe8VQtNx1QaghZPakvSw9cRDAeolxkFnUzHpqsgmkNDzle3fi56ew ISGA== 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=a4yJQ70gbcmr1a7GEjaWfWJaZjMnfyFa6mdz4JKGZqA=; b=mo/QLQpP6p3h6QMtQdahB+SlZ6hCnBL7YNVvJKK3E0UmVI3K+zDZuDlni+qS0SOBav bALeK39Kd3h9i0BFmTPlmDLYvEVnwJCW3v1NRtXT3rbRWMNR7j8v/771hiyxOKLPxIIS jGHHZkmD/QT/sLQG6tiph3DZtjgdxeRPNuqw5Ma+Yk3KRWBqoRqdwANBtK+qx3nEImTf 5evlrwvnbPUtbOv8x/R07DVguKKVXy6TUte6J8jfActSsGNEux6+getRFmWC5Plz+bkd lW8sb15zsoIZz3Ylp/i9BYGbgQwDeLiE+771bdLoPSv1tYVrkamvsV4i/YTPuGmPBRgd mCMQ== X-Gm-Message-State: AElRT7EsG118GqnbkSP4JeqTej6g1TDA0M9TjmG/KDl9zNx8V/TfmuGN 8F9+2n8srptpiSTxG6I+lO8= X-Google-Smtp-Source: AIpwx48uGE6OcQ8KMF1K71QtRYYJhNpMjdmsVntrQAQcgdLI6TPfNs2jE2AVnLKAYV3VYfGfbsILAw== X-Received: by 10.101.101.133 with SMTP id u5mr1967153pgv.151.1522228245674; Wed, 28 Mar 2018 02:10:45 -0700 (PDT) Received: from localhost.localdomain ([203.205.141.38]) by smtp.gmail.com with ESMTPSA id q9sm5590648pgs.89.2018.03.28.02.10.42 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Wed, 28 Mar 2018 02:10:45 -0700 (PDT) From: guangrong.xiao@gmail.com X-Google-Original-From: xiaoguangrong@tencent.com To: pbonzini@redhat.com, mst@redhat.com, mtosatti@redhat.com Cc: qemu-devel@nongnu.org, kvm@vger.kernel.org, dgilbert@redhat.com, peterx@redhat.com, jiang.biao2@zte.com.cn, wei.w.wang@intel.com, Xiao Guangrong Subject: [PATCH v2 07/10] migration: move calling control_save_page to the common place Date: Tue, 27 Mar 2018 17:10:40 +0800 Message-Id: <20180327091043.30220-8-xiaoguangrong@tencent.com> X-Mailer: git-send-email 2.14.3 In-Reply-To: <20180327091043.30220-1-xiaoguangrong@tencent.com> References: <20180327091043.30220-1-xiaoguangrong@tencent.com> Sender: kvm-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: kvm@vger.kernel.org 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 104d3d3e9f..ce3ef4382d 100644 --- a/migration/ram.c +++ b/migration/ram.c @@ -1039,10 +1039,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) { @@ -1200,10 +1196,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 @@ -1491,6 +1483,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,