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: 893175 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="p5YThq44"; 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 40CDVr2v6jz9s1r for ; Fri, 30 Mar 2018 18:57:39 +1100 (AEDT) Received: from localhost ([::1]:41031 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1f1oun-0007LD-1i for incoming@patchwork.ozlabs.org; Fri, 30 Mar 2018 03:57:37 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:56405) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1f1op1-000292-0C for qemu-devel@nongnu.org; Fri, 30 Mar 2018 03:51:39 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1f1ooz-0007ie-I6 for qemu-devel@nongnu.org; Fri, 30 Mar 2018 03:51:39 -0400 Received: from mail-pf0-x229.google.com ([2607:f8b0:400e:c00::229]:44557) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1f1ooz-0007iY-Bj for qemu-devel@nongnu.org; Fri, 30 Mar 2018 03:51:37 -0400 Received: by mail-pf0-x229.google.com with SMTP id m68so4981236pfm.11 for ; Fri, 30 Mar 2018 00:51:37 -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=pQdOPDJtOVfKgQIrEdy/8X6EJwsuwmAXj/fOmMnNad9APZVCnJOkB5OR4mgvBBJ3pe n8ttlmPkoKhquN4+3sRnlUqcbOcv/rGIJZyFYoV3T/U58qLu373qdq/nmyJPRjuEswjD NAfEExpCbJfUfo0FrlCDUQkWs9H8WuyzVTZMfiqt8S32GM2FEaag/AR0Pzyj0nYs82rl m5S5IGiZJZ49cNyct8hiyW5N6kd66qZVS85pdBBIHF6mx06IFGv276/sf7kdt9v4aDHn 1i3oASKcz2a8aiJ4+ZLWC6cYeQjyfg18yX0+V1IEym6tHCFIQtCrW0XFLdsp5hKkU2ji RjPA== X-Gm-Message-State: AElRT7GSZN7NWSSrydgcU/Ww7b9v16654MRiiLR8AJSI8NyIIYQt5koX yDSXT/NXVJTi7BQHoZi1QZI= 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 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> X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 2607:f8b0:400e:c00::229 Subject: [Qemu-devel] [PATCH v3 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 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); }