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: 892039 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=pass (mailfrom) smtp.mailfrom=nongnu.org (client-ip=2001:4830:134:3::11; helo=lists.gnu.org; envelope-from=qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org; receiver=) Authentication-Results: ozlabs.org; dmarc=fail (p=none dis=none) header.from=gmail.com Authentication-Results: ozlabs.org; dkim=fail reason="signature verification failed" (2048-bit key; unprotected) header.d=gmail.com header.i=@gmail.com header.b="GOlo2Uih"; dkim-atps=neutral Received: from lists.gnu.org (lists.gnu.org [IPv6:2001:4830:134:3::11]) (using TLSv1 with cipher AES256-SHA (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 40B2MR5NrZz9s08 for ; Wed, 28 Mar 2018 20:17:06 +1100 (AEDT) Received: from localhost ([::1]:38181 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1f17CW-0005k3-Pg for incoming@patchwork.ozlabs.org; Wed, 28 Mar 2018 05:17:00 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:56758) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1f176c-00015i-4B for qemu-devel@nongnu.org; Wed, 28 Mar 2018 05:10:57 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1f176b-0005Cf-2i for qemu-devel@nongnu.org; Wed, 28 Mar 2018 05:10:54 -0400 Received: from mail-pl0-x22c.google.com ([2607:f8b0:400e:c01::22c]:39038) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1f176a-0005CN-Th for qemu-devel@nongnu.org; Wed, 28 Mar 2018 05:10:53 -0400 Received: by mail-pl0-x22c.google.com with SMTP id s24-v6so1201805plq.6 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=s75ZQSG5CtOSSjPqSiTuuEmQoGOSHihLRPXewydcXn/Y25/h98ZVIf5ooXCljM2af0 l9gE5/pNwF4JtEkG9cqH/1Podz25BH/7COcoPFk965Culs9hRht2dMiBOhqVtdhdnlZW zBWBqb0OyrrMbaPY+mAJnxi5t3CSyknFOa6XDx4WxIojQnmZWhVvcn9KaE9xrjgtAdA0 XcQI55eGpttKUUnCUt04qsVmmr9JgRTmHXEGbRE+NHyGg4LucCB6Aex4arQhCK/FszJC Ltjv6+FRV0jg3GGHw2lxse6iBokeUDmt93Q0FoGBGtpVUw4+g965VBFVf18uEDY7BPgk c3ng== X-Gm-Message-State: AElRT7FBKHq9/pIFHIEHh/+2WA0CKjF7gGBVk3R2KP1Uy3t+nD+hcOFe Y4zBAu1Wy8Cv2jJCJSBXEoM= 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 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> X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 2607:f8b0:400e:c01::22c Subject: [Qemu-devel] [PATCH v2 09/10] migration: introduce save_normal_page() 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: kvm@vger.kernel.org, Xiao Guangrong , qemu-devel@nongnu.org, peterx@redhat.com, dgilbert@redhat.com, wei.w.wang@intel.com, jiang.biao2@zte.com.cn Errors-To: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Sender: "Qemu-devel" 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); }