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: 10277877 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 EE5A0602BD for ; Tue, 13 Mar 2018 07:59:08 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id DD0F428D13 for ; Tue, 13 Mar 2018 07:59:08 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id D1D1A28EAC; Tue, 13 Mar 2018 07:59:08 +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=-6.8 required=2.0 tests=BAYES_00, DKIM_ADSP_CUSTOM_MED, DKIM_SIGNED,FREEMAIL_FROM,RCVD_IN_DNSWL_HI,T_DKIM_INVALID autolearn=unavailable version=3.3.1 Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) (using TLSv1 with cipher AES256-SHA (256/256 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id 8A66228E01 for ; Tue, 13 Mar 2018 07:59:08 +0000 (UTC) Received: from localhost ([::1]:37439 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1evepv-00044T-M1 for patchwork-qemu-devel@patchwork.kernel.org; Tue, 13 Mar 2018 03:59:07 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:42932) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1eveom-0002r4-4x for qemu-devel@nongnu.org; Tue, 13 Mar 2018 03:57:57 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1eveol-0007OM-AW for qemu-devel@nongnu.org; Tue, 13 Mar 2018 03:57:56 -0400 Received: from mail-pl0-x241.google.com ([2607:f8b0:400e:c01::241]:44887) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1eveol-0007NO-4H for qemu-devel@nongnu.org; Tue, 13 Mar 2018 03:57:55 -0400 Received: by mail-pl0-x241.google.com with SMTP id 9-v6so10877769ple.11 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=NkcfrWGdDTDdtF5OJr/d6AzAwtAGfE0x13GjHGcowLomKG0LcLQk4El9dVarHqILGH 42my2KFxfSzpwIq/brxbvtwF+dwBd0Qwmqa5s/LK/gUoo63+pL64DgfUaCk+ywMC8shr q6LfevmaxXEBtu8gDzXZZbIiMM0B+Fb1XJWfCfTIXVZE3hJa6fmekXH0dD67U6ooKFKI ILZW0hqtRgOXfnnDYueHL3+3Mzpq7QyZi3e28OKJ8m7BC/cX1kc8l6nxy0G2Hk/eyCMu SVKE3MVdFE35U94YAOc3fPcDM4ImS1KoZrgWzIop9U/IGxQVpZ7si2X/siP5WXyCIZzE /Y1Q== X-Gm-Message-State: AElRT7FOhJee0/XNsjGTuBGzUWcIVQXRDS1eK+IxWstJgDOT2g80CEIC HkaiqFHY/4uHfW0sZvYLsDtM1g== 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 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> X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 2607:f8b0:400e:c01::241 Subject: [Qemu-devel] [PATCH 1/8] 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: Xiao Guangrong , qemu-devel@nongnu.org, kvm@vger.kernel.org Errors-To: qemu-devel-bounces+patchwork-qemu-devel=patchwork.kernel.org@nongnu.org Sender: "Qemu-devel" 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);