From patchwork Tue Mar 27 09:10:34 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Xiao Guangrong X-Patchwork-Id: 892029 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="eoN1Ck9X"; 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 40B2Dh0pXDz9s08 for ; Wed, 28 Mar 2018 20:11:16 +1100 (AEDT) Received: from localhost ([::1]:38152 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1f176v-0000mM-GP for incoming@patchwork.ozlabs.org; Wed, 28 Mar 2018 05:11:13 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:56621) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1f176C-0000kr-JT for qemu-devel@nongnu.org; Wed, 28 Mar 2018 05:10:29 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1f176B-0004w1-MA for qemu-devel@nongnu.org; Wed, 28 Mar 2018 05:10:28 -0400 Received: from mail-pg0-x244.google.com ([2607:f8b0:400e:c05::244]:35875) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1f176B-0004vb-AK for qemu-devel@nongnu.org; Wed, 28 Mar 2018 05:10:27 -0400 Received: by mail-pg0-x244.google.com with SMTP id 201so714525pgg.3 for ; Wed, 28 Mar 2018 02:10:27 -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=TL1XWhIt+sETAFduxXn4nL0YeK0YLzCPZxJw286oiUg=; b=eoN1Ck9XMmxWPUpfGeNrYdJbnYwiF0+2GycSflA1NyHlURopUJhE7orbNDpDQjF4Wc B50IAIndhiB8WKEiwmbrrzUrlLA3vQxFOkUGlAvie9BOc63zAUdZ+2oW2lIFhqtQM96F vtK6squJBjOh7Jvs9MSx6N2xkpBxsWADbWKj9MtJRGSYunSFO6G1pydvdjEONVEutlx7 SlSZbcP02WjPq3hlnFgdllpl1N2vFVrK7aDOV8g8RgolntwIw+BM0JNxS7z3NYYo4g7R 7VsXz+gzgg9t1SG8jsdwUjMMM0LEnxFZ8YVl1L5t2mfUEAAtaW69GfnCKSAvtkeWbas/ 0Upw== 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=TL1XWhIt+sETAFduxXn4nL0YeK0YLzCPZxJw286oiUg=; b=c0JkJaYA9S7zdJg9biFzVbWLd/8+9vUEPGbVmu/vxXI0o5JMof997KdYknVlO3MkE1 FIzKtfb33BORTjko2k39CuXNOYRVLslr8odtXODxaq1cBBHYjsawgWomgOKETdA+hMgo PPYsblsd0z64QkydaYgOyucIcnMsvqAR+gLOmEBayAaiL7HoAEebvOWp4bQE+1DBZasC kXMpsFoh6Y8DCYmTZXyEp7ky8W4wvbVSkGt+/np8dOXl+ZtAd+p7PIJWVSUMgIf6pTw6 ccqXZfbidTKar760KkELnLPanYr0EoUFMOaeM711ai0xF8gT9cizPiQMDO2XQDtWpNAP ofnA== X-Gm-Message-State: AElRT7Ef7Pp4y8BWf97yAB54S+vdZ44+KV1vKycXd6by1DBjxurYNhhv DaqEo7kZx26edsnGmqGjDo8= X-Google-Smtp-Source: AIpwx4/XAroKcoWqFf+tJ+h/MPP5W2h4lw0W+/qd8TqK6uFYtn3iGkom5/PPudB6Ft/BNhhJCChn/Q== X-Received: by 10.98.174.23 with SMTP id q23mr2311480pff.103.1522228226272; Wed, 28 Mar 2018 02:10:26 -0700 (PDT) Received: from localhost.localdomain ([203.205.141.38]) by smtp.gmail.com with ESMTPSA id q9sm5590648pgs.89.2018.03.28.02.10.23 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Wed, 28 Mar 2018 02:10:25 -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: Tue, 27 Mar 2018 17:10:34 +0800 Message-Id: <20180327091043.30220-2-xiaoguangrong@tencent.com> X-Mailer: git-send-email 2.14.3 In-Reply-To: <20180327091043.30220-1-xiaoguangrong@tencent.com> References: <20180327091043.30220-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::244 Subject: [Qemu-devel] [PATCH v2 01/10] migration: stop compressing page in migration thread 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 As compression is a heavy work, do not do it in migration thread, instead, we post it out as a normal page Reviewed-by: Wei Wang Reviewed-by: Peter Xu Reviewed-by: Dr. David Alan Gilbert Signed-off-by: Xiao Guangrong --- migration/ram.c | 32 ++++++++++++++++---------------- 1 file changed, 16 insertions(+), 16 deletions(-) diff --git a/migration/ram.c b/migration/ram.c index 0e90efa092..409c847a76 100644 --- a/migration/ram.c +++ b/migration/ram.c @@ -1137,7 +1137,7 @@ static int ram_save_compressed_page(RAMState *rs, PageSearchStatus *pss, int pages = -1; uint64_t bytes_xmit = 0; uint8_t *p; - int ret, blen; + int ret; RAMBlock *block = pss->block; ram_addr_t offset = pss->page << TARGET_PAGE_BITS; @@ -1167,23 +1167,23 @@ static int ram_save_compressed_page(RAMState *rs, PageSearchStatus *pss, if (block != rs->last_sent_block) { flush_compressed_data(rs); pages = save_zero_page(rs, block, offset); - if (pages == -1) { - /* Make sure the first page is sent out before other pages */ - bytes_xmit = save_page_header(rs, rs->f, block, offset | - RAM_SAVE_FLAG_COMPRESS_PAGE); - blen = qemu_put_compression_data(rs->f, p, TARGET_PAGE_SIZE, - migrate_compress_level()); - if (blen > 0) { - ram_counters.transferred += bytes_xmit + blen; - ram_counters.normal++; - pages = 1; - } else { - qemu_file_set_error(rs->f, blen); - error_report("compressed data failed!"); - } - } if (pages > 0) { ram_release_pages(block->idstr, offset, pages); + } else { + /* + * Make sure the first page is sent out before other pages. + * + * we post it as normal page as compression will take much + * CPU resource. + */ + ram_counters.transferred += save_page_header(rs, rs->f, block, + offset | RAM_SAVE_FLAG_PAGE); + qemu_put_buffer_async(rs->f, p, TARGET_PAGE_SIZE, + migrate_release_ram() & + migration_in_postcopy()); + ram_counters.transferred += TARGET_PAGE_SIZE; + ram_counters.normal++; + pages = 1; } } else { pages = save_zero_page(rs, block, offset);