From patchwork Fri Mar 30 07:51:25 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Xiao Guangrong X-Patchwork-Id: 10317307 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 BEF8C60467 for ; Fri, 30 Mar 2018 07:51:35 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id B38A22A17F for ; Fri, 30 Mar 2018 07:51:35 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id A6E932A55F; Fri, 30 Mar 2018 07:51:35 +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 26F7D2A17F for ; Fri, 30 Mar 2018 07:51:35 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751312AbeC3Hvd (ORCPT ); Fri, 30 Mar 2018 03:51:33 -0400 Received: from mail-pg0-f68.google.com ([74.125.83.68]:35608 "EHLO mail-pg0-f68.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752077AbeC3Hva (ORCPT ); Fri, 30 Mar 2018 03:51:30 -0400 Received: by mail-pg0-f68.google.com with SMTP id j3so4671886pgf.2 for ; Fri, 30 Mar 2018 00:51:30 -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=/ZZQLnC9y24MXAI8Da5LGtqV6MHDiGUV+fTyxg3VeSw=; b=VAiKecXbrcjVXQ2ok143KSidvX2BvjimmqOX0TUWc9hZVzBFReONLXLPL7klX9UdVo zuNumchQTk5KlVmyTVd86dFTx/f4EpCmqxLl96ZAT4IjUQuf2XdU2oLs8+BB3BnavqIG tcJAhyI5nePqWB1SL0rTRp4n76UewSTtbizPc3RCrQjQgbPPQSdSrrPmkGOYuSKlYMOP NNbxZhjCbjSWnsCpOy5XAafeDCbRGkemwGEAMJ+GaVgUhzGM1bqzeUKjM6v8JJQkqhSI suQF8jGut7wkT6toOFhinajQTPZNG8D9ZESuzbjsjboYQfFumeupHsyKCit5WQDIGXPp tYaw== 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=/ZZQLnC9y24MXAI8Da5LGtqV6MHDiGUV+fTyxg3VeSw=; b=H7MBgG2BhsnWQNYB+P2G9m8qcF04wxsQ8atT7uaQbFmFf3PkZnEa6hNvCISnaExHGT L+HmihFrrJ79jW7YMVF5qJ4NdcKhl0pHluc5VjglCtVjwdIA0ZAvKcYY7Tse4nEyfKzO f8/H2sohtK0xSWWmqST6kBBnMFYGPB5WNIlUOGwMQzcgnZMHzgeHMdUQyGLNespw/3rJ sWQp9xMadVR0gehCPYR/W303/j/9kfp+ezDdSJpqf//IIH15gmbi8Se2IcfnHQoM3lkH +zN0O2f9Xf5Im5N8Bp7LhH0GgvPnPQctm1+PQhOiouluQ2y0/qcBuYLcVL0dY+BzRj2c tbqQ== X-Gm-Message-State: AElRT7HA+i6DmEU/8YL9zZQZIi02YSqrUNoQSbgoNYmGc4dTYra7D+CO u2K6KS5KqzWn6H7O2nGKbVw= X-Google-Smtp-Source: AIpwx499QewCw8XsiB+XE4Ny9hS7XIFQeNNQg93yKU0F1VYeZ78Nl1FMDWOt2yEl8CdItfDSY8FLdg== X-Received: by 2002:a17:902:7003:: with SMTP id y3-v6mr1544141plk.212.1522396289858; Fri, 30 Mar 2018 00:51:29 -0700 (PDT) Received: from localhost.localdomain ([203.205.141.38]) by smtp.gmail.com with ESMTPSA id r75sm16557107pfb.98.2018.03.30.00.51.26 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Fri, 30 Mar 2018 00:51:29 -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, dgilbert@redhat.com, peterx@redhat.com, jiang.biao2@zte.com.cn, wei.w.wang@intel.com, Xiao Guangrong Subject: [PATCH v3 07/10] migration: move calling control_save_page to the common place Date: Fri, 30 Mar 2018 15:51:25 +0800 Message-Id: <20180330075128.26919-8-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> 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 Reviewed-by: Peter Xu Signed-off-by: Xiao Guangrong --- migration/ram.c | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/migration/ram.c b/migration/ram.c index c3628b020e..e0caf7182b 100644 --- a/migration/ram.c +++ b/migration/ram.c @@ -1037,10 +1037,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) { @@ -1198,10 +1194,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 @@ -1489,6 +1481,14 @@ err: static int ram_save_target_page(RAMState *rs, PageSearchStatus *pss, bool last_stage) { + RAMBlock *block = pss->block; + ram_addr_t offset = pss->page << TARGET_PAGE_BITS; + int res; + + if (control_save_page(rs, block, offset, &res)) { + return res; + } + /* * If xbzrle is on, stop using the data compression after first * round of migration even if compression is enabled. In theory,