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: 924915 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="X0WCPNbN"; 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 40zr536gSPz9rxs for ; Mon, 4 Jun 2018 19:59:35 +1000 (AEST) Received: from localhost ([::1]:38621 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1fPmGz-0001MZ-Jk for incoming@patchwork.ozlabs.org; Mon, 04 Jun 2018 05:59:33 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:46552) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1fPmDw-0007bL-Km for qemu-devel@nongnu.org; Mon, 04 Jun 2018 05:56:25 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1fPmDv-0001CA-Og for qemu-devel@nongnu.org; Mon, 04 Jun 2018 05:56:24 -0400 Received: from mail-pl0-x243.google.com ([2607:f8b0:400e:c01::243]:34704) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1fPmDv-0001Bs-Ir for qemu-devel@nongnu.org; Mon, 04 Jun 2018 05:56:23 -0400 Received: by mail-pl0-x243.google.com with SMTP id g20-v6so1601248plq.1 for ; Mon, 04 Jun 2018 02:56:23 -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=ZJcYU0+4OjrvjfVwWkdlAsKL2CNiKnwNXTeZAwoyeb0KD2JQRu9y/785XNPT8FuS+/ LyPjFyKOPLjPc2kjRYJR8pRA5hLxcOQ+Hv0Tpa7xDIaM1UCFLv3BslefWJzdzd+kM+cc 14ly98t9pd7fahpWbFR60KxBGiszTKswGZS6tLnsO9LncKsOiutJneHFIqlPT5qc8xyO 1UkYZWj+VNDbs2AUsy2Nq9E32o+3HAYCr1TvLigAQANu68kCLlh5s9KGvq26JcAR5wFt 8oJtrM5IfntBO3nvgs3cgRxC/u2Z9+AmpMwazZ12IjysbxxbvNb5jorm8nwgcjF1VW6a TdCg== X-Gm-Message-State: ALKqPwdp2+nScPLl7NrLtVCzeZ6E0RAr4pRYm0dzk1N/uroq//jKUtic KGryBPPKiC/riaQQLGcHojo= 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 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> X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 2607:f8b0:400e:c01::243 Subject: [Qemu-devel] [PATCH 06/12] migration: do not detect zero page for compression 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 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); }