From patchwork Fri Mar 30 07:51:24 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Xiao Guangrong X-Patchwork-Id: 10317305 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 55AAA60383 for ; Fri, 30 Mar 2018 07:51:32 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 4A5652A17F for ; Fri, 30 Mar 2018 07:51:32 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 3F4232A55F; Fri, 30 Mar 2018 07:51:32 +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=-7.0 required=2.0 tests=BAYES_00,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 CB8962A17F for ; Fri, 30 Mar 2018 07:51:31 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752189AbeC3Hv2 (ORCPT ); Fri, 30 Mar 2018 03:51:28 -0400 Received: from mail-pf0-f194.google.com ([209.85.192.194]:34639 "EHLO mail-pf0-f194.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751241AbeC3Hv1 (ORCPT ); Fri, 30 Mar 2018 03:51:27 -0400 Received: by mail-pf0-f194.google.com with SMTP id q9so4991882pff.1 for ; Fri, 30 Mar 2018 00:51:27 -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=DRP+RppCJq6ffQzj9IFqI19nyCxOb1EhZLgbovYRwHQ=; b=sRafEtKRBnU7ygVDRMqpxofr6AVPtGhF5A/+FUhZqYo1HqbN29oHkXcGM1q4oVerks dPbAGH06gSEsAA1O99Nf2jPpkykYW6gD9NP7b4ntQaduawvASk+qLHiCsfKq/AZsp+jW 4ZKd4RUWF2imX2Xfl1ggadGyWZclErtl5IMm0us0NwjyPzrkApvhGsyexb8BS4AS0CyP wjRMay7GIzAZ6CbeZ6pzOPKx61kaA2jv7BglpowHlfo4QDVfFLOzLx09bI/QHcHaQpMB OF7tFv7UkxNgJZzlBSBnyiXSYReNqIQMvYVwtqiSoIq1ac0kmPrvpeVafhJzof2IHwLc +djQ== 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=DRP+RppCJq6ffQzj9IFqI19nyCxOb1EhZLgbovYRwHQ=; b=aECx4D91yS5opgMqGUaom3Xxxk73DXdkcWRdziINn45sgnxopBuyP3sdL2U2d2I33v /WgfaZQSVYe/r6j37UFgPNtmT3mKmV3xTbjRLtsBpeHz+pN8J+xUdljcGyHrbXHXDFkQ drPm5O+EolnANa77vMYdwSHfZ8YvLoC1Q2XrSMmnk7CDxwK542Wd0SKvsnm4rkDXppwg ViVly1TGcp/eaTQ6WlMlE1DCfi6EfYsKsaMxUtPMZMRFRW9SEm3UzclVMWcAF7m5JVSw Hfns91yzxFkpsn56cqlo9i8bchXysj06V8iCzQRtTZ0dx8g9Dc7ZjGjcVMahb8ETOr2c oWCg== X-Gm-Message-State: AElRT7EVI9FGLCuL9IVqywXctrPzRDl4uZlMwbm26nNi4r4iNqObo16m ZdeXgU3W6ql6wCM6Jyugy1fWDQ== X-Google-Smtp-Source: AIpwx4+F9bEKcsHkq2aRSywhGCcGReH9p1IU4h7JnBMkOu7iZDItWv1HCoPUOsWxqxO264XU86Ikbw== X-Received: by 10.101.80.205 with SMTP id s13mr7601502pgp.285.1522396286672; Fri, 30 Mar 2018 00:51:26 -0700 (PDT) Received: from localhost.localdomain ([203.205.141.38]) by smtp.gmail.com with ESMTPSA id r75sm16557107pfb.98.2018.03.30.00.51.23 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Fri, 30 Mar 2018 00:51:26 -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 v3 06/10] migration: move some code to ram_save_host_page Date: Fri, 30 Mar 2018 15:51:24 +0800 Message-Id: <20180330075128.26919-7-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> 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 Reviewed-by: Peter Xu Signed-off-by: Xiao Guangrong --- migration/ram.c | 43 +++++++++++++++++++------------------------ 1 file changed, 19 insertions(+), 24 deletions(-) diff --git a/migration/ram.c b/migration/ram.c index 79c7958993..c3628b020e 100644 --- a/migration/ram.c +++ b/migration/ram.c @@ -1483,38 +1483,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); } /** @@ -1543,12 +1528,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));