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: 10277869 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id DBE63602BD for ; Tue, 13 Mar 2018 07:58:11 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id C78E128BDA for ; Tue, 13 Mar 2018 07:58:11 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id BC6DA28BE4; Tue, 13 Mar 2018 07:58:11 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-7.0 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, FREEMAIL_FROM, RCVD_IN_DNSWL_HI autolearn=ham version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 612F528BDA for ; Tue, 13 Mar 2018 07:58:11 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752187AbeCMH6J (ORCPT ); Tue, 13 Mar 2018 03:58:09 -0400 Received: from mail-pf0-f173.google.com ([209.85.192.173]:41967 "EHLO mail-pf0-f173.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752148AbeCMH6I (ORCPT ); Tue, 13 Mar 2018 03:58:08 -0400 Received: by mail-pf0-f173.google.com with SMTP id f80so5533614pfa.8 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=lMLSqXmkmVoVUUaBvSS6ppa+p7uMnCtIZUZjGAcR9Qn8DKmR5OGclxtiOGNhG5tsap PAcyEeo1sfry9c253RsN9FZTXKDH9quC+0k+bZAkKqdrFVOef3fE7LVSlVgpX+fRxS0j iYAaO3Ai92Q38OTm537xIa/H9RxzFbDF4FcvpdUI7720USxQtlvvMImVTbZ8BSqI/UuD sTw1lJ8iO0qrj9EYxoXs5/HyHUbZZuBDmdYa93ioruXAP/Q89iPawIVxsRcXYxiERTst oHmMkwZmNHbQxIP5GtIhlpOP6aSfPIxUUuK1FyKWrxiBnaDUBy7uGhJaKzTKUMh9no2l pzOA== X-Gm-Message-State: AElRT7F4kKObDq+6WkXeQA7q5qLHZPPTUNsPaIQeawD0ZIvMGt5Y1/b4 7FO+dAmbL2O/2GdjU3qwEkfn8g== 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 Cc: qemu-devel@nongnu.org, kvm@vger.kernel.org, Xiao Guangrong Subject: [PATCH 5/8] migration: move calling control_save_page to the common place 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> Sender: kvm-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: kvm@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP 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; }