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: 10312565 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 D5AE560325 for ; Wed, 28 Mar 2018 09:10:50 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id CA7CB29B23 for ; Wed, 28 Mar 2018 09:10:50 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id BF14F29C01; Wed, 28 Mar 2018 09:10:50 +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 688D429B23 for ; Wed, 28 Mar 2018 09:10:50 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751840AbeC1JKr (ORCPT ); Wed, 28 Mar 2018 05:10:47 -0400 Received: from mail-pg0-f68.google.com ([74.125.83.68]:38084 "EHLO mail-pg0-f68.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752120AbeC1JKm (ORCPT ); Wed, 28 Mar 2018 05:10:42 -0400 Received: by mail-pg0-f68.google.com with SMTP id a15so710317pgn.5 for ; Wed, 28 Mar 2018 02:10:42 -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=V98mkvvwQDlE+KxjqpTUu+C4e5RxevAx/noP80MtoFwwVqXsOS6P8Ex4tgdxZ6AgLT JAi+QbFh/1fDr0PNkyf+A4f30d6apTyE8fkaEnrVC5rwDhKxe4Bc9247JxKxILKnhyYh dhAE7ISuCG6/t5owW/FfZ9I1JOXVzkmoEI8Q28FIblf/NMIb13p3QhKpyBr1qMZ41P3J aAOnvmIwDcgk+5mPWtQuxOODZIK2alocFIrr0eZVANHsraOapSBuCvjbZYrxjtxsW3nL pSR1iQFIeud5LW9MiXPym7iTCH2JEz4gOU2YiUY8b+pXLM+gsWfSPy1kV6EuFCpvYUiQ jFJg== X-Gm-Message-State: AElRT7F9c/hlOeEjgHaK1IUNXMrWJs6d2bvQVA3C1h/IIZLbMPN2FQG4 cXzA9tW6AXzBCIbsMU8SrTg= 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 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 06/10] migration: move some code ram_save_host_page 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> 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 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));