From nobody Thu Nov 6 15:37:52 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 1489586677363642.3250105215672; Wed, 15 Mar 2017 07:04:37 -0700 (PDT) Received: from localhost ([::1]:37456 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1co9XW-00022I-Ae for importer@patchew.org; Wed, 15 Mar 2017 10:04:34 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:53931) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1co9KU-0007d3-AC 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 1co9KQ-0003mL-9f for qemu-devel@nongnu.org; Wed, 15 Mar 2017 09:51:06 -0400 Received: from mx1.redhat.com ([209.132.183.28]:42230) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1co9KP-0003lN-V3 for qemu-devel@nongnu.org; Wed, 15 Mar 2017 09:51:02 -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 D876580B56 for ; Wed, 15 Mar 2017 13:51:01 +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 v2FDoNUt002305; Wed, 15 Mar 2017 09:51:00 -0400 DMARC-Filter: OpenDMARC Filter v1.3.2 mx1.redhat.com D876580B56 Authentication-Results: ext-mx04.extmail.prod.ext.phx2.redhat.com; dmarc=none (p=none dis=none) header.from=redhat.com Authentication-Results: ext-mx04.extmail.prod.ext.phx2.redhat.com; spf=pass smtp.mailfrom=quintela@redhat.com DKIM-Filter: OpenDKIM Filter v2.11.0 mx1.redhat.com D876580B56 From: Juan Quintela To: qemu-devel@nongnu.org Date: Wed, 15 Mar 2017 14:50:14 +0100 Message-Id: <20170315135021.6978-25-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.28]); Wed, 15 Mar 2017 13:51:02 +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 24/31] ram: Move bytes_transferred into RAMState 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" Signed-off-by: Juan Quintela --- migration/ram.c | 35 +++++++++++++++++------------------ 1 file changed, 17 insertions(+), 18 deletions(-) diff --git a/migration/ram.c b/migration/ram.c index d39d185..f9933b2 100644 --- a/migration/ram.c +++ b/migration/ram.c @@ -191,6 +191,8 @@ struct RAMState { uint64_t xbzrle_overflows; /* number of dirty bits in the bitmap */ uint64_t migration_dirty_pages; + /* total number of bytes transferred */ + uint64_t bytes_transferred; /* protects modification of the bitmap */ QemuMutex bitmap_mutex; /* Ram Bitmap protected by RCU */ @@ -240,6 +242,11 @@ static ram_addr_t ram_save_remaining(void) return ram_state.migration_dirty_pages; } =20 +uint64_t ram_bytes_transferred(void) +{ + return ram_state.bytes_transferred; +} + /* used by the search for pages to send */ struct PageSearchStatus { /* Current block being searched */ @@ -844,9 +851,7 @@ static int do_compress_ram_page(QEMUFile *f, RAMBlock *= block, return bytes_sent; } =20 -static uint64_t bytes_transferred; - -static void flush_compressed_data(QEMUFile *f) +static void flush_compressed_data(RAMState *rs, QEMUFile *f) { int idx, len, thread_count; =20 @@ -867,7 +872,7 @@ static void flush_compressed_data(QEMUFile *f) qemu_mutex_lock(&comp_param[idx].mutex); if (!comp_param[idx].quit) { len =3D qemu_put_qemu_file(f, comp_param[idx].file); - bytes_transferred +=3D len; + rs->bytes_transferred +=3D len; } qemu_mutex_unlock(&comp_param[idx].mutex); } @@ -963,7 +968,7 @@ static int ram_save_compressed_page(RAMState *rs, Migra= tionState *ms, * is used to avoid resending the block name. */ if (block !=3D rs->last_sent_block) { - flush_compressed_data(f); + flush_compressed_data(rs, f); pages =3D save_zero_page(rs, f, block, offset, p, bytes_transf= erred); if (pages =3D=3D -1) { /* Make sure the first page is sent out before other pages= */ @@ -1039,7 +1044,7 @@ static bool find_dirty_block(RAMState *rs, QEMUFile *= f, PageSearchStatus *pss, /* If xbzrle is on, stop using the data compression at this * point. In theory, xbzrle can do better than compression. */ - flush_compressed_data(f); + flush_compressed_data(rs, f); compression_switch =3D false; } } @@ -1410,7 +1415,7 @@ void acct_update_position(QEMUFile *f, size_t size, b= ool zero) ram_state.zero_pages +=3D pages; } else { ram_state.norm_pages +=3D pages; - bytes_transferred +=3D size; + ram_state.bytes_transferred +=3D size; qemu_update_position(f, size); } } @@ -1420,11 +1425,6 @@ uint64_t ram_bytes_remaining(void) return ram_save_remaining() * TARGET_PAGE_SIZE; } =20 -uint64_t ram_bytes_transferred(void) -{ - return bytes_transferred; -} - uint64_t ram_bytes_total(void) { RAMBlock *block; @@ -1952,7 +1952,6 @@ static int ram_state_init(RAMState *rs) =20 qemu_mutex_lock_ramlist(); rcu_read_lock(); - bytes_transferred =3D 0; ram_state_reset(rs); =20 rs->ram_bitmap =3D g_new0(struct RAMBitmap, 1); @@ -2047,7 +2046,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, &bytes_transferred= ); + pages =3D ram_find_and_save_block(rs, f, false, &rs->bytes_transfe= rred); /* no more pages to sent */ if (pages =3D=3D 0) { done =3D 1; @@ -2069,7 +2068,7 @@ static int ram_save_iterate(QEMUFile *f, void *opaque) } i++; } - flush_compressed_data(f); + flush_compressed_data(rs, f); rcu_read_unlock(); =20 /* @@ -2079,7 +2078,7 @@ static int ram_save_iterate(QEMUFile *f, void *opaque) ram_control_after_iterate(f, RAM_CONTROL_ROUND); =20 qemu_put_be64(f, RAM_SAVE_FLAG_EOS); - bytes_transferred +=3D 8; + rs->bytes_transferred +=3D 8; =20 ret =3D qemu_file_get_error(f); if (ret < 0) { @@ -2109,14 +2108,14 @@ static int ram_save_complete(QEMUFile *f, void *opa= que) int pages; =20 pages =3D ram_find_and_save_block(rs, f, !migration_in_colo_state(= ), - &bytes_transferred); + &rs->bytes_transferred); /* no more blocks to sent */ if (pages =3D=3D 0) { break; } } =20 - flush_compressed_data(f); + flush_compressed_data(rs, f); ram_control_after_iterate(f, RAM_CONTROL_FINISH); =20 rcu_read_unlock(); --=20 2.9.3