From nobody Thu Nov 6 15:47:51 2025 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) client-ip=208.118.235.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Authentication-Results: mx.zoho.com; spf=pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; Return-Path: Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) by mx.zohomail.com with SMTPS id 1489586822183727.4897375592371; Wed, 15 Mar 2017 07:07:02 -0700 (PDT) Received: from localhost ([::1]:37472 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1co9Zo-0004IN-ON for importer@patchew.org; Wed, 15 Mar 2017 10:06:56 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:53925) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1co9KU-0007cj-2h for qemu-devel@nongnu.org; Wed, 15 Mar 2017 09:51:07 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1co9KR-0003p0-KV for qemu-devel@nongnu.org; Wed, 15 Mar 2017 09:51:06 -0400 Received: from mx1.redhat.com ([209.132.183.28]:53834) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1co9KR-0003nI-Ad for qemu-devel@nongnu.org; Wed, 15 Mar 2017 09:51:03 -0400 Received: from int-mx14.intmail.prod.int.phx2.redhat.com (int-mx14.intmail.prod.int.phx2.redhat.com [10.5.11.27]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 49CDC80F8E for ; Wed, 15 Mar 2017 13:51:03 +0000 (UTC) Received: from secure.mitica (ovpn-116-230.ams2.redhat.com [10.36.116.230]) by int-mx14.intmail.prod.int.phx2.redhat.com (8.14.4/8.14.4) with ESMTP id v2FDoNUu002305; Wed, 15 Mar 2017 09:51:01 -0400 DMARC-Filter: OpenDMARC Filter v1.3.2 mx1.redhat.com 49CDC80F8E Authentication-Results: ext-mx03.extmail.prod.ext.phx2.redhat.com; dmarc=none (p=none dis=none) header.from=redhat.com Authentication-Results: ext-mx03.extmail.prod.ext.phx2.redhat.com; spf=pass smtp.mailfrom=quintela@redhat.com DKIM-Filter: OpenDKIM Filter v2.11.0 mx1.redhat.com 49CDC80F8E From: Juan Quintela To: qemu-devel@nongnu.org Date: Wed, 15 Mar 2017 14:50:15 +0100 Message-Id: <20170315135021.6978-26-quintela@redhat.com> In-Reply-To: <20170315135021.6978-1-quintela@redhat.com> References: <20170315135021.6978-1-quintela@redhat.com> X-Scanned-By: MIMEDefang 2.68 on 10.5.11.27 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.27]); Wed, 15 Mar 2017 13:51:03 +0000 (UTC) X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] [fuzzy] X-Received-From: 209.132.183.28 Subject: [Qemu-devel] [PATCH 25/31] ram: Use the RAMState bytes_transferred parameter 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: amit.shah@redhat.com, dgilbert@redhat.com Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail: RSF_0 Z_629925259 SPT_0 Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Somewhere it was passed by reference, just use it from RAMState. Signed-off-by: Juan Quintela Reviewed-by: Dr. David Alan Gilbert --- migration/ram.c | 77 ++++++++++++++++++++---------------------------------= ---- 1 file changed, 27 insertions(+), 50 deletions(-) diff --git a/migration/ram.c b/migration/ram.c index f9933b2..9c9533d 100644 --- a/migration/ram.c +++ b/migration/ram.c @@ -477,12 +477,10 @@ static void xbzrle_cache_zero_page(RAMState *rs, ram_= addr_t current_addr) * @block: block that contains the page we want to send * @offset: offset inside the block for the page * @last_stage: if we are at the completion stage - * @bytes_transferred: increase it with the number of transferred bytes */ static int save_xbzrle_page(QEMUFile *f, RAMState *rs, uint8_t **current_d= ata, ram_addr_t current_addr, RAMBlock *block, - ram_addr_t offset, bool last_stage, - uint64_t *bytes_transferred) + ram_addr_t offset, bool last_stage) { int encoded_len =3D 0, bytes_xbzrle; uint8_t *prev_cached_page; @@ -538,7 +536,7 @@ static int save_xbzrle_page(QEMUFile *f, RAMState *rs, = uint8_t **current_data, bytes_xbzrle +=3D encoded_len + 1 + 2; rs->xbzrle_pages++; rs->xbzrle_bytes +=3D bytes_xbzrle; - *bytes_transferred +=3D bytes_xbzrle; + rs->bytes_transferred +=3D bytes_xbzrle; =20 return 1; } @@ -701,20 +699,18 @@ static void migration_bitmap_sync(RAMState *rs) * @block: block that contains the page we want to send * @offset: offset inside the block for the page * @p: pointer to the page - * @bytes_transferred: increase it with the number of transferred bytes */ static int save_zero_page(RAMState *rs, QEMUFile *f, RAMBlock *block, - ram_addr_t offset, - uint8_t *p, uint64_t *bytes_transferred) + ram_addr_t offset, uint8_t *p) { int pages =3D -1; =20 if (is_zero_range(p, TARGET_PAGE_SIZE)) { rs->zero_pages++; - *bytes_transferred +=3D save_page_header(f, block, - offset | RAM_SAVE_FLAG_COMP= RESS); + rs->bytes_transferred +=3D save_page_header(f, block, + offset | RAM_SAVE_FLAG_C= OMPRESS); qemu_put_byte(f, 0); - *bytes_transferred +=3D 1; + rs->bytes_transferred +=3D 1; pages =3D 1; } =20 @@ -745,11 +741,9 @@ static void ram_release_pages(MigrationState *ms, cons= t char *block_name, * @block: block that contains the page we want to send * @offset: offset inside the block for the page * @last_stage: if we are at the completion stage - * @bytes_transferred: increase it with the number of transferred bytes */ static int ram_save_page(RAMState *rs, MigrationState *ms, QEMUFile *f, - PageSearchStatus *pss, bool last_stage, - uint64_t *bytes_transferred) + PageSearchStatus *pss, bool last_stage) { int pages =3D -1; uint64_t bytes_xmit; @@ -767,7 +761,7 @@ static int ram_save_page(RAMState *rs, MigrationState *= ms, QEMUFile *f, ret =3D ram_control_save_page(f, block->offset, offset, TARGET_PAGE_SIZE, &bytes_xmit); if (bytes_xmit) { - *bytes_transferred +=3D bytes_xmit; + rs->bytes_transferred +=3D bytes_xmit; pages =3D 1; } =20 @@ -787,7 +781,7 @@ static int ram_save_page(RAMState *rs, MigrationState *= ms, QEMUFile *f, } } } else { - pages =3D save_zero_page(rs, f, block, offset, p, bytes_transferre= d); + pages =3D save_zero_page(rs, f, block, offset, p); if (pages > 0) { /* Must let xbzrle know, otherwise a previous (now 0'd) cached * page would be stale @@ -797,7 +791,7 @@ static int ram_save_page(RAMState *rs, MigrationState *= ms, QEMUFile *f, } else if (!rs->ram_bulk_stage && !migration_in_postcopy(ms) && migrate_use_xbzrle()) { pages =3D save_xbzrle_page(f, rs, &p, current_addr, block, - offset, last_stage, bytes_transferred= ); + offset, last_stage); if (!last_stage) { /* Can't send this cached data async, since the cache page * might get updated before it gets to the wire @@ -809,7 +803,7 @@ static int ram_save_page(RAMState *rs, MigrationState *= ms, QEMUFile *f, =20 /* XBZRLE overflow or normal page */ if (pages =3D=3D -1) { - *bytes_transferred +=3D save_page_header(f, block, + rs->bytes_transferred +=3D save_page_header(f, block, offset | RAM_SAVE_FLAG_PAGE= ); if (send_async) { qemu_put_buffer_async(f, p, TARGET_PAGE_SIZE, @@ -818,7 +812,7 @@ static int ram_save_page(RAMState *rs, MigrationState *= ms, QEMUFile *f, } else { qemu_put_buffer(f, p, TARGET_PAGE_SIZE); } - *bytes_transferred +=3D TARGET_PAGE_SIZE; + rs->bytes_transferred +=3D TARGET_PAGE_SIZE; pages =3D 1; rs->norm_pages++; } @@ -886,8 +880,7 @@ static inline void set_compress_params(CompressParam *p= aram, RAMBlock *block, } =20 static int compress_page_with_multi_thread(RAMState *rs, QEMUFile *f, - RAMBlock *block, ram_addr_t off= set, - uint64_t *bytes_transferred) + RAMBlock *block, ram_addr_t off= set) { int idx, thread_count, bytes_xmit =3D -1, pages =3D -1; =20 @@ -904,7 +897,7 @@ static int compress_page_with_multi_thread(RAMState *rs= , QEMUFile *f, qemu_mutex_unlock(&comp_param[idx].mutex); pages =3D 1; rs->norm_pages++; - *bytes_transferred +=3D bytes_xmit; + rs->bytes_transferred +=3D bytes_xmit; break; } } @@ -930,12 +923,10 @@ static int compress_page_with_multi_thread(RAMState *= rs, QEMUFile *f, * @block: block that contains the page we want to send * @offset: offset inside the block for the page * @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(RAMState *rs, MigrationState *ms, QEMUFile *f, - PageSearchStatus *pss, bool last_stage, - uint64_t *bytes_transferred) + PageSearchStatus *pss, bool last_stage) { int pages =3D -1; uint64_t bytes_xmit =3D 0; @@ -949,7 +940,7 @@ static int ram_save_compressed_page(RAMState *rs, Migra= tionState *ms, ret =3D ram_control_save_page(f, block->offset, offset, TARGET_PAGE_SIZE, &bytes_xmit); if (bytes_xmit) { - *bytes_transferred +=3D bytes_xmit; + rs->bytes_transferred +=3D bytes_xmit; pages =3D 1; } if (ret !=3D RAM_SAVE_CONTROL_NOT_SUPP) { @@ -969,7 +960,7 @@ static int ram_save_compressed_page(RAMState *rs, Migra= tionState *ms, */ if (block !=3D rs->last_sent_block) { flush_compressed_data(rs, f); - pages =3D save_zero_page(rs, f, block, offset, p, bytes_transf= erred); + pages =3D save_zero_page(rs, f, block, offset, p); if (pages =3D=3D -1) { /* Make sure the first page is sent out before other pages= */ bytes_xmit =3D save_page_header(f, block, offset | @@ -977,7 +968,7 @@ static int ram_save_compressed_page(RAMState *rs, Migra= tionState *ms, blen =3D qemu_put_compression_data(f, p, TARGET_PAGE_SIZE, migrate_compress_level()); if (blen > 0) { - *bytes_transferred +=3D bytes_xmit + blen; + rs->bytes_transferred +=3D bytes_xmit + blen; rs->norm_pages++; pages =3D 1; } else { @@ -990,10 +981,9 @@ static int ram_save_compressed_page(RAMState *rs, Migr= ationState *ms, } } else { offset |=3D RAM_SAVE_FLAG_CONTINUE; - pages =3D save_zero_page(rs, f, block, offset, p, bytes_transf= erred); + pages =3D save_zero_page(rs, f, block, offset, p); if (pages =3D=3D -1) { - pages =3D compress_page_with_multi_thread(rs, f, block, of= fset, - bytes_transferred); + pages =3D compress_page_with_multi_thread(rs, f, block, of= fset); } else { ram_release_pages(ms, block->idstr, pss->offset, pages); } @@ -1256,7 +1246,6 @@ err: * @block: pointer to block that contains the page we want to send * @offset: offset inside the block for the page; * @last_stage: if we are at the completion stage - * @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 sp= ace * * Returns: Number of pages written. @@ -1264,7 +1253,6 @@ err: static int ram_save_target_page(RAMState *rs, MigrationState *ms, QEMUFile= *f, PageSearchStatus *pss, bool last_stage, - uint64_t *bytes_transferred, ram_addr_t dirty_ram_abs) { int res =3D 0; @@ -1273,12 +1261,9 @@ static int ram_save_target_page(RAMState *rs, Migrat= ionState *ms, QEMUFile *f, if (migration_bitmap_clear_dirty(rs, dirty_ram_abs)) { unsigned long *unsentmap; if (compression_switch && migrate_use_compression()) { - res =3D ram_save_compressed_page(rs, ms, f, pss, - last_stage, - bytes_transferred); + res =3D ram_save_compressed_page(rs, ms, f, pss, last_stage); } else { - res =3D ram_save_page(rs, ms, f, pss, last_stage, - bytes_transferred); + res =3D ram_save_page(rs, ms, f, pss, last_stage); } =20 if (res < 0) { @@ -1317,21 +1302,18 @@ static int ram_save_target_page(RAMState *rs, Migra= tionState *ms, QEMUFile *f, * @offset: offset inside the block for the page; updated to last target p= age * sent * @last_stage: if we are at the completion stage - * @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 sp= ace */ static int ram_save_host_page(RAMState *rs, MigrationState *ms, QEMUFile *= f, PageSearchStatus *pss, bool last_stage, - uint64_t *bytes_transferred, ram_addr_t dirty_ram_abs) { int tmppages, pages =3D 0; size_t pagesize =3D qemu_ram_pagesize(pss->block); =20 do { - tmppages =3D ram_save_target_page(rs, ms, f, pss, last_stage, - bytes_transferred, dirty_ram_abs); + tmppages =3D ram_save_target_page(rs, ms, f, pss, last_stage, dirt= y_ram_abs); if (tmppages < 0) { return tmppages; } @@ -1357,14 +1339,12 @@ static int ram_save_host_page(RAMState *rs, Migrati= onState *ms, QEMUFile *f, * @rs: The RAM state * @f: QEMUFile where to send the data * @last_stage: if we are at the completion stage - * @bytes_transferred: increase it with the number of transferred bytes * * On systems where host-page-size > target-page-size it will send all the * pages in a host page that are dirty. */ =20 -static int ram_find_and_save_block(RAMState *rs, QEMUFile *f, bool last_st= age, - uint64_t *bytes_transferred) +static int ram_find_and_save_block(RAMState *rs, QEMUFile *f, bool last_st= age) { PageSearchStatus pss; MigrationState *ms =3D migrate_get_current(); @@ -1396,9 +1376,7 @@ static int ram_find_and_save_block(RAMState *rs, QEMU= File *f, bool last_stage, } =20 if (found) { - pages =3D ram_save_host_page(rs, ms, f, &pss, - last_stage, bytes_transferred, - dirty_ram_abs); + pages =3D ram_save_host_page(rs, ms, f, &pss, last_stage, dirt= y_ram_abs); } } while (!pages && again); =20 @@ -2046,7 +2024,7 @@ static int ram_save_iterate(QEMUFile *f, void *opaque) while ((ret =3D qemu_file_rate_limit(f)) =3D=3D 0) { int pages; =20 - pages =3D ram_find_and_save_block(rs, f, false, &rs->bytes_transfe= rred); + pages =3D ram_find_and_save_block(rs, f, false); /* no more pages to sent */ if (pages =3D=3D 0) { done =3D 1; @@ -2107,8 +2085,7 @@ static int ram_save_complete(QEMUFile *f, void *opaqu= e) while (true) { int pages; =20 - pages =3D ram_find_and_save_block(rs, f, !migration_in_colo_state(= ), - &rs->bytes_transferred); + pages =3D ram_find_and_save_block(rs, f, !migration_in_colo_state(= )); /* no more blocks to sent */ if (pages =3D=3D 0) { break; --=20 2.9.3