From patchwork Fri Feb 5 13:56:49 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Amit Shah X-Patchwork-Id: 8234601 Return-Path: X-Original-To: patchwork-qemu-devel@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork2.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.29.136]) by patchwork2.web.kernel.org (Postfix) with ESMTP id 4BE13BEEE5 for ; Fri, 5 Feb 2016 13:59:25 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 9050B20389 for ; Fri, 5 Feb 2016 13:59:24 +0000 (UTC) Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) (using TLSv1 with cipher AES256-SHA (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 9FE50202F8 for ; Fri, 5 Feb 2016 13:59:23 +0000 (UTC) Received: from localhost ([::1]:48459 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1aRgux-0004oF-49 for patchwork-qemu-devel@patchwork.kernel.org; Fri, 05 Feb 2016 08:59:23 -0500 Received: from eggs.gnu.org ([2001:4830:134:3::10]:54353) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1aRgsv-0001JS-4Z for qemu-devel@nongnu.org; Fri, 05 Feb 2016 08:57:21 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1aRgss-000306-Si for qemu-devel@nongnu.org; Fri, 05 Feb 2016 08:57:16 -0500 Received: from mx1.redhat.com ([209.132.183.28]:41114) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1aRgss-000301-Fa for qemu-devel@nongnu.org; Fri, 05 Feb 2016 08:57:14 -0500 Received: from int-mx09.intmail.prod.int.phx2.redhat.com (int-mx09.intmail.prod.int.phx2.redhat.com [10.5.11.22]) by mx1.redhat.com (Postfix) with ESMTPS id 085993CB289; Fri, 5 Feb 2016 13:57:13 +0000 (UTC) Received: from localhost (dhcp193-102.pnq.redhat.com [10.65.193.102]) by int-mx09.intmail.prod.int.phx2.redhat.com (8.14.4/8.14.4) with ESMTP id u15DvCMP003842; Fri, 5 Feb 2016 08:57:13 -0500 From: Amit Shah To: Peter Maydell Date: Fri, 5 Feb 2016 19:26:49 +0530 Message-Id: In-Reply-To: References: In-Reply-To: References: X-Scanned-By: MIMEDefang 2.68 on 10.5.11.22 X-detected-operating-system: by eggs.gnu.org: GNU/Linux 3.x X-Received-From: 209.132.183.28 Cc: qemu list , Amit Shah , zhanghailiang , "Dr. David Alan Gilbert" , Juan Quintela Subject: [Qemu-devel] [PULL 4/9] migration/ram: Fix some helper functions' parameter to use PageSearchStatus X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+patchwork-qemu-devel=patchwork.kernel.org@nongnu.org Sender: qemu-devel-bounces+patchwork-qemu-devel=patchwork.kernel.org@nongnu.org X-Spam-Status: No, score=-6.9 required=5.0 tests=BAYES_00, RCVD_IN_DNSWL_HI, UNPARSEABLE_RELAY autolearn=unavailable version=3.3.1 X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on mail.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP From: zhanghailiang Some helper functions use parameters 'RAMBlock *block' and 'ram_addr_t *offset', We can use 'PageSearchStatus *pss' directly instead, with this change, we can reduce the number of parameters for these helper function, also it is easily to add new parameters for these helper functions. Signed-off-by: zhanghailiang Reviewed-by: Dr. David Alan Gilbert Reviewed-by: Amit Shah Message-Id: <1452829066-9764-5-git-send-email-zhang.zhanghailiang@huawei.com> Signed-off-by: Amit Shah --- migration/ram.c | 33 +++++++++++++++++++-------------- 1 file changed, 19 insertions(+), 14 deletions(-) diff --git a/migration/ram.c b/migration/ram.c index b541ceb..3cdfea4 100644 --- a/migration/ram.c +++ b/migration/ram.c @@ -729,7 +729,7 @@ static int save_zero_page(QEMUFile *f, RAMBlock *block, ram_addr_t offset, * @last_stage: if we are at the completion stage * @bytes_transferred: increase it with the number of transferred bytes */ -static int ram_save_page(QEMUFile *f, RAMBlock* block, ram_addr_t offset, +static int ram_save_page(QEMUFile *f, PageSearchStatus *pss, bool last_stage, uint64_t *bytes_transferred) { int pages = -1; @@ -738,6 +738,8 @@ static int ram_save_page(QEMUFile *f, RAMBlock* block, ram_addr_t offset, uint8_t *p; int ret; bool send_async = true; + RAMBlock *block = pss->block; + ram_addr_t offset = pss->offset; p = block->host + offset; @@ -912,14 +914,16 @@ static int compress_page_with_multi_thread(QEMUFile *f, RAMBlock *block, * @last_stage: if we are at the completion stage * @bytes_transferred: increase it with the number of transferred bytes */ -static int ram_save_compressed_page(QEMUFile *f, RAMBlock *block, - ram_addr_t offset, bool last_stage, +static int ram_save_compressed_page(QEMUFile *f, PageSearchStatus *pss, + bool last_stage, uint64_t *bytes_transferred) { int pages = -1; uint64_t bytes_xmit; uint8_t *p; int ret; + RAMBlock *block = pss->block; + ram_addr_t offset = pss->offset; p = block->host + offset; @@ -1229,7 +1233,7 @@ err: * Returns: Number of pages written. */ static int ram_save_target_page(MigrationState *ms, QEMUFile *f, - RAMBlock *block, ram_addr_t offset, + PageSearchStatus *pss, bool last_stage, uint64_t *bytes_transferred, ram_addr_t dirty_ram_abs) @@ -1240,11 +1244,11 @@ static int ram_save_target_page(MigrationState *ms, QEMUFile *f, if (migration_bitmap_clear_dirty(dirty_ram_abs)) { unsigned long *unsentmap; if (compression_switch && migrate_use_compression()) { - res = ram_save_compressed_page(f, block, offset, + res = ram_save_compressed_page(f, pss, last_stage, bytes_transferred); } else { - res = ram_save_page(f, block, offset, last_stage, + res = ram_save_page(f, pss, last_stage, bytes_transferred); } @@ -1260,7 +1264,7 @@ static int ram_save_target_page(MigrationState *ms, QEMUFile *f, * to the stream. */ if (res > 0) { - last_sent_block = block; + last_sent_block = pss->block; } } @@ -1284,26 +1288,27 @@ static int ram_save_target_page(MigrationState *ms, QEMUFile *f, * @bytes_transferred: increase it with the number of transferred bytes * @dirty_ram_abs: Address of the start of the dirty page in ram_addr_t space */ -static int ram_save_host_page(MigrationState *ms, QEMUFile *f, RAMBlock *block, - ram_addr_t *offset, bool last_stage, +static int ram_save_host_page(MigrationState *ms, QEMUFile *f, + PageSearchStatus *pss, + bool last_stage, uint64_t *bytes_transferred, ram_addr_t dirty_ram_abs) { int tmppages, pages = 0; do { - tmppages = ram_save_target_page(ms, f, block, *offset, last_stage, + tmppages = ram_save_target_page(ms, f, pss, last_stage, bytes_transferred, dirty_ram_abs); if (tmppages < 0) { return tmppages; } pages += tmppages; - *offset += TARGET_PAGE_SIZE; + pss->offset += TARGET_PAGE_SIZE; dirty_ram_abs += TARGET_PAGE_SIZE; - } while (*offset & (qemu_host_page_size - 1)); + } while (pss->offset & (qemu_host_page_size - 1)); /* The offset we leave with is the last one we looked at */ - *offset -= TARGET_PAGE_SIZE; + pss->offset -= TARGET_PAGE_SIZE; return pages; } @@ -1351,7 +1356,7 @@ static int ram_find_and_save_block(QEMUFile *f, bool last_stage, } if (found) { - pages = ram_save_host_page(ms, f, pss.block, &pss.offset, + pages = ram_save_host_page(ms, f, &pss, last_stage, bytes_transferred, dirty_ram_abs); }