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: 885024 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="ZpqB8vUU"; 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 400nSX5KGWz9sSf for ; Tue, 13 Mar 2018 19:04:28 +1100 (AEDT) Received: from localhost ([::1]:37464 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1evev4-0007pe-KJ for incoming@patchwork.ozlabs.org; Tue, 13 Mar 2018 04:04:26 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:43041) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1evep5-00033m-AO for qemu-devel@nongnu.org; Tue, 13 Mar 2018 03:58:19 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1evep4-0007m1-8J for qemu-devel@nongnu.org; Tue, 13 Mar 2018 03:58:15 -0400 Received: from mail-pf0-x22f.google.com ([2607:f8b0:400e:c00::22f]:45515) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1evep4-0007ku-1G for qemu-devel@nongnu.org; Tue, 13 Mar 2018 03:58:14 -0400 Received: by mail-pf0-x22f.google.com with SMTP id h19so5528900pfd.12 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=AGAvuE4KAqtAwF4dYeJ1qeE11zUrxpIn0aa58d3nWLZyhAidU9FQ9+Y3iE8zutNuBi 4q259XMkOW51tmlZLiNXQhir0IjWkRuzDQybcQuw6sAzGXC69bvlMVvlBdHg7Y8wyN2k gR9vXxfhh8Ueo4ZjZHULpmh9HKX4cxudMQ5exSka2CCIuTwK4yUmXzhdGD29ITLECTyy SQZnyy3uFw+ccNsBtdrJjPQBUQuTdPnFFWoEUkk1352lF8VHGo5orqz1L88SHHNS8hH8 NT22oKFXCjLA6wqWA/jkau5HZ4LUtdkpv1kvAzBrHB3shRe2AEDF/7YI/RR+MtVd5/O+ h+LA== X-Gm-Message-State: AElRT7HkgdUKu2xZiGzNJGTscEg5EnXDeuYGMJRnmwQQDDuJ0vPiYeHt oi81sqbJ56yvKQdf/OCO2O8= 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 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> X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 2607:f8b0:400e:c00::22f Subject: [Qemu-devel] [PATCH 7/8] 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: Xiao Guangrong , qemu-devel@nongnu.org, kvm@vger.kernel.org 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 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); }