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: 893162 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="sRafEtKR"; 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 40CDNk3RZSz9s1r for ; Fri, 30 Mar 2018 18:52:22 +1100 (AEDT) Received: from localhost ([::1]:40873 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1f1opg-00023u-Al for incoming@patchwork.ozlabs.org; Fri, 30 Mar 2018 03:52:20 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:56346) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1f1oos-00020m-98 for qemu-devel@nongnu.org; Fri, 30 Mar 2018 03:51:31 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1f1oop-0007es-Of for qemu-devel@nongnu.org; Fri, 30 Mar 2018 03:51:30 -0400 Received: from mail-pf0-x242.google.com ([2607:f8b0:400e:c00::242]:45699) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1f1oop-0007eW-Iz for qemu-devel@nongnu.org; Fri, 30 Mar 2018 03:51:27 -0400 Received: by mail-pf0-x242.google.com with SMTP id l27so4977719pfk.12 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=PSw5yK1LyfCInzb6Ix53Hh+wnP3nAHz6teKGE2gK0uoaMh4MifgNwN7O52oTCmNV4Y iSYSfL4rf3XhAUXrdAQkOvFZCf+ZfmbHSs6cBvcHkf7n4efuy28gu5EZ3tgEh87/7Une Rn89W6+6SL6NKa7TqCAEqMqcbVWrHdMW9gK9QLJy4eeMZH8xEvb28CtM29rfDTbl7MME 6Q1DJPizE7VaYEOpfDRMfEPAXgFltqCNZwMeJjS6Ty9wC5leXWHZn+Gn46Z0GvcUW9ho 7fnzstnL6pxyQqP5Rx/P8Ctow9N9LGljcpJpyucyZo3C38VlIm7wULbYyeuvyaBtPzxb WZYA== X-Gm-Message-State: AElRT7EPkOv/aajikFUZ+mXcLG/truVAINK22q4L1Z9CSC/NvpcxPzk5 0sx9s/jiJIsvY35NdlWq7Ko= 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 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> X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 2607:f8b0:400e:c00::242 Subject: [Qemu-devel] [PATCH v3 06/10] migration: move some code to 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+incoming=patchwork.ozlabs.org@nongnu.org Sender: "Qemu-devel" 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));