From patchwork Tue Mar 27 09:10:42 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Xiao Guangrong X-Patchwork-Id: 10312571 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 E971760325 for ; Wed, 28 Mar 2018 09:10:59 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id DC94E29C01 for ; Wed, 28 Mar 2018 09:10:59 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id D16B829C2C; Wed, 28 Mar 2018 09:10:59 +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=-5.7 required=2.0 tests=BAYES_00, DATE_IN_PAST_24_48, 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 70A0B29C2E for ; Wed, 28 Mar 2018 09:10:59 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752216AbeC1JKz (ORCPT ); Wed, 28 Mar 2018 05:10:55 -0400 Received: from mail-pl0-f52.google.com ([209.85.160.52]:34029 "EHLO mail-pl0-f52.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751341AbeC1JKw (ORCPT ); Wed, 28 Mar 2018 05:10:52 -0400 Received: by mail-pl0-f52.google.com with SMTP id u11-v6so1212568plq.1 for ; Wed, 28 Mar 2018 02:10:52 -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=F33N57sAf+wp/fVCaGOBBnoIR6diNc3lH+anQmNYRYY=; b=GOlo2Uih1Ab51AFvSJ3hITeyI658hkxbNY1B3mTkrISpx8OfUR8gSGsk+vJHMlULkU fJ5M2fKs28VSsWGIee7y/lF40vRHMwfIZOLwPJjc3vNL+EtmPkutt+NJBtE+/kMI6W8R +xpkBmKK0DvtTwHGMUpqoVFlNtmzuiVuqxQbU52M0lXjtE9EyCwKMqLJnEDXf+7IXBw/ WvZqhaTVlAkjGXQuLJ83eqLA8nvLGAHRXGQShlsmM9t4mONVWy6w1vd+4l5YLoc2dIOx xxdmX9nv4wzY2vdrTSy4oYqrQuQiI9d/4YLB+F3UXinMB3quwdvGLesuv4HhXWMd/okk PjzQ== 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=F33N57sAf+wp/fVCaGOBBnoIR6diNc3lH+anQmNYRYY=; b=MwrRG0mqDD34ykKQMwAwkywFY9aiYHu85ZluMsj9pQgwZV+G/zXEybIeYZv7FuOBjj alTIU3AtAw+FU9yjr1KfwqNGCLSqRwATC/kimDAsndOPq6xsx/8ooP01rHIyeUFADCZ3 BP3zuuIYBbd+ihwv5CXrknyu42f3FuKNFyrSZ3PqfbhvqGYUDJsZVsoqlpm0VDDPVW3g nq0pxuwkCjfj8PAHk58GIebqB0xT9UmCcANABtG2uUJwCe8xAenAvTh5qRgULLbrKb5F Ln1Zn9egf7XNW3nvEAgaXpqlDiMa9re5Ow5CaVNwNbAeXZAtKUjW79P6oPCrrODtFnty UhSQ== X-Gm-Message-State: AElRT7GVX9rM094VU67qfl4nwHVcbem/a3IQ0howr7lQvAiou/njkyCe sUIQRexm/3FKPtw2SKj10Ok= X-Google-Smtp-Source: AIpwx4/XMzDdRn7dpLLiKqLCG+J4fQE5IR4HbzoGBC3Z/ZZlSLuS6/lJTpqN2Tqp5zSdo10MfRVFxw== X-Received: by 2002:a17:902:6884:: with SMTP id i4-v6mr2998173plk.259.1522228252183; Wed, 28 Mar 2018 02:10:52 -0700 (PDT) Received: from localhost.localdomain ([203.205.141.38]) by smtp.gmail.com with ESMTPSA id q9sm5590648pgs.89.2018.03.28.02.10.49 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Wed, 28 Mar 2018 02:10:51 -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 v2 09/10] migration: introduce save_normal_page() Date: Tue, 27 Mar 2018 17:10:42 +0800 Message-Id: <20180327091043.30220-10-xiaoguangrong@tencent.com> X-Mailer: git-send-email 2.14.3 In-Reply-To: <20180327091043.30220-1-xiaoguangrong@tencent.com> References: <20180327091043.30220-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 771763985d..e71a9aee11 100644 --- a/migration/ram.c +++ b/migration/ram.c @@ -1014,6 +1014,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 * @@ -1054,18 +1082,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(); @@ -1196,14 +1213,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); }