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: 10317295 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id B630760467 for ; Fri, 30 Mar 2018 07:51:15 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id AABA42A17F for ; Fri, 30 Mar 2018 07:51:15 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 9F6092A55F; Fri, 30 Mar 2018 07:51:15 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-7.0 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, FREEMAIL_FROM, RCVD_IN_DNSWL_HI autolearn=ham version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 10C012A17F for ; Fri, 30 Mar 2018 07:51:15 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751976AbeC3HvN (ORCPT ); Fri, 30 Mar 2018 03:51:13 -0400 Received: from mail-pf0-f177.google.com ([209.85.192.177]:39735 "EHLO mail-pf0-f177.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751397AbeC3HvL (ORCPT ); Fri, 30 Mar 2018 03:51:11 -0400 Received: by mail-pf0-f177.google.com with SMTP id c78so4979311pfj.6 for ; Fri, 30 Mar 2018 00:51:10 -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=JePIuzR3JZckJKE56q5C7jt9f5Z/IY8Jv6ZHe9iT7EqlPr9TcqW8wBgftPGm8N/3Fn qGKB9PxJ5lyuejq2HC1b03JUCsnA404jxvf5KipTdYOtqb4QWICy0xIsiDjeCyfUBXIK 63fXzdkE90PJRs81a3c8etNJ6LRJuF3l3WbxZBmUv+TjiSkGk8jvZXhkuDGCBQcRXO/1 ymKbpZYgyssrf+Iqb7bVf0zZg+FDN99rA2JVmqYKIukV1AjXHMo38or0uSod2ujeLoXu P/n6WeGMGv0+Cf/i6uPmx4TZIIXCku2IkTOQNVV51R7brI9aYUQv10WmVKe6ceCaktZx ppiw== X-Gm-Message-State: AElRT7GOhli8S6KrU48QAbBFUJ1J/zwBvDyfjwT94ytnOv3ZSIaVaWCG NcO1sJLwG3x+7AKQGGrv70k= 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 Cc: qemu-devel@nongnu.org, kvm@vger.kernel.org, dgilbert@redhat.com, peterx@redhat.com, jiang.biao2@zte.com.cn, wei.w.wang@intel.com, Xiao Guangrong Subject: [PATCH v3 01/10] migration: stop compressing page in migration thread 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> Sender: kvm-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: kvm@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP 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);