From patchwork Tue Mar 13 07:57: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: 10277875 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 903BA602BD for ; Tue, 13 Mar 2018 07:58:20 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 7BE6628797 for ; Tue, 13 Mar 2018 07:58:20 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 70A8128BE4; Tue, 13 Mar 2018 07:58:20 +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 D941C28797 for ; Tue, 13 Mar 2018 07:58:19 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752263AbeCMH6R (ORCPT ); Tue, 13 Mar 2018 03:58:17 -0400 Received: from mail-pf0-f196.google.com ([209.85.192.196]:44236 "EHLO mail-pf0-f196.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752250AbeCMH6Q (ORCPT ); Tue, 13 Mar 2018 03:58:16 -0400 Received: by mail-pf0-f196.google.com with SMTP id m68so2388927pfm.11 for ; Tue, 13 Mar 2018 00:58:16 -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=CSKV4ZsjZA8tRrRtQklVjRu5ljpTR9hU0naEcvkbxu8=; b=vPjimVCT/qraJAgjygypUUfvV/cqe88sKlNsm07kVf02QGFAP6/ZIHKl3zOmmz9uRm NCjkwGLQDYIZ0csg5FVtTXJwtt92tsmOiyKEjRzbhFDmqHm8YPA/7Od2uuWUZhcsj7NN af4wswjAfoBGndRM22KsUpDJYR0/Z2QU7xilOdwt+kvilVTnbb1SYsiBwx7+niS3tsaV UbZ5mfTihcxnG0JUgixPmjWL2Adsr8RvLdt/gRm/ErvicEDFeBnnaTfmNB4WDIUmgbI8 qWnieFzpBnaaDOGF8tBbkLUcysrtE0lYxOGFhiK5nSXpQqiXwitBf4KdvAjME59V9gf/ 42eg== 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=CSKV4ZsjZA8tRrRtQklVjRu5ljpTR9hU0naEcvkbxu8=; b=EmETFzGC6Q0mHD99+GNxdwCjtMxbA0KvnqCe9CwBLVQ2yt/Qun2MDYHac96e9NYgbF zollTCDhqvEgrMfjRv8r44n51KJi3Tu/HrrSu4nVjgew0NupXzCQvDvQf/gpOoEOQ8hc KW7mPOJSSWfCe7P9W/DPvPWLwr15MemZrj+LubEK/qE+YcdtFpfzl4AtEM6J17iaC2Rg UPSVHLK96Ih0fnD2hGl9eaINwS9uJtEtkzp3txKuoBIQvUTHqH59PJT0jAjLZtzrXBn2 9UnF+rKNgVwZ0z8pMRc6MFjnQGcy7lShMNGW7RLlHOHymK/IxvjrjNVDk0UF73puFL/N tkkw== X-Gm-Message-State: AElRT7G6a+JdRGWdpri43R8IyeIf2UvSEwB0QS3YZBn5VLK2Ljr4JjUJ Q+iqio/Kqq3IG8hZq61GaNyo6w== X-Google-Smtp-Source: AG47ELtqSFbLKqHbc55tTWz2UzabCSOIVPx8llKX9L8P5IA6kN7JjEluN9lw15D2SaZ2NMsKExSkOg== X-Received: by 10.98.254.6 with SMTP id z6mr10747909pfh.155.1520927896160; Tue, 13 Mar 2018 00:58:16 -0700 (PDT) Received: from localhost.localdomain ([203.205.141.35]) by smtp.gmail.com with ESMTPSA id x4sm16756537pgv.72.2018.03.13.00.58.13 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Tue, 13 Mar 2018 00:58:15 -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, Xiao Guangrong Subject: [PATCH 8/8] migration: remove ram_save_compressed_page() Date: Tue, 13 Mar 2018 15:57:39 +0800 Message-Id: <20180313075739.11194-9-xiaoguangrong@tencent.com> X-Mailer: git-send-email 2.14.3 In-Reply-To: <20180313075739.11194-1-xiaoguangrong@tencent.com> References: <20180313075739.11194-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 Signed-off-by: Xiao Guangrong Reviewed-by: Dr. David Alan Gilbert Reviewed-by: Peter Xu --- migration/ram.c | 45 ++++++++------------------------------------- 1 file changed, 8 insertions(+), 37 deletions(-) diff --git a/migration/ram.c b/migration/ram.c index f778627992..8f4f8aca86 100644 --- a/migration/ram.c +++ b/migration/ram.c @@ -1162,41 +1162,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. @@ -1501,8 +1466,14 @@ static int ram_save_target_page(RAMState *rs, PageSearchStatus *pss, goto page_saved; } - if (save_page_use_compression(rs)) { - res = 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); } else { res = ram_save_page(rs, pss, last_stage); }