From nobody Wed Oct 29 17:30:52 2025 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) client-ip=208.118.235.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Authentication-Results: mx.zohomail.com; spf=pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail(p=none dis=none) header.from=redhat.com Return-Path: Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) by mx.zohomail.com with SMTPS id 152468694060922.44183258747603; Wed, 25 Apr 2018 13:09:00 -0700 (PDT) Received: from localhost ([::1]:38799 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1fBQip-0007aQ-Fk for importer@patchew.org; Wed, 25 Apr 2018 16:08:59 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:45289) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1fBQdg-0003ah-Tx for qemu-devel@nongnu.org; Wed, 25 Apr 2018 16:03:44 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1fBQdg-00031u-2p for qemu-devel@nongnu.org; Wed, 25 Apr 2018 16:03:40 -0400 Received: from mx3-rdu2.redhat.com ([66.187.233.73]:44074 helo=mx1.redhat.com) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1fBQdf-00031o-U6 for qemu-devel@nongnu.org; Wed, 25 Apr 2018 16:03:40 -0400 Received: from smtp.corp.redhat.com (int-mx06.intmail.prod.int.rdu2.redhat.com [10.11.54.6]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 7FEFA40201DF; Wed, 25 Apr 2018 20:03:39 +0000 (UTC) Received: from dgilbert-t530.redhat.com (ovpn-116-232.ams2.redhat.com [10.36.116.232]) by smtp.corp.redhat.com (Postfix) with ESMTP id 8D25D2166BAD; Wed, 25 Apr 2018 20:03:38 +0000 (UTC) From: "Dr. David Alan Gilbert (git)" To: qemu-devel@nongnu.org, quintela@redhat.com, peterx@redhat.com, a.perevalov@samsung.com, xiaoguangrong@tencent.com Date: Wed, 25 Apr 2018 21:03:17 +0100 Message-Id: <20180425200326.72337-8-dgilbert@redhat.com> In-Reply-To: <20180425200326.72337-1-dgilbert@redhat.com> References: <20180425200326.72337-1-dgilbert@redhat.com> X-Scanned-By: MIMEDefang 2.78 on 10.11.54.6 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.11.55.6]); Wed, 25 Apr 2018 20:03:39 +0000 (UTC) X-Greylist: inspected by milter-greylist-4.5.16 (mx1.redhat.com [10.11.55.6]); Wed, 25 Apr 2018 20:03:39 +0000 (UTC) for IP:'10.11.54.6' DOMAIN:'int-mx06.intmail.prod.int.rdu2.redhat.com' HELO:'smtp.corp.redhat.com' FROM:'dgilbert@redhat.com' RCPT:'' X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] [fuzzy] X-Received-From: 66.187.233.73 Subject: [Qemu-devel] [PULL 07/16] 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: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail: RSF_0 Z_629925259 SPT_0 Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" 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 Message-Id: <20180330075128.26919-2-xiaoguangrong@tencent.com> Signed-off-by: Dr. David Alan Gilbert --- 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, Pag= eSearchStatus *pss, int pages =3D -1; uint64_t bytes_xmit =3D 0; uint8_t *p; - int ret, blen; + int ret; RAMBlock *block =3D pss->block; ram_addr_t offset =3D pss->page << TARGET_PAGE_BITS; =20 @@ -1167,23 +1167,23 @@ static int ram_save_compressed_page(RAMState *rs, P= ageSearchStatus *pss, if (block !=3D rs->last_sent_block) { flush_compressed_data(rs); pages =3D save_zero_page(rs, block, offset); - if (pages =3D=3D -1) { - /* Make sure the first page is sent out before other pages= */ - bytes_xmit =3D save_page_header(rs, rs->f, block, offset | - RAM_SAVE_FLAG_COMPRESS_PAGE); - blen =3D qemu_put_compression_data(rs->f, p, TARGET_PAGE_S= IZE, - migrate_compress_level()); - if (blen > 0) { - ram_counters.transferred +=3D bytes_xmit + blen; - ram_counters.normal++; - pages =3D 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 +=3D save_page_header(rs, rs->f, = block, + offset | RAM_SAVE_FLAG_PAG= E); + qemu_put_buffer_async(rs->f, p, TARGET_PAGE_SIZE, + migrate_release_ram() & + migration_in_postcopy()); + ram_counters.transferred +=3D TARGET_PAGE_SIZE; + ram_counters.normal++; + pages =3D 1; } } else { pages =3D save_zero_page(rs, block, offset); --=20 2.17.0