From patchwork Tue Mar 13 07:57:38 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Xiao Guangrong X-Patchwork-Id: 10277873 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 7C98B602C2 for ; Tue, 13 Mar 2018 07:58:17 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 6896728797 for ; Tue, 13 Mar 2018 07:58:17 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 5D7E028BE4; Tue, 13 Mar 2018 07:58:17 +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 0266028797 for ; Tue, 13 Mar 2018 07:58:17 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752227AbeCMH6O (ORCPT ); Tue, 13 Mar 2018 03:58:14 -0400 Received: from mail-pf0-f169.google.com ([209.85.192.169]:37085 "EHLO mail-pf0-f169.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752192AbeCMH6N (ORCPT ); Tue, 13 Mar 2018 03:58:13 -0400 Received: by mail-pf0-f169.google.com with SMTP id h11so5529476pfn.4 for ; Tue, 13 Mar 2018 00:58:13 -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=qkT2r6VMWNa5M5xGmgnsqhXnO84NtFGGtYAS9Fyu7MM=; b=ZpqB8vUUaannXYmYYFFWxWknnwTdepYPGRxD5KQQWmFbcbWJgYLqKUszClDOcRD9GZ XIx/kHRFb36vR7QrWk8OZpf9KdSs/dtQKTKBKohAuYEYcfArVwrt2IsUHRAxCyk0semJ 4q401PahwaFPIaaQTBnJ2lR9ZzsMF9wdwDPGs4t1M7MNF6V4THaOUvnWv4G+UX7ADW7Q rSOZXetIvqV6SUzeSEdhikENhadZJS+O7w7d9qxR/wUt4+JkA6F+/j3RIRSHEHcHXftj IYxEIi9bYPMX12/u1CfXJVH3Wxps3RP/yjtbnLya6f5TKQ0aIwGqUjZfJ1jvXflpLsKa f9VQ== 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=qkT2r6VMWNa5M5xGmgnsqhXnO84NtFGGtYAS9Fyu7MM=; b=SGleTLe21CcpYjUQ0E8dXzg8CRLnlcZkcGGp3p4bhL0h/jUl9pJlmb227QDlQjOLzs SJ419odntuV4wo96It1GM7J1+qyq1n/SCo4M7XcRcrSyu3wLiE0Jm2VgLXNkPh+P5xUg hkUMMymV85TNTTh7LBCLE5ouIywa3zjHrDh8548sdaaNdoPA9gI/Lfdd/aQ+gjv26d7c bdjgF4F1WCtNtrWTra51idpRjWPvl5HorknS37VVMXbTmBUaI8WrRTRyZmuuEkUcQ0sT b/Z8vrUAl7UJ2bWwvNCzRbAPZtM1CuwVvgcAvyKWVRw0rMELkDeSKU0MyB6y6kU/MkRI vrAg== X-Gm-Message-State: AElRT7Fcx+l5RrNVP0998iUCsZcNoxaUenFFmuHoJF9BJIq2lDMA6ScE AT6kV8jt5R1qpMfETrjD8BI= X-Google-Smtp-Source: AG47ELsByyLEIp1SldNNLVudsdRa2Jck0fNkaVYYRM46MQKWTGmwwNJy0ZyYHGkzr/Ysmso2xDwDRw== X-Received: by 10.98.232.6 with SMTP id c6mr10686037pfi.242.1520927893157; Tue, 13 Mar 2018 00:58:13 -0700 (PDT) Received: from localhost.localdomain ([203.205.141.35]) by smtp.gmail.com with ESMTPSA id x4sm16756537pgv.72.2018.03.13.00.58.10 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Tue, 13 Mar 2018 00:58:12 -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 7/8] migration: introduce save_normal_page() Date: Tue, 13 Mar 2018 15:57:38 +0800 Message-Id: <20180313075739.11194-8-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 It directly sends the page to the stream neither checking zero nor using xbzrle or compression Signed-off-by: Xiao Guangrong Reviewed-by: Dr. David Alan Gilbert Reviewed-by: Peter Xu --- migration/ram.c | 50 ++++++++++++++++++++++++++++++-------------------- 1 file changed, 30 insertions(+), 20 deletions(-) diff --git a/migration/ram.c b/migration/ram.c index 9627ce18e9..f778627992 100644 --- a/migration/ram.c +++ b/migration/ram.c @@ -995,6 +995,34 @@ static bool control_save_page(RAMState *rs, RAMBlock *block, ram_addr_t offset, return true; } +/* + * directly send the page to the stream + * + * Returns the number of pages written. + * + * @rs: current RAM state + * @block: block that contains the page we want to send + * @offset: offset inside the block for the page + * @buf: the page to be sent + * @async: send to page asyncly + */ +static int save_normal_page(RAMState *rs, RAMBlock *block, ram_addr_t offset, + uint8_t *buf, bool async) +{ + ram_counters.transferred += save_page_header(rs, rs->f, block, + offset | RAM_SAVE_FLAG_PAGE); + if (async) { + qemu_put_buffer_async(rs->f, buf, TARGET_PAGE_SIZE, + migrate_release_ram() & + migration_in_postcopy()); + } else { + qemu_put_buffer(rs->f, buf, TARGET_PAGE_SIZE); + } + ram_counters.transferred += TARGET_PAGE_SIZE; + ram_counters.normal++; + return 1; +} + /** * ram_save_page: send the given page to the stream * @@ -1035,18 +1063,7 @@ static int ram_save_page(RAMState *rs, PageSearchStatus *pss, bool last_stage) /* XBZRLE overflow or normal page */ if (pages == -1) { - ram_counters.transferred += - save_page_header(rs, rs->f, block, offset | RAM_SAVE_FLAG_PAGE); - if (send_async) { - qemu_put_buffer_async(rs->f, p, TARGET_PAGE_SIZE, - migrate_release_ram() & - migration_in_postcopy()); - } else { - qemu_put_buffer(rs->f, p, TARGET_PAGE_SIZE); - } - ram_counters.transferred += TARGET_PAGE_SIZE; - pages = 1; - ram_counters.normal++; + pages = save_normal_page(rs, block, offset, p, send_async); } XBZRLE_cache_unlock(); @@ -1172,14 +1189,7 @@ static int ram_save_compressed_page(RAMState *rs, PageSearchStatus *pss, * 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; + pages = save_normal_page(rs, block, offset, p, true); } else { pages = compress_page_with_multi_thread(rs, block, offset); }