From patchwork Fri Mar 30 07:51:19 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Xiao Guangrong X-Patchwork-Id: 893160 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="fkYfeXLN"; 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 40CDNN2JT1z9s1r for ; Fri, 30 Mar 2018 18:52:02 +1100 (AEDT) Received: from localhost ([::1]:40862 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1f1opL-0001p2-Ah for incoming@patchwork.ozlabs.org; Fri, 30 Mar 2018 03:51:59 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:56230) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1f1ooa-0001nZ-Pm for qemu-devel@nongnu.org; Fri, 30 Mar 2018 03:51:13 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1f1ooZ-0007YK-M8 for qemu-devel@nongnu.org; Fri, 30 Mar 2018 03:51:12 -0400 Received: from mail-pf0-x230.google.com ([2607:f8b0:400e:c00::230]:40324) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1f1ooZ-0007YA-F9 for qemu-devel@nongnu.org; Fri, 30 Mar 2018 03:51:11 -0400 Received: by mail-pf0-x230.google.com with SMTP id y66so4951060pfi.7 for ; Fri, 30 Mar 2018 00:51:11 -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=fkYfeXLNWTokAx+6DNAhYPnDbPLJm6dad6fMSDm5YwNHgSioZXDznY1vmfNfXAQsTJ HcstQ/sV6qp05R9xYXwVf5kgh0b5PHM7PPoEw5VvNOLJS9oFAUT5kJzFeKzVQTYcBh6e 1YuduK0oOI6D3VzlG5JhRAFb3w+j+K4Y/SJEeGhjFD2MR5D2jnwTMUsyFctswu8WToY6 UGF2YltTXTVTyNCeCAzs/8DNWtYgDcK1NVkZUoZ8uSYuFTWAXS727Lu+f8VOvjn5Mtuy 6vwym0PuglBWNch4KTedrfIItqBZZonm0+BLB/iZxJ9zYN7qUbJIcy3HVAo+0/8BIX4N GkUQ== 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=RxYV8ugpDCE61bpvWZTodszQZ2LHSSrBtXhnUjfXyIS8FeZm+A94hJi6wV3M+ySUEC hMlij2qIS85fvNL0Wrz7d4YZDZthEBMC7ZQ/oWTSRJRAkPS8tEQItJaL8w/O1f7pXicM r2gNKdn/j5B72VXDwnLFV7eAIOy2Ik6WLblHQ/led+Pec97fIuL7o9yYMg2WWjsRCQ5W 4DPZrYCpT3zc0RaM6uwmVlnheeRQY/QwJ+kBoVR/Mf88DJS3Az+Sv47IDg+LOtBRhzpi vnu6ILq7v0jtgwHhmlEm8Bb8W+BrERvTtNnCdi3PC+25cRX6PN+EMBq6tK731tP2VNfL cvEQ== X-Gm-Message-State: AElRT7Hgb4ZiE1N1FIUhmNVjq94ZanAsZohn8bS3uQ6dB4ITZm3pWDKu tmfmWp3O+uFqILGA1oSHSynQ1A== X-Google-Smtp-Source: AIpwx49Yo86miJbjqYl1E+Ix7xB8o+9/j2fblwDnibBCk6c4MIyXl+eH0NOf72Z30zlEf9h+kHGQyw== X-Received: by 10.99.169.1 with SMTP id u1mr7936032pge.251.1522396270551; Fri, 30 Mar 2018 00:51:10 -0700 (PDT) Received: from localhost.localdomain ([203.205.141.38]) by smtp.gmail.com with ESMTPSA id r75sm16557107pfb.98.2018.03.30.00.51.07 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Fri, 30 Mar 2018 00:51:10 -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: Fri, 30 Mar 2018 15:51:19 +0800 Message-Id: <20180330075128.26919-2-xiaoguangrong@tencent.com> X-Mailer: git-send-email 2.14.3 In-Reply-To: <20180330075128.26919-1-xiaoguangrong@tencent.com> References: <20180330075128.26919-1-xiaoguangrong@tencent.com> X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 2607:f8b0:400e:c00::230 Subject: [Qemu-devel] [PATCH v3 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);