From patchwork Mon Jun 4 09:55:14 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Xiao Guangrong X-Patchwork-Id: 10446181 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 07CC160284 for ; Mon, 4 Jun 2018 09:56:38 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id ECF5128BC6 for ; Mon, 4 Jun 2018 09:56:37 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id E1DB328BD0; Mon, 4 Jun 2018 09:56:37 +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=-8.0 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, FREEMAIL_FROM, MAILING_LIST_MULTI, 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 6C06D28BC6 for ; Mon, 4 Jun 2018 09:56:37 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752453AbeFDJ4e (ORCPT ); Mon, 4 Jun 2018 05:56:34 -0400 Received: from mail-pl0-f68.google.com ([209.85.160.68]:35919 "EHLO mail-pl0-f68.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752448AbeFDJ4X (ORCPT ); Mon, 4 Jun 2018 05:56:23 -0400 Received: by mail-pl0-f68.google.com with SMTP id v24-v6so19392988plo.3 for ; Mon, 04 Jun 2018 02:56:22 -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=aH2Gwskf+jJbLGc5BYs25N5cBEGULq8L0irgyJaU/HM=; b=X0WCPNbNZXYyoD7cHY3remVQ1Nho84koou+Yo5PdHO2cCf5s0/N/1wG6z5+5UDJ6yU u6Xoj8RniuyoI78gHgUoeRwVAIjTv/4uuxxSBeQWfMXJnfzFdrpNBjq/Hr4fEstM0dbK dnXely0pBUGE2TxLORPOy6C2492AfzwHI6XbRUoat8c4tHTbHg2T6ufMn5RKR4fpTABq 4ucm3VxJjySZrn+8fg60oApbl2l1KjWmm4bMEhwwh+cpz+hZVpNsIvyRXFPklgbzer93 dSc8X1f4jZyWxtRaJpByS7BFE0e/EP8wl/dyMez3IpoGzxenPxipbruvptl57pdpcJey o1PQ== 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=aH2Gwskf+jJbLGc5BYs25N5cBEGULq8L0irgyJaU/HM=; b=O90sNzi1sn/NySNRRZ5ft4mMjJudjm0VOtf0qNGT90CF/+7gS/Q5ei104+pN2NmOi0 CHnD6sUud/1fLHZpLP7j0rbTdDJMab9PzZMwFwEIhxSP0ND32syaOR0fd2qhhgu5H2Qe Z05DHH0o31To6hCy55rZxmx/h9JskYxx0sSXhrvPELyw7iayFDEnph5Oa17TL8LCFHE9 fyggaMoLo56jmCCWLBVp58qRvyG9n5xYnsk4fmJufN3ALXnmyP6DJfp5X7lIVHimxFik HOb16xO/xVuFnMzvgOB1YHXjDZIvUC/JpOQSdae9GwbjgtVCea7sgfSqcqMNF4nRnPru oU0Q== X-Gm-Message-State: ALKqPwfrVcE1tOUeXkAeO46xdTAnDGEu8vjlv84Gh1rwadrqhIT1EOSl +XkqHviO3Og+xpRZM8Z2ngA= X-Google-Smtp-Source: ADUXVKJLPcKpQ3DWcjYJZKnBDjawUPjpu59nJCChtVYIAwQngzRp4ST4AiGwaEdy+Taeb3VjonjIqg== X-Received: by 2002:a17:902:d697:: with SMTP id v23-v6mr12715755ply.193.1528106182707; Mon, 04 Jun 2018 02:56:22 -0700 (PDT) Received: from localhost.localdomain ([203.205.141.35]) by smtp.gmail.com with ESMTPSA id h130-v6sm124502105pfc.98.2018.06.04.02.56.19 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Mon, 04 Jun 2018 02:56:22 -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 06/12] migration: do not detect zero page for compression Date: Mon, 4 Jun 2018 17:55:14 +0800 Message-Id: <20180604095520.8563-7-xiaoguangrong@tencent.com> X-Mailer: git-send-email 2.14.4 In-Reply-To: <20180604095520.8563-1-xiaoguangrong@tencent.com> References: <20180604095520.8563-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 Detecting zero page is not a light work, we can disable it for compression that can handle all zero data very well Signed-off-by: Xiao Guangrong --- migration/ram.c | 44 +++++++++++++++++++++++--------------------- 1 file changed, 23 insertions(+), 21 deletions(-) diff --git a/migration/ram.c b/migration/ram.c index 80914b747e..15b20d3f70 100644 --- a/migration/ram.c +++ b/migration/ram.c @@ -1760,15 +1760,30 @@ static int ram_save_target_page(RAMState *rs, PageSearchStatus *pss, return res; } - /* - * When starting the process of a new block, the first page of - * the block should be sent out before other pages in the same - * block, and all the pages in last block should have been sent - * out, keeping this order is important, because the 'cont' flag - * is used to avoid resending the block name. - */ - if (block != rs->last_sent_block && save_page_use_compression(rs)) { + if (save_page_use_compression(rs)) { + /* + * When starting the process of a new block, the first page of + * the block should be sent out before other pages in the same + * block, and all the pages in last block should have been sent + * out, keeping this order is important, because the 'cont' flag + * is used to avoid resending the block name. + * + * We post the fist page as normal page as compression will take + * much CPU resource. + */ + if (block != rs->last_sent_block) { flush_compressed_data(rs); + } else { + /* + * do not detect zero page as it can be handled very well + * for compression + */ + res = compress_page_with_multi_thread(rs, block, offset); + if (res > 0) { + return res; + } + compression_counters.busy++; + } } res = save_zero_page(rs, block, offset); @@ -1785,19 +1800,6 @@ static int ram_save_target_page(RAMState *rs, PageSearchStatus *pss, return res; } - /* - * 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); - if (res > 0) { - return res; - } - compression_counters.busy++; - } return ram_save_page(rs, pss, last_stage); }