From patchwork Fri Mar 30 07:51:27 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Xiao Guangrong X-Patchwork-Id: 10317311 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 180BF60383 for ; Fri, 30 Mar 2018 07:51:41 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 0D10C2A17F for ; Fri, 30 Mar 2018 07:51:41 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 01E3E2A55F; Fri, 30 Mar 2018 07:51:40 +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 8EFBD2A17F for ; Fri, 30 Mar 2018 07:51:40 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751324AbeC3Hvi (ORCPT ); Fri, 30 Mar 2018 03:51:38 -0400 Received: from mail-pf0-f177.google.com ([209.85.192.177]:34547 "EHLO mail-pf0-f177.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752192AbeC3Hvh (ORCPT ); Fri, 30 Mar 2018 03:51:37 -0400 Received: by mail-pf0-f177.google.com with SMTP id q9so4992215pff.1 for ; Fri, 30 Mar 2018 00:51:36 -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=Wee6hB1rpXgOf1s4KkwmsEQwUMDIgf1HCAuTBaNpP/Y=; b=p5YThq44g+eWNXQrDIPkhNE3ZCZNRHVF6TS+w8CFE2FB+896Gv8MLRfUsm7VqBLsXz 4Rr06Q3/FybzAwqn5bmUOePDNN7c5MJWTPofB7uXySV/6NUPz5eO0o1AOF54dGwuFhmm qMgfu3SNRzIYN2MUeioq87CRCs9Tq2kLsfcppFaMhgQ5v8hU7TX2dJDBTU4K84w4duL6 7qoYWoobKXK0zAqUC0jUXTilS1u3G2QAq8LRxZnIdCpYEQJjAVKzBbsJ9xRBmK3ix7/o P7UOl6StujhSf7MUQ0MmMV8l8fAbYmXMDIqmy904Q6q7zT3ajCh+qvQEsSmGoMan9rDN drdA== 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=Wee6hB1rpXgOf1s4KkwmsEQwUMDIgf1HCAuTBaNpP/Y=; b=NICCx2xOIMIAsPXxwjU4+Cq2o1zqMfLmhL1CyUhvgf/OG0yl5Niaj1YCgDdUuoqCBq 6ZqHqCuzOawXpnXedgxIR5rcJDOzhAfWbanBLMShBue1/oa48G5dEGochsr8v6GThXvt I1oYwO/3VGaS6/7sZ9nklYTQ2JKaYp3Mn6Eh+diaPQF5X7z0knCmsJ+XIr6dagfB/irW W0HjkA23t5RwQkoHe8br2Dei6W5ljhAJBdIDFPg0qyAL+dJe4mileHSCdwkNn7fPBPMI pVGBLGt3O77xb+X8gQHt7VIr/vc3g6FyDYtnAqnWkzwDZSPQzadzWZWsoAECCJ2+d6vU vfzg== X-Gm-Message-State: AElRT7F/KpcZBXDuPf2kEvJRU+qbdvTGRzarwMiwR2BeZeKMp+9lTiEW alv6eImJePOHm8pH1nGZjF1u6Q== X-Google-Smtp-Source: AIpwx4+OmQ4yIbx6a9RaLiC58mNRUVmQdui2ZYnJPzwhiIGrj7GUpKMUuQQC5KwvJtC+tEnE4g9F5g== X-Received: by 10.98.194.142 with SMTP id w14mr6336042pfk.226.1522396296426; Fri, 30 Mar 2018 00:51:36 -0700 (PDT) Received: from localhost.localdomain ([203.205.141.38]) by smtp.gmail.com with ESMTPSA id r75sm16557107pfb.98.2018.03.30.00.51.33 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Fri, 30 Mar 2018 00:51:35 -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 09/10] migration: introduce save_normal_page() Date: Fri, 30 Mar 2018 15:51:27 +0800 Message-Id: <20180330075128.26919-10-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 It directly sends the page to the stream neither checking zero nor using xbzrle or compression Reviewed-by: Peter Xu Reviewed-by: Dr. David Alan Gilbert Signed-off-by: Xiao Guangrong --- migration/ram.c | 50 ++++++++++++++++++++++++++++++-------------------- 1 file changed, 30 insertions(+), 20 deletions(-) diff --git a/migration/ram.c b/migration/ram.c index 97917542c5..2eb4c0bf49 100644 --- a/migration/ram.c +++ b/migration/ram.c @@ -1012,6 +1012,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 * @@ -1052,18 +1080,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(); @@ -1194,14 +1211,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); }