From patchwork Tue Mar 13 07:57:36 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Xiao Guangrong X-Patchwork-Id: 885021 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="Bq9FSyJK"; 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 400nRP1Tm1z9sSf for ; Tue, 13 Mar 2018 19:03:29 +1100 (AEDT) Received: from localhost ([::1]:37462 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1eveu7-0006tA-34 for incoming@patchwork.ozlabs.org; Tue, 13 Mar 2018 04:03:27 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:42989) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1eveoz-0002yi-Pa for qemu-devel@nongnu.org; Tue, 13 Mar 2018 03:58:12 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1eveoy-0007f5-Un for qemu-devel@nongnu.org; Tue, 13 Mar 2018 03:58:09 -0400 Received: from mail-pf0-x22d.google.com ([2607:f8b0:400e:c00::22d]:34464) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1eveoy-0007eP-Ou for qemu-devel@nongnu.org; Tue, 13 Mar 2018 03:58:08 -0400 Received: by mail-pf0-x22d.google.com with SMTP id j20so5540949pfi.1 for ; Tue, 13 Mar 2018 00:58:08 -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=+cgEGzYx+EI4jtofU/Be0YPAm0jsFU8XENuzH7MI8Bs=; b=Bq9FSyJKUackhWGsxDuLgsePvi+ywphA5WALwVytOYnLGE7LhoKt9jtu0XHw3bnuiS IjwNNg+Eg5qXTesgzZIj0oY0G3DlGq30t/jPDJxYKopzi3SMX/b2y4W7fURvyux9y/2e 19Nf75EqHCSWYryJPJbkB5hBSatwH283aVidJoyqAsWocfgma5gkNoyyTZtVjCezg5Sx JsgHkbNCZd2rDVRhKHPUQsQSNWwYYAGIG74efLXpOmJW5EgTb+u80Tkv0zRz6c2EDa6A aALMfKR9IYoPyrKNcLBU90Bs9SrHxkxnb0XbEuSF+k3vDqMmDbo312Oc/YIuQM8cwObm BQPQ== 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=+cgEGzYx+EI4jtofU/Be0YPAm0jsFU8XENuzH7MI8Bs=; b=FuhhMlNaE+V0yptS/QdRYxWwL+dpbXFAuNYoqNqX2IqzHEvWEbRPBo9/dvkXbhHXD6 CbFYxq7SAGzmmHrzCAFwc1RzS0jgpXkjIEIhW26rFoKdN92mejFRJ2/7EBYPHQb3tXbL AiuGE2BInD58j/ansnx9sHRLYm6SKECawhfH351GVluH4AAZuKXdNqTrJ5CENVgCgp1K YgLorO9dPCwW10Ck0NrQODvP5+eHnqerFcY0fMHOhWdywVkTvAVlgApGjCo2vu88uibP BfJAM1zmKV64JsWN6MRTePONVEtKJ6xJ77WayqwBwNFqrNWMlnG59wOT4WKoIc8+1+W9 TDdA== X-Gm-Message-State: AElRT7FayLARvMHrFFakAKWMM+b2L/EVKxxZpEW7aNs0W4jo9PmwmRqG l61IzNfTKUqttAQF90um1wA= X-Google-Smtp-Source: AG47ELud9LMLtGgZLWvFHvs5oV8fGRcNYCr3yeWXvSLUFHzwISVbcsWS3YbiNO9A+NeanTHo4C79qw== X-Received: by 10.99.111.130 with SMTP id k124mr9170164pgc.236.1520927887868; Tue, 13 Mar 2018 00:58:07 -0700 (PDT) Received: from localhost.localdomain ([203.205.141.35]) by smtp.gmail.com with ESMTPSA id x4sm16756537pgv.72.2018.03.13.00.58.05 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Tue, 13 Mar 2018 00:58:07 -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:36 +0800 Message-Id: <20180313075739.11194-6-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::22d Subject: [Qemu-devel] [PATCH 5/8] migration: move calling control_save_page to the common place 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 The function is called by both ram_save_page and ram_save_target_page, so move it to the common caller to cleanup the code Signed-off-by: Xiao Guangrong Reviewed-by: Peter Xu --- migration/ram.c | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/migration/ram.c b/migration/ram.c index e7b8b14c3c..839665d866 100644 --- a/migration/ram.c +++ b/migration/ram.c @@ -1020,10 +1020,6 @@ static int ram_save_page(RAMState *rs, PageSearchStatus *pss, bool last_stage) p = block->host + offset; trace_ram_save_page(block->idstr, (uint64_t)offset, p); - if (control_save_page(rs, block, offset, &pages)) { - return pages; - } - XBZRLE_cache_lock(); pages = save_zero_page(rs, block, offset); if (pages > 0) { @@ -1176,10 +1172,6 @@ static int ram_save_compressed_page(RAMState *rs, PageSearchStatus *pss, p = block->host + offset; - if (control_save_page(rs, block, offset, &pages)) { - return pages; - } - /* When starting the process of a new block, the first page of * the block should be sent out before other pages in the same * block, and all the pages in last block should have been sent @@ -1472,6 +1464,13 @@ static int ram_save_target_page(RAMState *rs, PageSearchStatus *pss, /* Check the pages is dirty and if it is send it */ if (migration_bitmap_clear_dirty(rs, pss->block, pss->page)) { + RAMBlock *block = pss->block; + ram_addr_t offset = pss->page << TARGET_PAGE_BITS; + + if (control_save_page(rs, block, offset, &res)) { + goto page_saved; + } + /* * If xbzrle is on, stop using the data compression after first * round of migration even if compression is enabled. In theory, @@ -1484,6 +1483,7 @@ static int ram_save_target_page(RAMState *rs, PageSearchStatus *pss, res = ram_save_page(rs, pss, last_stage); } +page_saved: if (res < 0) { return res; }