From patchwork Tue Mar 27 09:10:39 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Xiao Guangrong X-Patchwork-Id: 10312583 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 6D03560212 for ; Wed, 28 Mar 2018 09:14:55 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 6439029D66 for ; Wed, 28 Mar 2018 09:14:55 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 5897229D72; Wed, 28 Mar 2018 09:14:55 +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.4 required=2.0 tests=BAYES_00, DATE_IN_PAST_24_48, 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 09FC729CDD for ; Wed, 28 Mar 2018 09:14:55 +0000 (UTC) Received: from localhost ([::1]:38171 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1f17AU-0004hN-7A for patchwork-qemu-devel@patchwork.kernel.org; Wed, 28 Mar 2018 05:14:54 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:56705) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1f176S-0000yn-OP for qemu-devel@nongnu.org; Wed, 28 Mar 2018 05:10:46 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1f176R-00057q-8Z for qemu-devel@nongnu.org; Wed, 28 Mar 2018 05:10:44 -0400 Received: from mail-pg0-x244.google.com ([2607:f8b0:400e:c05::244]:46097) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1f176R-00057d-3B for qemu-devel@nongnu.org; Wed, 28 Mar 2018 05:10:43 -0400 Received: by mail-pg0-x244.google.com with SMTP id t12so701897pgp.13 for ; Wed, 28 Mar 2018 02:10:43 -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=BowyGQOXuV8DY4UpAHOoLnlrcBFl68/F7Px7ZtSi3+A=; b=ZU6gUdfiHTnnn5dahmpe5CKuHTsbdy6K2KwDscYuIjHYchNvzORiRGk1wJuxtHmgi/ dz4fm8+hi5gbqr8miLSeuW+A+IYqOB06RfcgdMD9ntsVrt7t5ZuDcfkjWhVgRHlsEdeM t39G9/5HY5Y1KEk/ERqKvV4aCNvf006CtLEJ/3mh9kyCKH6fw3ujWkV4a1QEzRbM5Rpt IC6LJ5HbDt1N7q6gPNASli+lncXqnW+Odau5cuX7oFxCheQRuepAdmLvEIN96Cp2cy/x cEdFIGSs8x6FpZRE9+vt2FNjvJW1h+EWqv7lO4VIlesGRToRPsa4NxjbvIfVBbGvK46W H94A== 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=BowyGQOXuV8DY4UpAHOoLnlrcBFl68/F7Px7ZtSi3+A=; b=GsJ0wwf1IJqRumZplHAY0QB+w7QpvQn2mFQrivuCag8CNZ3HrcoT0U7n8EvMMXQu7/ 8Ytz2CcDVA5cemxFOM35CLdW9elHOs1qndtrCuWHqMGY6PIvslSNzKWAieuD/qGkOIdF TdUf5Yha/2R4LryMtLTnlJKt+1IbLZRrzFBaQ9PdNpfN2qwS6/DJz/3eod/KJu2eyN4/ x3HcbS46aAi5RFy1YpRZ5Z4syHIqqwHYiTWhR0//A1mvj6bzvz9BVMRJBU/C+iIj0okK AnvV/CZvqXM7FrJonmIsQGPyawoPC0tNthKpzMDJZkFjNHrTMwZWRyaMViSGkJfa8dH9 vh1Q== X-Gm-Message-State: AElRT7Hiiar4+QgvL400v5rx5wtainImBNbijrsrqtFE11s3QU33nZfe KWHt4yOdG5xLCcs9UPowVCc= X-Google-Smtp-Source: AIpwx4/u8OvAJ8cjQqNgXoptL0HnnJ2eK+MFFx5G65OCsVOrz9knDwVPX8/q5Y+G1h0MeCTQB7q4oQ== X-Received: by 10.101.82.12 with SMTP id o12mr1983638pgp.126.1522228242384; Wed, 28 Mar 2018 02:10:42 -0700 (PDT) Received: from localhost.localdomain ([203.205.141.38]) by smtp.gmail.com with ESMTPSA id q9sm5590648pgs.89.2018.03.28.02.10.39 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Wed, 28 Mar 2018 02:10:41 -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:39 +0800 Message-Id: <20180327091043.30220-7-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:c05::244 Subject: [Qemu-devel] [PATCH v2 06/10] migration: move some code ram_save_host_page 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 Move some code from ram_save_target_page() to ram_save_host_page() to make it be more readable for latter patches that dramatically clean ram_save_target_page() up Signed-off-by: Xiao Guangrong Reviewed-by: Peter Xu --- migration/ram.c | 43 +++++++++++++++++++------------------------ 1 file changed, 19 insertions(+), 24 deletions(-) diff --git a/migration/ram.c b/migration/ram.c index fc1fde7bb7..104d3d3e9f 100644 --- a/migration/ram.c +++ b/migration/ram.c @@ -1485,38 +1485,23 @@ err: * Returns the number of pages written * * @rs: current RAM state - * @ms: current migration state * @pss: data about the page we want to send * @last_stage: if we are at the completion stage */ static int ram_save_target_page(RAMState *rs, PageSearchStatus *pss, bool last_stage) { - int res = 0; - - /* Check the pages is dirty and if it is send it */ - if (migration_bitmap_clear_dirty(rs, pss->block, pss->page)) { - /* - * If xbzrle is on, stop using the data compression after first - * round of migration even if compression is enabled. In theory, - * xbzrle can do better than compression. - */ - if (migrate_use_compression() && - (rs->ram_bulk_stage || !migrate_use_xbzrle())) { - res = ram_save_compressed_page(rs, pss, last_stage); - } else { - res = ram_save_page(rs, pss, last_stage); - } - - if (res < 0) { - return res; - } - if (pss->block->unsentmap) { - clear_bit(pss->page, pss->block->unsentmap); - } + /* + * If xbzrle is on, stop using the data compression after first + * round of migration even if compression is enabled. In theory, + * xbzrle can do better than compression. + */ + if (migrate_use_compression() && + (rs->ram_bulk_stage || !migrate_use_xbzrle())) { + return ram_save_compressed_page(rs, pss, last_stage); } - return res; + return ram_save_page(rs, pss, last_stage); } /** @@ -1545,12 +1530,22 @@ static int ram_save_host_page(RAMState *rs, PageSearchStatus *pss, qemu_ram_pagesize(pss->block) >> TARGET_PAGE_BITS; do { + /* Check the pages is dirty and if it is send it */ + if (!migration_bitmap_clear_dirty(rs, pss->block, pss->page)) { + pss->page++; + continue; + } + tmppages = ram_save_target_page(rs, pss, last_stage); if (tmppages < 0) { return tmppages; } pages += tmppages; + if (pss->block->unsentmap) { + clear_bit(pss->page, pss->block->unsentmap); + } + pss->page++; } while ((pss->page & (pagesize_bits - 1)) && offset_in_ramblock(pss->block, pss->page << TARGET_PAGE_BITS));