From patchwork Fri Jun 17 13:06:47 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Amit Shah X-Patchwork-Id: 637015 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org 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 3rWLQC2Xz8z9t26 for ; Fri, 17 Jun 2016 23:17:23 +1000 (AEST) Received: from localhost ([::1]:57417 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1bDteC-0002CB-PU for incoming@patchwork.ozlabs.org; Fri, 17 Jun 2016 09:17:20 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:55955) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1bDtUZ-0007Wf-VG for qemu-devel@nongnu.org; Fri, 17 Jun 2016 09:07:25 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1bDtUX-00086i-Pm for qemu-devel@nongnu.org; Fri, 17 Jun 2016 09:07:22 -0400 Received: from mx1.redhat.com ([209.132.183.28]:43317) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1bDtUX-00086e-Hy for qemu-devel@nongnu.org; Fri, 17 Jun 2016 09:07:21 -0400 Received: from int-mx10.intmail.prod.int.phx2.redhat.com (int-mx10.intmail.prod.int.phx2.redhat.com [10.5.11.23]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 39399C04B305; Fri, 17 Jun 2016 13:07:21 +0000 (UTC) Received: from localhost (ovpn-116-17.sin2.redhat.com [10.67.116.17]) by int-mx10.intmail.prod.int.phx2.redhat.com (8.14.4/8.14.4) with ESMTP id u5HD7Jmx027550; Fri, 17 Jun 2016 09:07:20 -0400 From: Amit Shah To: Peter Maydell Date: Fri, 17 Jun 2016 18:36:47 +0530 Message-Id: In-Reply-To: References: In-Reply-To: References: X-Scanned-By: MIMEDefang 2.68 on 10.5.11.23 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.31]); Fri, 17 Jun 2016 13:07:21 +0000 (UTC) X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] X-Received-From: 209.132.183.28 Subject: [Qemu-devel] [PULL 08/13] migration: refine ram_save_compressed_page 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: Juan Quintela , liang.z.li@intel.com, qemu list , "Dr. David Alan Gilbert" , Amit Shah , den@openvz.org Errors-To: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Sender: "Qemu-devel" From: Liang Li Use qemu_put_compression_data to do the compression directly instead of using do_compress_ram_page, avoid some data copy. very small improvement, at the same time, add code to check if the compression is successful. Signed-off-by: Liang Li Message-Id: <1462433579-13691-6-git-send-email-liang.z.li@intel.com> Signed-off-by: Amit Shah --- migration/ram.c | 27 +++++++++++++-------------- 1 file changed, 13 insertions(+), 14 deletions(-) diff --git a/migration/ram.c b/migration/ram.c index d30c923..9e4f5e5 100644 --- a/migration/ram.c +++ b/migration/ram.c @@ -929,24 +929,20 @@ static int ram_save_compressed_page(QEMUFile *f, PageSearchStatus *pss, uint64_t *bytes_transferred) { int pages = -1; - uint64_t bytes_xmit; + uint64_t bytes_xmit = 0; uint8_t *p; - int ret; + int ret, blen; RAMBlock *block = pss->block; ram_addr_t offset = pss->offset; p = block->host + offset; - bytes_xmit = 0; ret = ram_control_save_page(f, block->offset, offset, TARGET_PAGE_SIZE, &bytes_xmit); if (bytes_xmit) { *bytes_transferred += bytes_xmit; pages = 1; } - if (block == last_sent_block) { - offset |= RAM_SAVE_FLAG_CONTINUE; - } if (ret != RAM_SAVE_CONTROL_NOT_SUPP) { if (ret != RAM_SAVE_CONTROL_DELAYED) { if (bytes_xmit > 0) { @@ -966,19 +962,22 @@ static int ram_save_compressed_page(QEMUFile *f, PageSearchStatus *pss, flush_compressed_data(f); pages = save_zero_page(f, block, offset, p, bytes_transferred); if (pages == -1) { - set_compress_params(&comp_param[0], block, offset); - /* Use the qemu thread to compress the data to make sure the - * first page is sent out before other pages - */ - bytes_xmit = do_compress_ram_page(&comp_param[0]); - if (bytes_xmit > 0) { + /* Make sure the first page is sent out before other pages */ + bytes_xmit = save_page_header(f, block, offset | + RAM_SAVE_FLAG_COMPRESS_PAGE); + blen = qemu_put_compression_data(f, p, TARGET_PAGE_SIZE, + migrate_compress_level()); + if (blen > 0) { + *bytes_transferred += bytes_xmit + blen; acct_info.norm_pages++; - qemu_put_qemu_file(f, comp_param[0].file); - *bytes_transferred += bytes_xmit; pages = 1; + } else { + qemu_file_set_error(f, blen); + error_report("compressed data failed!"); } } } else { + offset |= RAM_SAVE_FLAG_CONTINUE; pages = save_zero_page(f, block, offset, p, bytes_transferred); if (pages == -1) { pages = compress_page_with_multi_thread(f, block, offset,