From patchwork Tue Mar 13 07:57:32 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Xiao Guangrong X-Patchwork-Id: 10277861 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 DC299602BD for ; Tue, 13 Mar 2018 07:57:58 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id C710428787 for ; Tue, 13 Mar 2018 07:57:58 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id BBBCF2879C; Tue, 13 Mar 2018 07:57:58 +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 65B9E28787 for ; Tue, 13 Mar 2018 07:57:58 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752007AbeCMH54 (ORCPT ); Tue, 13 Mar 2018 03:57:56 -0400 Received: from mail-pl0-f67.google.com ([209.85.160.67]:42333 "EHLO mail-pl0-f67.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751830AbeCMH5y (ORCPT ); Tue, 13 Mar 2018 03:57:54 -0400 Received: by mail-pl0-f67.google.com with SMTP id w15-v6so1778887plq.9 for ; Tue, 13 Mar 2018 00:57:54 -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=UC5TJnKBOOx1kQENx1nH1wqP/Tk6n1k1ra1l5ayMmj8=; b=pPhO+Z6hwIQDuBmta7XeFkBGUuBfuHei9NdhaQ71KFt3aMCdb7mWhvy8xBhUyZkyJx sKZGHB7vr2X0aCv8QZuim2HBSSqB8gVph537VluOk/q2zu8Lzs1ijkeXayaMDeSpSoEO /3cKYO6Y9E1rGWaHyjtRRVQuNLKJYJA2VOPx5LGyV4jagk/GExehGjr4BZPHXJc/IYii /TK5A1JQf8GK+xCmPVEbTSdc7GFozO6Meqjf5jw8FbnOf4hDXfbsEqlKz7G3JXgzeAJ2 cJzPX3eHW4RzOsMfLKTturCVqzj98tUKz6ijICHtodpUctKXMIzudJ5KbqCqyrNlVyNL CG8Q== 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=UC5TJnKBOOx1kQENx1nH1wqP/Tk6n1k1ra1l5ayMmj8=; b=syCY6Kd55gCrulW2Xn2TQ0RqJjCzj2z5AynhiplupICb5TV2NXLMjiIU/AmZrADyoe PpAwOUOa9Io+XOw34i5QbH1n5MdL7Qtln1ItNAXJuOCBUQ7g+3Cp9vQ2TdXYJD77Yn4/ TdNHeWP0W0rwrEBK+muXCarayU0WIOuKFT7SCEKe/lARbqmdKoto35TGsIF4KzsXF8RG vzX5sZ5OGYPkyXnuXgVWUZqZRygN4LWECVzbFrZAJ8d8AZIpSAe2XqkguMIxcEzg7zXJ +I6osx6MlifoNyIcRFzvjf7cSX8+r4j6ZJ70PMFYOm5WM5Ln7To360pxP9A3wv2jI7tD 2x4g== X-Gm-Message-State: AElRT7H10PBWAcXudENR8qDY5MTS5aFHND64DRIvyVnKhHPTWYlSTSbi KcWquS+4vIvzKPXFq5cEQys= X-Google-Smtp-Source: AG47ELtVthUISNEphYZA43SlCwIyfJSjrKfk+ZvEnB/8nkEnZtCuSxSQXLoYej4jPQDShINhCUBOgg== X-Received: by 2002:a17:902:be16:: with SMTP id r22-v6mr8222827pls.268.1520927874282; Tue, 13 Mar 2018 00:57:54 -0700 (PDT) Received: from localhost.localdomain ([203.205.141.35]) by smtp.gmail.com with ESMTPSA id x4sm16756537pgv.72.2018.03.13.00.57.51 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Tue, 13 Mar 2018 00:57:53 -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, Xiao Guangrong Subject: [PATCH 1/8] migration: stop compressing page in migration thread Date: Tue, 13 Mar 2018 15:57:32 +0800 Message-Id: <20180313075739.11194-2-xiaoguangrong@tencent.com> X-Mailer: git-send-email 2.14.3 In-Reply-To: <20180313075739.11194-1-xiaoguangrong@tencent.com> References: <20180313075739.11194-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 Signed-off-by: Xiao Guangrong Reviewed-by: Dr. David Alan Gilbert Reviewed-by: Peter Xu Reviewed-by: Wei Wang --- migration/ram.c | 32 ++++++++++++++++---------------- 1 file changed, 16 insertions(+), 16 deletions(-) diff --git a/migration/ram.c b/migration/ram.c index 7266351fd0..615693f180 100644 --- a/migration/ram.c +++ b/migration/ram.c @@ -1132,7 +1132,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; @@ -1162,23 +1162,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);