From nobody Tue Oct 28 01:58:02 2025 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) client-ip=208.118.235.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Authentication-Results: mx.zohomail.com; dkim=fail; spf=pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail(p=none dis=none) header.from=gmail.com Return-Path: Received: from lists.gnu.org (208.118.235.17 [208.118.235.17]) by mx.zohomail.com with SMTPS id 1522228708110582.1426044885209; Wed, 28 Mar 2018 02:18:28 -0700 (PDT) Received: from localhost ([::1]:38185 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1f17Dl-0006eb-Mj for importer@patchew.org; Wed, 28 Mar 2018 05:18:17 -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) 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) 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) 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+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) X-ZohoMail: RDKM_2 RSF_0 Z_629925259 SPT_0 Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" 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; } =20 +/* + * 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 offs= et, + uint8_t *buf, bool async) +{ + ram_counters.transferred +=3D save_page_header(rs, rs->f, block, + offset | RAM_SAVE_FLAG_PA= GE); + 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 +=3D 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, PageSearchSta= tus *pss, bool last_stage) =20 /* XBZRLE overflow or normal page */ if (pages =3D=3D -1) { - ram_counters.transferred +=3D - 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 +=3D TARGET_PAGE_SIZE; - pages =3D 1; - ram_counters.normal++; + pages =3D save_normal_page(rs, block, offset, p, send_async); } =20 XBZRLE_cache_unlock(); @@ -1196,14 +1213,7 @@ static int ram_save_compressed_page(RAMState *rs, Pa= geSearchStatus *pss, * we post it as normal page as compression will take much * CPU resource. */ - ram_counters.transferred +=3D 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 +=3D TARGET_PAGE_SIZE; - ram_counters.normal++; - pages =3D 1; + pages =3D save_normal_page(rs, block, offset, p, true); } else { pages =3D compress_page_with_multi_thread(rs, block, offset); } --=20 2.14.3