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: 10317313 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 7F1F860467 for ; Fri, 30 Mar 2018 07:51:43 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 749652A17F for ; Fri, 30 Mar 2018 07:51:43 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 6929A2A55F; Fri, 30 Mar 2018 07:51:43 +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 05C262A17F for ; Fri, 30 Mar 2018 07:51:43 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751981AbeC3Hvl (ORCPT ); Fri, 30 Mar 2018 03:51:41 -0400 Received: from mail-pg0-f68.google.com ([74.125.83.68]:40881 "EHLO mail-pg0-f68.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752016AbeC3Hvk (ORCPT ); Fri, 30 Mar 2018 03:51:40 -0400 Received: by mail-pg0-f68.google.com with SMTP id h3so605700pgq.7 for ; Fri, 30 Mar 2018 00:51:39 -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=SfFUbWrrf3hmSD48Z8zk+LSA+x6XOSYGNfn3isA8jDU8xcrO8zaM8AN96sgSXE2Amk QdEVwsR8lS+Iqzyl/yOyRS8JGMtlZ3pwyPvdPi6MbT0tkBkUzk5OvKNcctQg7sHWV5tj zVB1RKirt4rfX4+PvZi1zmSR7QFz2Bscg0hsUeKxVxZoUvtoJRsb+Fj6cdfhsYRUZYk/ K0GqnYeMxUXXQzsVKL0bwS0raiMKwQ7kp3CUAbhs7X6rD+i48YNeBZmfrFfopFOzm6Kc AuKIS/oMbA/8iTn1OSHUf5WMo+uy9AKFZQ4wsKPWD54yAU5CSbjOP9ZtYYo8QX+yBjMd 8mAA== X-Gm-Message-State: AElRT7EXoNBB3tp6t6qLmScOQRaluEuWFsqvxK6UgKuIDiDwvlTJWRP0 HC4oftxl6fpkSN/1IHGLtRQ= 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 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 10/10] migration: remove ram_save_compressed_page() 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> 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 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);