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: 892042 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=pass (mailfrom) smtp.mailfrom=nongnu.org (client-ip=2001:4830:134:3::11; helo=lists.gnu.org; envelope-from=qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org; receiver=) Authentication-Results: ozlabs.org; dmarc=fail (p=none dis=none) header.from=gmail.com Authentication-Results: ozlabs.org; dkim=fail reason="signature verification failed" (2048-bit key; unprotected) header.d=gmail.com header.i=@gmail.com header.b="mglAyVAj"; dkim-atps=neutral Received: from lists.gnu.org (lists.gnu.org [IPv6:2001:4830:134:3::11]) (using TLSv1 with cipher AES256-SHA (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 40B2Qt1pWXz9s0m for ; Wed, 28 Mar 2018 20:20:04 +1100 (AEDT) Received: from localhost ([::1]:38193 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1f17FR-0008Fg-48 for incoming@patchwork.ozlabs.org; Wed, 28 Mar 2018 05:20:01 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:56740) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1f176Z-000132-7p for qemu-devel@nongnu.org; Wed, 28 Mar 2018 05:10:52 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1f176U-00059f-J0 for qemu-devel@nongnu.org; Wed, 28 Mar 2018 05:10:51 -0400 Received: from mail-pf0-x244.google.com ([2607:f8b0:400e:c00::244]:35815) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1f176U-00059J-D1 for qemu-devel@nongnu.org; Wed, 28 Mar 2018 05:10:46 -0400 Received: by mail-pf0-x244.google.com with SMTP id u86so740662pfd.2 for ; Wed, 28 Mar 2018 02:10:46 -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=AtGTnRTorjaaet0oPBELMCQ9LGiqB+kA7KtsTMBPNHMC7Mio1oFwd6sOrE0bw7Wa+6 cWvGi8JDBcTBqDGyYa75ivKwxZyRue+F3ZRKdkxmsHoeRLLgUvACLHNfxruk+2cW2Xqg WrfpT3GeNCMWKCSVQHu7sa7as8cwOlsh0IrmIqbFccJuM4yl5XTwmLRTBr23IpLw+CiD zRyvUCSYkdg/2rhNdK3Nea/miMcgRiuputt6YAC8O/t2Um8VQrMb2+/NZOleT2BXCFrI aPlYFBbEy+PihCtH3cvTggMBq/CoxutwiW5czEltV/PM5SMmZylqJ/9qJss9L5nN9jXX j0lw== X-Gm-Message-State: AElRT7GoCAWPqnbdKXPvVPovsftEQarsHC+Ux1H0YuWNqmujIhBWQa24 gSOPbmXlaZhVJU2G/ERz2Y4= 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 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> X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 2607:f8b0:400e:c00::244 Subject: [Qemu-devel] [PATCH v2 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+incoming=patchwork.ozlabs.org@nongnu.org Sender: "Qemu-devel" 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,