From patchwork Fri Mar 30 07:51:28 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Xiao Guangrong X-Patchwork-Id: 10317353 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 4170260383 for ; Fri, 30 Mar 2018 07:59:53 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 3517D29757 for ; Fri, 30 Mar 2018 07:59:53 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 255062A559; Fri, 30 Mar 2018 07:59:53 +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=-6.8 required=2.0 tests=BAYES_00, 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 9E59829757 for ; Fri, 30 Mar 2018 07:59:52 +0000 (UTC) Received: from localhost ([::1]:41169 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1f1owx-0001Kv-U5 for patchwork-qemu-devel@patchwork.kernel.org; Fri, 30 Mar 2018 03:59:51 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:56426) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1f1op3-0002Bb-IW for qemu-devel@nongnu.org; Fri, 30 Mar 2018 03:51:42 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1f1op2-0007mQ-Nm for qemu-devel@nongnu.org; Fri, 30 Mar 2018 03:51:41 -0400 Received: from mail-pg0-x241.google.com ([2607:f8b0:400e:c05::241]:41910) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1f1op2-0007lT-H5 for qemu-devel@nongnu.org; Fri, 30 Mar 2018 03:51:40 -0400 Received: by mail-pg0-x241.google.com with SMTP id t10so4664569pgv.8 for ; Fri, 30 Mar 2018 00:51:40 -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=oy/IApCirRmzaHbTwpG1z5Fsc+1VQHF3Ps2Wiwo+R9A=; b=NN7GXWPAM90+aXEv4/t9cDf5vimyjTW2jIlurUHJako170j6nZnHE5QtkjUKYlnewy 9Cdh70rm6khBRaIoQll5Cc8a+S1uK3T2x6vIklOKOnZr9HAKzKidpRax/6rrM8fvSkQ3 nwb1FRY+6kTkCkgxntW972CNXTgPqLZqSds+KCf3kqGy6NFvvZXnltuMJM9lXsbDCcV2 zvd8TIkCkLpHmABsT7PDXSpBNOFwpNuaHmleJzd5HR/j2Hopn7b3KmfXlFxqlZzga00A 3nQ+GVwe5z2Q663MQh1oe6Ew4hN+F/e+uw3IDQDqge9ddfcoHED//w3rUGXIsLe3napW eppg== 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=oy/IApCirRmzaHbTwpG1z5Fsc+1VQHF3Ps2Wiwo+R9A=; b=iHDXX2QdZgcazoa8thmaaPcKbzeS9iM/QvtJz7mg7kGbrr4FJh9OPmPvKJtFVYgScq New6zGyDR4raEu/HjdHyXrpIMLY1I9o0TbXMI3i9oyzJ1IMFtn5q6f0DDrypFrI7MyWp S9qcsjunruNycZMIKsInoic/T1vAPR7DeP0naENVVKSIFX3gmySylp/LbnOVLN7g5tFg k0eIh/l8d+zsnCFuWFfsYiaUkb43kKsnB8YsRfynOnzbg5N/p1rpoQT6rLev4JSeaYVB oFMx0sBoYEmAyPS9JADEv4Ge1ofzQHJXWxw8QCODyo0WNfVm3g8V68tQZdaAu2jjPlhh /QjA== X-Gm-Message-State: AElRT7HD8l9b30cFd/aVMkkyYzlFgtEQ2HZ03nNk5JZ8FBxFmtcBQT/I 1gwbNgHPSxaatTeY4bvisbc= X-Google-Smtp-Source: AIpwx4/69JA39+KfAL7idvDwICh58VUyhgBgNIseTLxZGkSDeH5x1KhWSRV9tM1vfBhYVkWghaTL4A== X-Received: by 2002:a17:902:2943:: with SMTP id g61-v6mr12061088plb.238.1522396299595; Fri, 30 Mar 2018 00:51:39 -0700 (PDT) Received: from localhost.localdomain ([203.205.141.38]) by smtp.gmail.com with ESMTPSA id r75sm16557107pfb.98.2018.03.30.00.51.36 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Fri, 30 Mar 2018 00:51:39 -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:28 +0800 Message-Id: <20180330075128.26919-11-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:c05::241 Subject: [Qemu-devel] [PATCH v3 10/10] migration: remove ram_save_compressed_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 Now, we can reuse the path in ram_save_page() to post the page out as normal, then the only thing remained in ram_save_compressed_page() is compression that we can move it out to the caller Reviewed-by: Peter Xu Reviewed-by: Dr. David Alan Gilbert Signed-off-by: Xiao Guangrong --- migration/ram.c | 45 ++++++++------------------------------------- 1 file changed, 8 insertions(+), 37 deletions(-) diff --git a/migration/ram.c b/migration/ram.c index 2eb4c0bf49..912810c18e 100644 --- a/migration/ram.c +++ b/migration/ram.c @@ -1184,41 +1184,6 @@ static int compress_page_with_multi_thread(RAMState *rs, RAMBlock *block, return pages; } -/** - * ram_save_compressed_page: compress the given page and send it to the stream - * - * Returns the number of pages written. - * - * @rs: current RAM state - * @block: block that contains the page we want to send - * @offset: offset inside the block for the page - * @last_stage: if we are at the completion stage - */ -static int ram_save_compressed_page(RAMState *rs, PageSearchStatus *pss, - bool last_stage) -{ - int pages = -1; - uint8_t *p; - RAMBlock *block = pss->block; - ram_addr_t offset = pss->page << TARGET_PAGE_BITS; - - p = block->host + offset; - - if (block != rs->last_sent_block) { - /* - * Make sure the first page is sent out before other pages. - * - * we post it as normal page as compression will take much - * CPU resource. - */ - pages = save_normal_page(rs, block, offset, p, true); - } else { - pages = compress_page_with_multi_thread(rs, block, offset); - } - - return pages; -} - /** * find_dirty_block: find the next dirty page and update any state * associated with the search process. @@ -1518,8 +1483,14 @@ static int ram_save_target_page(RAMState *rs, PageSearchStatus *pss, return res; } - if (save_page_use_compression(rs)) { - return ram_save_compressed_page(rs, pss, last_stage); + /* + * Make sure the first page is sent out before other pages. + * + * we post it as normal page as compression will take much + * CPU resource. + */ + if (block == rs->last_sent_block && save_page_use_compression(rs)) { + res = compress_page_with_multi_thread(rs, block, offset); } return ram_save_page(rs, pss, last_stage);