From nobody Thu Nov 6 13:36:10 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 1489586043892592.1867882432242; Wed, 15 Mar 2017 06:54:03 -0700 (PDT) Received: from localhost ([::1]:37403 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1co9NJ-0000uZ-B5 for importer@patchew.org; Wed, 15 Mar 2017 09:54:01 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:53457) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1co9Jx-000799-6T for qemu-devel@nongnu.org; Wed, 15 Mar 2017 09:50:35 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1co9Js-0003DA-Ua for qemu-devel@nongnu.org; Wed, 15 Mar 2017 09:50:33 -0400 Received: from mx1.redhat.com ([209.132.183.28]:57532) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1co9Js-0003CL-LM for qemu-devel@nongnu.org; Wed, 15 Mar 2017 09:50:28 -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 CE40A81244 for ; Wed, 15 Mar 2017 13:50:26 +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 v2FDoNUW002305; Wed, 15 Mar 2017 09:50:25 -0400 DMARC-Filter: OpenDMARC Filter v1.3.2 mx1.redhat.com CE40A81244 Authentication-Results: ext-mx01.extmail.prod.ext.phx2.redhat.com; dmarc=none (p=none dis=none) header.from=redhat.com Authentication-Results: ext-mx01.extmail.prod.ext.phx2.redhat.com; spf=pass smtp.mailfrom=quintela@redhat.com DKIM-Filter: OpenDKIM Filter v2.11.0 mx1.redhat.com CE40A81244 From: Juan Quintela To: qemu-devel@nongnu.org Date: Wed, 15 Mar 2017 14:49:51 +0100 Message-Id: <20170315135021.6978-2-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.25]); Wed, 15 Mar 2017 13:50:26 +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 01/31] ram: move more fields 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" last_seen_block, last_sent_block, last_offset, last_version and ram_bulk_stage are globals that are really related together. Signed-off-by: Juan Quintela Reviewed-by: Dr. David Alan Gilbert Reviewed-by: Philippe Mathieu-Daud=C3=A9 --- migration/ram.c | 136 ++++++++++++++++++++++++++++++++--------------------= ---- 1 file changed, 79 insertions(+), 57 deletions(-) diff --git a/migration/ram.c b/migration/ram.c index 719425b..c20a539 100644 --- a/migration/ram.c +++ b/migration/ram.c @@ -136,6 +136,23 @@ out: return ret; } =20 +/* State of RAM for migration */ +struct RAMState { + /* Last block that we have visited searching for dirty pages */ + RAMBlock *last_seen_block; + /* Last block from where we have sent data */ + RAMBlock *last_sent_block; + /* Last offeset we have sent data from */ + ram_addr_t last_offset; + /* last ram version we have seen */ + uint32_t last_version; + /* We are in the first round */ + bool ram_bulk_stage; +}; +typedef struct RAMState RAMState; + +static RAMState ram_state; + /* accounting for migration statistics */ typedef struct AccountingInfo { uint64_t dup_pages; @@ -211,16 +228,8 @@ uint64_t xbzrle_mig_pages_overflow(void) return acct_info.xbzrle_overflows; } =20 -/* This is the last block that we have visited serching for dirty pages - */ -static RAMBlock *last_seen_block; -/* This is the last block from where we have sent data */ -static RAMBlock *last_sent_block; -static ram_addr_t last_offset; static QemuMutex migration_bitmap_mutex; static uint64_t migration_dirty_pages; -static uint32_t last_version; -static bool ram_bulk_stage; =20 /* used by the search for pages to send */ struct PageSearchStatus { @@ -437,9 +446,9 @@ static void mig_throttle_guest_down(void) * As a bonus, if the page wasn't in the cache it gets added so that * when a small write is made into the 0'd page it gets XBZRLE sent */ -static void xbzrle_cache_zero_page(ram_addr_t current_addr) +static void xbzrle_cache_zero_page(RAMState *rs, ram_addr_t current_addr) { - if (ram_bulk_stage || !migrate_use_xbzrle()) { + if (rs->ram_bulk_stage || !migrate_use_xbzrle()) { return; } =20 @@ -539,7 +548,7 @@ static int save_xbzrle_page(QEMUFile *f, uint8_t **curr= ent_data, * Returns: byte offset within memory region of the start of a dirty page */ static inline -ram_addr_t migration_bitmap_find_dirty(RAMBlock *rb, +ram_addr_t migration_bitmap_find_dirty(RAMState *rs, RAMBlock *rb, ram_addr_t start, ram_addr_t *ram_addr_abs) { @@ -552,7 +561,7 @@ ram_addr_t migration_bitmap_find_dirty(RAMBlock *rb, unsigned long next; =20 bitmap =3D atomic_rcu_read(&migration_bitmap_rcu)->bmap; - if (ram_bulk_stage && nr > base) { + if (rs->ram_bulk_stage && nr > base) { next =3D nr + 1; } else { next =3D find_next_bit(bitmap, size, nr); @@ -740,6 +749,7 @@ static void ram_release_pages(MigrationState *ms, const= char *block_name, * >=3D0 - Number of pages written - this might legally be 0 * if xbzrle noticed the page was the same. * + * @rs: The RAM state * @ms: The current migration state. * @f: QEMUFile where to send the data * @block: block that contains the page we want to send @@ -747,8 +757,9 @@ static void ram_release_pages(MigrationState *ms, const= char *block_name, * @last_stage: if we are at the completion stage * @bytes_transferred: increase it with the number of transferred bytes */ -static int ram_save_page(MigrationState *ms, QEMUFile *f, PageSearchStatus= *pss, - bool last_stage, uint64_t *bytes_transferred) +static int ram_save_page(RAMState *rs, MigrationState *ms, QEMUFile *f, + PageSearchStatus *pss, bool last_stage, + uint64_t *bytes_transferred) { int pages =3D -1; uint64_t bytes_xmit; @@ -774,7 +785,7 @@ static int ram_save_page(MigrationState *ms, QEMUFile *= f, PageSearchStatus *pss, =20 current_addr =3D block->offset + offset; =20 - if (block =3D=3D last_sent_block) { + if (block =3D=3D rs->last_sent_block) { offset |=3D RAM_SAVE_FLAG_CONTINUE; } if (ret !=3D RAM_SAVE_CONTROL_NOT_SUPP) { @@ -791,9 +802,9 @@ static int ram_save_page(MigrationState *ms, QEMUFile *= f, PageSearchStatus *pss, /* Must let xbzrle know, otherwise a previous (now 0'd) cached * page would be stale */ - xbzrle_cache_zero_page(current_addr); + xbzrle_cache_zero_page(rs, current_addr); ram_release_pages(ms, block->idstr, pss->offset, pages); - } else if (!ram_bulk_stage && + } else if (!rs->ram_bulk_stage && !migration_in_postcopy(ms) && migrate_use_xbzrle()) { pages =3D save_xbzrle_page(f, &p, current_addr, block, offset, last_stage, bytes_transferred= ); @@ -925,6 +936,7 @@ static int compress_page_with_multi_thread(QEMUFile *f,= RAMBlock *block, * * Returns: Number of pages written. * + * @rs: The RAM state * @ms: The current migration state. * @f: QEMUFile where to send the data * @block: block that contains the page we want to send @@ -932,7 +944,8 @@ 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(MigrationState *ms, QEMUFile *f, +static int ram_save_compressed_page(RAMState *rs, MigrationState *ms, + QEMUFile *f, PageSearchStatus *pss, bool last_stage, uint64_t *bytes_transferred) { @@ -966,7 +979,7 @@ static int ram_save_compressed_page(MigrationState *ms,= QEMUFile *f, * out, keeping this order is important, because the 'cont' flag * is used to avoid resending the block name. */ - if (block !=3D last_sent_block) { + if (block !=3D rs->last_sent_block) { flush_compressed_data(f); pages =3D save_zero_page(f, block, offset, p, bytes_transferre= d); if (pages =3D=3D -1) { @@ -1008,19 +1021,20 @@ static int ram_save_compressed_page(MigrationState = *ms, QEMUFile *f, * * Returns: True if a page is found * + * @rs: The RAM state * @f: Current migration stream. * @pss: Data about the state of the current dirty page scan. * @*again: Set to false if the search has scanned the whole of RAM * *ram_addr_abs: Pointer into which to store the address of the dirty page * within the global ram_addr space */ -static bool find_dirty_block(QEMUFile *f, PageSearchStatus *pss, +static bool find_dirty_block(RAMState *rs, QEMUFile *f, PageSearchStatus *= pss, bool *again, ram_addr_t *ram_addr_abs) { - pss->offset =3D migration_bitmap_find_dirty(pss->block, pss->offset, + pss->offset =3D migration_bitmap_find_dirty(rs, pss->block, pss->offse= t, ram_addr_abs); - if (pss->complete_round && pss->block =3D=3D last_seen_block && - pss->offset >=3D last_offset) { + if (pss->complete_round && pss->block =3D=3D rs->last_seen_block && + pss->offset >=3D rs->last_offset) { /* * We've been once around the RAM and haven't found anything. * Give up. @@ -1037,7 +1051,7 @@ static bool find_dirty_block(QEMUFile *f, PageSearchS= tatus *pss, pss->block =3D QLIST_FIRST_RCU(&ram_list.blocks); /* Flag that we've looped */ pss->complete_round =3D true; - ram_bulk_stage =3D false; + rs->ram_bulk_stage =3D false; if (migrate_use_xbzrle()) { /* If xbzrle is on, stop using the data compression at this * point. In theory, xbzrle can do better than compression. @@ -1097,13 +1111,14 @@ static RAMBlock *unqueue_page(MigrationState *ms, r= am_addr_t *offset, * Unqueue a page from the queue fed by postcopy page requests; skips pages * that are already sent (!dirty) * + * rs: The RAM state * ms: MigrationState in * pss: PageSearchStatus structure updated with found block/offset * ram_addr_abs: global offset in the dirty/sent bitmaps * * Returns: true if a queued page is found */ -static bool get_queued_page(MigrationState *ms, PageSearchStatus *pss, +static bool get_queued_page(RAMState *rs, MigrationState *ms, PageSearchSt= atus *pss, ram_addr_t *ram_addr_abs) { RAMBlock *block; @@ -1144,7 +1159,7 @@ static bool get_queued_page(MigrationState *ms, PageS= earchStatus *pss, * in (migration_bitmap_find_and_reset_dirty) that every page is * dirty, that's no longer true. */ - ram_bulk_stage =3D false; + rs->ram_bulk_stage =3D false; =20 /* * We want the background search to continue from the queued page @@ -1248,6 +1263,7 @@ err: * ram_save_target_page: Save one target page * * + * @rs: The RAM state * @f: QEMUFile where to send the data * @block: pointer to block that contains the page we want to send * @offset: offset inside the block for the page; @@ -1257,7 +1273,7 @@ err: * * Returns: Number of pages written. */ -static int ram_save_target_page(MigrationState *ms, QEMUFile *f, +static int ram_save_target_page(RAMState *rs, MigrationState *ms, QEMUFile= *f, PageSearchStatus *pss, bool last_stage, uint64_t *bytes_transferred, @@ -1269,11 +1285,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 =3D ram_save_compressed_page(ms, f, pss, + res =3D ram_save_compressed_page(rs, ms, f, pss, last_stage, bytes_transferred); } else { - res =3D ram_save_page(ms, f, pss, last_stage, + res =3D ram_save_page(rs, ms, f, pss, last_stage, bytes_transferred); } =20 @@ -1289,7 +1305,7 @@ static int ram_save_target_page(MigrationState *ms, Q= EMUFile *f, * to the stream. */ if (res > 0) { - last_sent_block =3D pss->block; + rs->last_sent_block =3D pss->block; } } =20 @@ -1307,6 +1323,7 @@ static int ram_save_target_page(MigrationState *ms, Q= EMUFile *f, * * Returns: Number of pages written. * + * @rs: The RAM state * @f: QEMUFile where to send the data * @block: pointer to block that contains the page we want to send * @offset: offset inside the block for the page; updated to last target p= age @@ -1315,7 +1332,7 @@ static int ram_save_target_page(MigrationState *ms, Q= EMUFile *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 sp= ace */ -static int ram_save_host_page(MigrationState *ms, QEMUFile *f, +static int ram_save_host_page(RAMState *rs, MigrationState *ms, QEMUFile *= f, PageSearchStatus *pss, bool last_stage, uint64_t *bytes_transferred, @@ -1325,7 +1342,7 @@ static int ram_save_host_page(MigrationState *ms, QEM= UFile *f, size_t pagesize =3D qemu_ram_pagesize(pss->block); =20 do { - tmppages =3D ram_save_target_page(ms, f, pss, last_stage, + tmppages =3D ram_save_target_page(rs, ms, f, pss, last_stage, bytes_transferred, dirty_ram_abs); if (tmppages < 0) { return tmppages; @@ -1349,6 +1366,7 @@ static int ram_save_host_page(MigrationState *ms, QEM= UFile *f, * Returns: The number of pages written * 0 means no dirty pages * + * @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 @@ -1357,7 +1375,7 @@ static int ram_save_host_page(MigrationState *ms, QEM= UFile *f, * pages in a host page that are dirty. */ =20 -static int ram_find_and_save_block(QEMUFile *f, bool last_stage, +static int ram_find_and_save_block(RAMState *rs, QEMUFile *f, bool last_st= age, uint64_t *bytes_transferred) { PageSearchStatus pss; @@ -1372,8 +1390,8 @@ static int ram_find_and_save_block(QEMUFile *f, bool = last_stage, return pages; } =20 - pss.block =3D last_seen_block; - pss.offset =3D last_offset; + pss.block =3D rs->last_seen_block; + pss.offset =3D rs->last_offset; pss.complete_round =3D false; =20 if (!pss.block) { @@ -1382,22 +1400,22 @@ static int ram_find_and_save_block(QEMUFile *f, boo= l last_stage, =20 do { again =3D true; - found =3D get_queued_page(ms, &pss, &dirty_ram_abs); + found =3D get_queued_page(rs, ms, &pss, &dirty_ram_abs); =20 if (!found) { /* priority queue empty, so just search for something dirty */ - found =3D find_dirty_block(f, &pss, &again, &dirty_ram_abs); + found =3D find_dirty_block(rs, f, &pss, &again, &dirty_ram_abs= ); } =20 if (found) { - pages =3D ram_save_host_page(ms, f, &pss, + pages =3D ram_save_host_page(rs, ms, f, &pss, last_stage, bytes_transferred, dirty_ram_abs); } } while (!pages && again); =20 - last_seen_block =3D pss.block; - last_offset =3D pss.offset; + rs->last_seen_block =3D pss.block; + rs->last_offset =3D pss.offset; =20 return pages; } @@ -1479,13 +1497,13 @@ static void ram_migration_cleanup(void *opaque) XBZRLE_cache_unlock(); } =20 -static void reset_ram_globals(void) +static void ram_state_reset(RAMState *rs) { - last_seen_block =3D NULL; - last_sent_block =3D NULL; - last_offset =3D 0; - last_version =3D ram_list.version; - ram_bulk_stage =3D true; + rs->last_seen_block =3D NULL; + rs->last_sent_block =3D NULL; + rs->last_offset =3D 0; + rs->last_version =3D ram_list.version; + rs->ram_bulk_stage =3D true; } =20 #define MAX_WAIT 50 /* ms, half buffered_file limit */ @@ -1800,9 +1818,9 @@ static int postcopy_chunk_hostpages(MigrationState *m= s) struct RAMBlock *block; =20 /* Easiest way to make sure we don't resume in the middle of a host-pa= ge */ - last_seen_block =3D NULL; - last_sent_block =3D NULL; - last_offset =3D 0; + ram_state.last_seen_block =3D NULL; + ram_state.last_sent_block =3D NULL; + ram_state.last_offset =3D 0; =20 QLIST_FOREACH_RCU(block, &ram_list.blocks, next) { unsigned long first =3D block->offset >> TARGET_PAGE_BITS; @@ -1913,7 +1931,7 @@ err: return ret; } =20 -static int ram_save_init_globals(void) +static int ram_save_init_globals(RAMState *rs) { int64_t ram_bitmap_pages; /* Size of bitmap in pages, including gaps */ =20 @@ -1959,7 +1977,7 @@ static int ram_save_init_globals(void) qemu_mutex_lock_ramlist(); rcu_read_lock(); bytes_transferred =3D 0; - reset_ram_globals(); + ram_state_reset(rs); =20 migration_bitmap_rcu =3D g_new0(struct BitmapRcu, 1); /* Skip setting bitmap if there is no RAM */ @@ -1997,11 +2015,12 @@ static int ram_save_init_globals(void) =20 static int ram_save_setup(QEMUFile *f, void *opaque) { + RAMState *rs =3D opaque; RAMBlock *block; =20 /* migration has already setup the bitmap, reuse it. */ if (!migration_in_colo_state()) { - if (ram_save_init_globals() < 0) { + if (ram_save_init_globals(rs) < 0) { return -1; } } @@ -2031,14 +2050,15 @@ static int ram_save_setup(QEMUFile *f, void *opaque) =20 static int ram_save_iterate(QEMUFile *f, void *opaque) { + RAMState *rs =3D opaque; int ret; int i; int64_t t0; int done =3D 0; =20 rcu_read_lock(); - if (ram_list.version !=3D last_version) { - reset_ram_globals(); + if (ram_list.version !=3D rs->last_version) { + ram_state_reset(rs); } =20 /* Read version before ram_list.blocks */ @@ -2051,7 +2071,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(f, false, &bytes_transferred); + pages =3D ram_find_and_save_block(rs, f, false, &bytes_transferred= ); /* no more pages to sent */ if (pages =3D=3D 0) { done =3D 1; @@ -2096,6 +2116,8 @@ static int ram_save_iterate(QEMUFile *f, void *opaque) /* Called with iothread lock */ static int ram_save_complete(QEMUFile *f, void *opaque) { + RAMState *rs =3D opaque; + =20 rcu_read_lock(); =20 if (!migration_in_postcopy(migrate_get_current())) { @@ -2110,7 +2132,7 @@ static int ram_save_complete(QEMUFile *f, void *opaqu= e) while (true) { int pages; =20 - pages =3D ram_find_and_save_block(f, !migration_in_colo_state(), + pages =3D ram_find_and_save_block(rs, f, !migration_in_colo_state(= ), &bytes_transferred); /* no more blocks to sent */ if (pages =3D=3D 0) { @@ -2675,5 +2697,5 @@ static SaveVMHandlers savevm_ram_handlers =3D { void ram_mig_init(void) { qemu_mutex_init(&XBZRLE.lock); - register_savevm_live(NULL, "ram", 0, 4, &savevm_ram_handlers, NULL); + register_savevm_live(NULL, "ram", 0, 4, &savevm_ram_handlers, &ram_sta= te); } --=20 2.9.3 From nobody Thu Nov 6 13:36:10 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 1489585904188886.4759424689706; Wed, 15 Mar 2017 06:51:44 -0700 (PDT) Received: from localhost ([::1]:37397 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1co9L4-0007BS-VC for importer@patchew.org; Wed, 15 Mar 2017 09:51:43 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:53456) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1co9Jx-000798-6O for qemu-devel@nongnu.org; Wed, 15 Mar 2017 09:50:34 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1co9Js-0003Cs-K6 for qemu-devel@nongnu.org; Wed, 15 Mar 2017 09:50:33 -0400 Received: from mx1.redhat.com ([209.132.183.28]:47856) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1co9Js-0003CS-B9 for qemu-devel@nongnu.org; Wed, 15 Mar 2017 09:50:28 -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 4D8DC437F49 for ; Wed, 15 Mar 2017 13:50:28 +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 v2FDoNUX002305; Wed, 15 Mar 2017 09:50:26 -0400 DMARC-Filter: OpenDMARC Filter v1.3.2 mx1.redhat.com 4D8DC437F49 Authentication-Results: ext-mx05.extmail.prod.ext.phx2.redhat.com; dmarc=none (p=none dis=none) header.from=redhat.com Authentication-Results: ext-mx05.extmail.prod.ext.phx2.redhat.com; spf=pass smtp.mailfrom=quintela@redhat.com DKIM-Filter: OpenDKIM Filter v2.11.0 mx1.redhat.com 4D8DC437F49 From: Juan Quintela To: qemu-devel@nongnu.org Date: Wed, 15 Mar 2017 14:49:52 +0100 Message-Id: <20170315135021.6978-3-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.29]); Wed, 15 Mar 2017 13:50:28 +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 02/31] ram: Add dirty_rate_high_cnt to 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" We need to add a parameter to several functions to make this work. Signed-off-by: Juan Quintela Reviewed-by: Dr. David Alan Gilbert Reviewed-by: Philippe Mathieu-Daud=C3=A9 --- migration/ram.c | 23 ++++++++++++----------- 1 file changed, 12 insertions(+), 11 deletions(-) diff --git a/migration/ram.c b/migration/ram.c index c20a539..9120755 100644 --- a/migration/ram.c +++ b/migration/ram.c @@ -45,8 +45,6 @@ #include "qemu/rcu_queue.h" #include "migration/colo.h" =20 -static int dirty_rate_high_cnt; - static uint64_t bitmap_sync_count; =20 /***********************************************************/ @@ -148,6 +146,8 @@ struct RAMState { uint32_t last_version; /* We are in the first round */ bool ram_bulk_stage; + /* How many times we have dirty too many pages */ + int dirty_rate_high_cnt; }; typedef struct RAMState RAMState; =20 @@ -626,7 +626,7 @@ uint64_t ram_pagesize_summary(void) return summary; } =20 -static void migration_bitmap_sync(void) +static void migration_bitmap_sync(RAMState *rs) { RAMBlock *block; uint64_t num_dirty_pages_init =3D migration_dirty_pages; @@ -673,9 +673,9 @@ static void migration_bitmap_sync(void) if (s->dirty_pages_rate && (num_dirty_pages_period * TARGET_PAGE_SIZE > (bytes_xfer_now - bytes_xfer_prev)/2) && - (dirty_rate_high_cnt++ >=3D 2)) { + (rs->dirty_rate_high_cnt++ >=3D 2)) { trace_migration_throttle(); - dirty_rate_high_cnt =3D 0; + rs->dirty_rate_high_cnt =3D 0; mig_throttle_guest_down(); } bytes_xfer_prev =3D bytes_xfer_now; @@ -1859,7 +1859,7 @@ int ram_postcopy_send_discard_bitmap(MigrationState *= ms) rcu_read_lock(); =20 /* This should be our last sync, the src is now paused */ - migration_bitmap_sync(); + migration_bitmap_sync(&ram_state); =20 unsentmap =3D atomic_rcu_read(&migration_bitmap_rcu)->unsentmap; if (!unsentmap) { @@ -1935,7 +1935,7 @@ static int ram_save_init_globals(RAMState *rs) { int64_t ram_bitmap_pages; /* Size of bitmap in pages, including gaps */ =20 - dirty_rate_high_cnt =3D 0; + rs->dirty_rate_high_cnt =3D 0; bitmap_sync_count =3D 0; migration_bitmap_sync_init(); qemu_mutex_init(&migration_bitmap_mutex); @@ -1999,7 +1999,7 @@ static int ram_save_init_globals(RAMState *rs) migration_dirty_pages =3D ram_bytes_total() >> TARGET_PAGE_BITS; =20 memory_global_dirty_log_start(); - migration_bitmap_sync(); + migration_bitmap_sync(rs); qemu_mutex_unlock_ramlist(); qemu_mutex_unlock_iothread(); rcu_read_unlock(); @@ -2117,11 +2117,11 @@ static int ram_save_iterate(QEMUFile *f, void *opaq= ue) static int ram_save_complete(QEMUFile *f, void *opaque) { RAMState *rs =3D opaque; - =20 + rcu_read_lock(); =20 if (!migration_in_postcopy(migrate_get_current())) { - migration_bitmap_sync(); + migration_bitmap_sync(rs); } =20 ram_control_before_iterate(f, RAM_CONTROL_FINISH); @@ -2154,6 +2154,7 @@ static void ram_save_pending(QEMUFile *f, void *opaqu= e, uint64_t max_size, uint64_t *non_postcopiable_pending, uint64_t *postcopiable_pending) { + RAMState *rs =3D opaque; uint64_t remaining_size; =20 remaining_size =3D ram_save_remaining() * TARGET_PAGE_SIZE; @@ -2162,7 +2163,7 @@ static void ram_save_pending(QEMUFile *f, void *opaqu= e, uint64_t max_size, remaining_size < max_size) { qemu_mutex_lock_iothread(); rcu_read_lock(); - migration_bitmap_sync(); + migration_bitmap_sync(rs); rcu_read_unlock(); qemu_mutex_unlock_iothread(); remaining_size =3D ram_save_remaining() * TARGET_PAGE_SIZE; --=20 2.9.3 From nobody Thu Nov 6 13:36:10 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 1489585905384769.2610166292231; Wed, 15 Mar 2017 06:51:45 -0700 (PDT) Received: from localhost ([::1]:37396 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1co9L3-00079h-4N for importer@patchew.org; Wed, 15 Mar 2017 09:51:41 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:53458) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1co9Jx-00079A-6X for qemu-devel@nongnu.org; Wed, 15 Mar 2017 09:50:34 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1co9Ju-0003DU-2N for qemu-devel@nongnu.org; Wed, 15 Mar 2017 09:50:33 -0400 Received: from mx1.redhat.com ([209.132.183.28]:57044) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1co9Jt-0003DI-R5 for qemu-devel@nongnu.org; Wed, 15 Mar 2017 09:50:30 -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 C79B23B731 for ; Wed, 15 Mar 2017 13:50:29 +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 v2FDoNUY002305; Wed, 15 Mar 2017 09:50:28 -0400 DMARC-Filter: OpenDMARC Filter v1.3.2 mx1.redhat.com C79B23B731 Authentication-Results: ext-mx06.extmail.prod.ext.phx2.redhat.com; dmarc=none (p=none dis=none) header.from=redhat.com Authentication-Results: ext-mx06.extmail.prod.ext.phx2.redhat.com; spf=pass smtp.mailfrom=quintela@redhat.com DKIM-Filter: OpenDKIM Filter v2.11.0 mx1.redhat.com C79B23B731 From: Juan Quintela To: qemu-devel@nongnu.org Date: Wed, 15 Mar 2017 14:49:53 +0100 Message-Id: <20170315135021.6978-4-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.30]); Wed, 15 Mar 2017 13:50:29 +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 03/31] ram: move bitmap_sync_count 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 Reviewed-by: Dr. David Alan Gilbert Reviewed-by: Philippe Mathieu-Daud=C3=A9 --- migration/ram.c | 22 +++++++++++----------- 1 file changed, 11 insertions(+), 11 deletions(-) diff --git a/migration/ram.c b/migration/ram.c index 9120755..c0bee94 100644 --- a/migration/ram.c +++ b/migration/ram.c @@ -45,8 +45,6 @@ #include "qemu/rcu_queue.h" #include "migration/colo.h" =20 -static uint64_t bitmap_sync_count; - /***********************************************************/ /* ram save/restore */ =20 @@ -148,6 +146,8 @@ struct RAMState { bool ram_bulk_stage; /* How many times we have dirty too many pages */ int dirty_rate_high_cnt; + /* How many times we have synchronized the bitmap */ + uint64_t bitmap_sync_count; }; typedef struct RAMState RAMState; =20 @@ -455,7 +455,7 @@ static void xbzrle_cache_zero_page(RAMState *rs, ram_ad= dr_t current_addr) /* We don't care if this fails to allocate a new cache page * as long as it updated an old one */ cache_insert(XBZRLE.cache, current_addr, ZERO_TARGET_PAGE, - bitmap_sync_count); + rs->bitmap_sync_count); } =20 #define ENCODING_FLAG_XBZRLE 0x1 @@ -475,7 +475,7 @@ static void xbzrle_cache_zero_page(RAMState *rs, ram_ad= dr_t current_addr) * @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, uint8_t **current_data, +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) @@ -483,11 +483,11 @@ static int save_xbzrle_page(QEMUFile *f, uint8_t **cu= rrent_data, int encoded_len =3D 0, bytes_xbzrle; uint8_t *prev_cached_page; =20 - if (!cache_is_cached(XBZRLE.cache, current_addr, bitmap_sync_count)) { + if (!cache_is_cached(XBZRLE.cache, current_addr, rs->bitmap_sync_count= )) { acct_info.xbzrle_cache_miss++; if (!last_stage) { if (cache_insert(XBZRLE.cache, current_addr, *current_data, - bitmap_sync_count) =3D=3D -1) { + rs->bitmap_sync_count) =3D=3D -1) { return -1; } else { /* update *current_data when the page has been @@ -634,7 +634,7 @@ static void migration_bitmap_sync(RAMState *rs) int64_t end_time; int64_t bytes_xfer_now; =20 - bitmap_sync_count++; + rs->bitmap_sync_count++; =20 if (!bytes_xfer_prev) { bytes_xfer_prev =3D ram_bytes_transferred(); @@ -697,9 +697,9 @@ static void migration_bitmap_sync(RAMState *rs) start_time =3D end_time; num_dirty_pages_period =3D 0; } - s->dirty_sync_count =3D bitmap_sync_count; + s->dirty_sync_count =3D rs->bitmap_sync_count; if (migrate_use_events()) { - qapi_event_send_migration_pass(bitmap_sync_count, NULL); + qapi_event_send_migration_pass(rs->bitmap_sync_count, NULL); } } =20 @@ -806,7 +806,7 @@ static int ram_save_page(RAMState *rs, MigrationState *= ms, QEMUFile *f, ram_release_pages(ms, block->idstr, pss->offset, pages); } else if (!rs->ram_bulk_stage && !migration_in_postcopy(ms) && migrate_use_xbzrle()) { - pages =3D save_xbzrle_page(f, &p, current_addr, block, + pages =3D save_xbzrle_page(f, rs, &p, current_addr, block, offset, last_stage, bytes_transferred= ); if (!last_stage) { /* Can't send this cached data async, since the cache page @@ -1936,7 +1936,7 @@ static int ram_save_init_globals(RAMState *rs) int64_t ram_bitmap_pages; /* Size of bitmap in pages, including gaps */ =20 rs->dirty_rate_high_cnt =3D 0; - bitmap_sync_count =3D 0; + rs->bitmap_sync_count =3D 0; migration_bitmap_sync_init(); qemu_mutex_init(&migration_bitmap_mutex); =20 --=20 2.9.3 From nobody Thu Nov 6 13:36:10 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 1489585908807190.4771884836631; Wed, 15 Mar 2017 06:51:48 -0700 (PDT) Received: from localhost ([::1]:37398 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1co9L8-0007EC-He for importer@patchew.org; Wed, 15 Mar 2017 09:51:46 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:53455) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1co9Jx-000797-6H for qemu-devel@nongnu.org; Wed, 15 Mar 2017 09:50:36 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1co9Jv-0003E0-Lw for qemu-devel@nongnu.org; Wed, 15 Mar 2017 09:50:33 -0400 Received: from mx1.redhat.com ([209.132.183.28]:51835) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1co9Jv-0003Dk-D5 for qemu-devel@nongnu.org; Wed, 15 Mar 2017 09:50:31 -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 6056AC05AA65 for ; Wed, 15 Mar 2017 13:50:31 +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 v2FDoNUZ002305; Wed, 15 Mar 2017 09:50:29 -0400 DMARC-Filter: OpenDMARC Filter v1.3.2 mx1.redhat.com 6056AC05AA65 Authentication-Results: ext-mx08.extmail.prod.ext.phx2.redhat.com; dmarc=none (p=none dis=none) header.from=redhat.com Authentication-Results: ext-mx08.extmail.prod.ext.phx2.redhat.com; spf=pass smtp.mailfrom=quintela@redhat.com DKIM-Filter: OpenDKIM Filter v2.11.0 mx1.redhat.com 6056AC05AA65 From: Juan Quintela To: qemu-devel@nongnu.org Date: Wed, 15 Mar 2017 14:49:54 +0100 Message-Id: <20170315135021.6978-5-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.32]); Wed, 15 Mar 2017 13:50:31 +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 04/31] ram: Move start time 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 Reviewed-by: Dr. David Alan Gilbert Reviewed-by: Philippe Mathieu-Daud=C3=A9 --- migration/ram.c | 20 +++++++++++--------- 1 file changed, 11 insertions(+), 9 deletions(-) diff --git a/migration/ram.c b/migration/ram.c index c0bee94..f6ac503 100644 --- a/migration/ram.c +++ b/migration/ram.c @@ -148,6 +148,9 @@ struct RAMState { int dirty_rate_high_cnt; /* How many times we have synchronized the bitmap */ uint64_t bitmap_sync_count; + /* this variables are used for bitmap sync */ + /* last time we did a full bitmap_sync */ + int64_t start_time; }; typedef struct RAMState RAMState; =20 @@ -594,15 +597,14 @@ static void migration_bitmap_sync_range(ram_addr_t st= art, ram_addr_t length) } =20 /* Fix me: there are too many global variables used in migration process. = */ -static int64_t start_time; static int64_t bytes_xfer_prev; static int64_t num_dirty_pages_period; static uint64_t xbzrle_cache_miss_prev; static uint64_t iterations_prev; =20 -static void migration_bitmap_sync_init(void) +static void migration_bitmap_sync_init(RAMState *rs) { - start_time =3D 0; + rs->start_time =3D 0; bytes_xfer_prev =3D 0; num_dirty_pages_period =3D 0; xbzrle_cache_miss_prev =3D 0; @@ -640,8 +642,8 @@ static void migration_bitmap_sync(RAMState *rs) bytes_xfer_prev =3D ram_bytes_transferred(); } =20 - if (!start_time) { - start_time =3D qemu_clock_get_ms(QEMU_CLOCK_REALTIME); + if (!rs->start_time) { + rs->start_time =3D qemu_clock_get_ms(QEMU_CLOCK_REALTIME); } =20 trace_migration_bitmap_sync_start(); @@ -661,7 +663,7 @@ static void migration_bitmap_sync(RAMState *rs) end_time =3D qemu_clock_get_ms(QEMU_CLOCK_REALTIME); =20 /* more than 1 second =3D 1000 millisecons */ - if (end_time > start_time + 1000) { + if (end_time > rs->start_time + 1000) { if (migrate_auto_converge()) { /* The following detection logic can be refined later. For now: Check to see if the dirtied bytes is 50% more than the appr= ox. @@ -692,9 +694,9 @@ static void migration_bitmap_sync(RAMState *rs) xbzrle_cache_miss_prev =3D acct_info.xbzrle_cache_miss; } s->dirty_pages_rate =3D num_dirty_pages_period * 1000 - / (end_time - start_time); + / (end_time - rs->start_time); s->dirty_bytes_rate =3D s->dirty_pages_rate * TARGET_PAGE_SIZE; - start_time =3D end_time; + rs->start_time =3D end_time; num_dirty_pages_period =3D 0; } s->dirty_sync_count =3D rs->bitmap_sync_count; @@ -1937,7 +1939,7 @@ static int ram_save_init_globals(RAMState *rs) =20 rs->dirty_rate_high_cnt =3D 0; rs->bitmap_sync_count =3D 0; - migration_bitmap_sync_init(); + migration_bitmap_sync_init(rs); qemu_mutex_init(&migration_bitmap_mutex); =20 if (migrate_use_xbzrle()) { --=20 2.9.3 From nobody Thu Nov 6 13:36:10 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 1489586107005280.44700553679604; Wed, 15 Mar 2017 06:55:07 -0700 (PDT) Received: from localhost ([::1]:37408 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1co9OJ-0001s0-Lg for importer@patchew.org; Wed, 15 Mar 2017 09:55:03 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:53484) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1co9Jy-00079F-3C for qemu-devel@nongnu.org; Wed, 15 Mar 2017 09:50:35 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1co9Jx-0003Eh-6Z for qemu-devel@nongnu.org; Wed, 15 Mar 2017 09:50:34 -0400 Received: from mx1.redhat.com ([209.132.183.28]:57700) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1co9Jx-0003EA-0l for qemu-devel@nongnu.org; Wed, 15 Mar 2017 09:50:33 -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 ED6E881241 for ; Wed, 15 Mar 2017 13:50:32 +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 v2FDoNUa002305; Wed, 15 Mar 2017 09:50:31 -0400 DMARC-Filter: OpenDMARC Filter v1.3.2 mx1.redhat.com ED6E881241 Authentication-Results: ext-mx01.extmail.prod.ext.phx2.redhat.com; dmarc=none (p=none dis=none) header.from=redhat.com Authentication-Results: ext-mx01.extmail.prod.ext.phx2.redhat.com; spf=pass smtp.mailfrom=quintela@redhat.com DKIM-Filter: OpenDKIM Filter v2.11.0 mx1.redhat.com ED6E881241 From: Juan Quintela To: qemu-devel@nongnu.org Date: Wed, 15 Mar 2017 14:49:55 +0100 Message-Id: <20170315135021.6978-6-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.25]); Wed, 15 Mar 2017 13:50:33 +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 05/31] ram: Move bytes_xfer_prev 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 Reviewed-by: Dr. David Alan Gilbert Reviewed-by: Philippe Mathieu-Daud=C3=A9 --- migration/ram.c | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) diff --git a/migration/ram.c b/migration/ram.c index f6ac503..2d288cc 100644 --- a/migration/ram.c +++ b/migration/ram.c @@ -151,6 +151,8 @@ struct RAMState { /* this variables are used for bitmap sync */ /* last time we did a full bitmap_sync */ int64_t start_time; + /* bytes transferred at start_time */ + int64_t bytes_xfer_prev; }; typedef struct RAMState RAMState; =20 @@ -597,7 +599,6 @@ static void migration_bitmap_sync_range(ram_addr_t star= t, ram_addr_t length) } =20 /* Fix me: there are too many global variables used in migration process. = */ -static int64_t bytes_xfer_prev; static int64_t num_dirty_pages_period; static uint64_t xbzrle_cache_miss_prev; static uint64_t iterations_prev; @@ -605,7 +606,7 @@ static uint64_t iterations_prev; static void migration_bitmap_sync_init(RAMState *rs) { rs->start_time =3D 0; - bytes_xfer_prev =3D 0; + rs->bytes_xfer_prev =3D 0; num_dirty_pages_period =3D 0; xbzrle_cache_miss_prev =3D 0; iterations_prev =3D 0; @@ -638,8 +639,8 @@ static void migration_bitmap_sync(RAMState *rs) =20 rs->bitmap_sync_count++; =20 - if (!bytes_xfer_prev) { - bytes_xfer_prev =3D ram_bytes_transferred(); + if (!rs->bytes_xfer_prev) { + rs->bytes_xfer_prev =3D ram_bytes_transferred(); } =20 if (!rs->start_time) { @@ -674,13 +675,13 @@ static void migration_bitmap_sync(RAMState *rs) =20 if (s->dirty_pages_rate && (num_dirty_pages_period * TARGET_PAGE_SIZE > - (bytes_xfer_now - bytes_xfer_prev)/2) && + (bytes_xfer_now - rs->bytes_xfer_prev)/2) && (rs->dirty_rate_high_cnt++ >=3D 2)) { trace_migration_throttle(); rs->dirty_rate_high_cnt =3D 0; mig_throttle_guest_down(); } - bytes_xfer_prev =3D bytes_xfer_now; + rs->bytes_xfer_prev =3D bytes_xfer_now; } =20 if (migrate_use_xbzrle()) { --=20 2.9.3 From nobody Thu Nov 6 13:36:10 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 1489586044395596.9072360106026; Wed, 15 Mar 2017 06:54:04 -0700 (PDT) Received: from localhost ([::1]:37404 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1co9NH-0000vV-Qg for importer@patchew.org; Wed, 15 Mar 2017 09:53:59 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:53515) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1co9Jz-0007AB-O4 for qemu-devel@nongnu.org; Wed, 15 Mar 2017 09:50:36 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1co9Jy-0003Fl-NN for qemu-devel@nongnu.org; Wed, 15 Mar 2017 09:50:35 -0400 Received: from mx1.redhat.com ([209.132.183.28]:47076) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1co9Jy-0003FN-F5 for qemu-devel@nongnu.org; Wed, 15 Mar 2017 09:50:34 -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 6F7464E4CA for ; Wed, 15 Mar 2017 13:50:34 +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 v2FDoNUb002305; Wed, 15 Mar 2017 09:50:32 -0400 DMARC-Filter: OpenDMARC Filter v1.3.2 mx1.redhat.com 6F7464E4CA Authentication-Results: ext-mx09.extmail.prod.ext.phx2.redhat.com; dmarc=none (p=none dis=none) header.from=redhat.com Authentication-Results: ext-mx09.extmail.prod.ext.phx2.redhat.com; spf=pass smtp.mailfrom=quintela@redhat.com DKIM-Filter: OpenDKIM Filter v2.11.0 mx1.redhat.com 6F7464E4CA From: Juan Quintela To: qemu-devel@nongnu.org Date: Wed, 15 Mar 2017 14:49:56 +0100 Message-Id: <20170315135021.6978-7-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.38]); Wed, 15 Mar 2017 13:50:34 +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 06/31] ram: Move num_dirty_pages_period 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 Reviewed-by: Dr. David Alan Gilbert Reviewed-by: Philippe Mathieu-Daud=C3=A9 --- migration/ram.c | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) diff --git a/migration/ram.c b/migration/ram.c index 2d288cc..b13d2d5 100644 --- a/migration/ram.c +++ b/migration/ram.c @@ -153,6 +153,8 @@ struct RAMState { int64_t start_time; /* bytes transferred at start_time */ int64_t bytes_xfer_prev; + /* number of dirty pages since start_time */ + int64_t num_dirty_pages_period; }; typedef struct RAMState RAMState; =20 @@ -599,7 +601,6 @@ static void migration_bitmap_sync_range(ram_addr_t star= t, ram_addr_t length) } =20 /* Fix me: there are too many global variables used in migration process. = */ -static int64_t num_dirty_pages_period; static uint64_t xbzrle_cache_miss_prev; static uint64_t iterations_prev; =20 @@ -607,7 +608,7 @@ static void migration_bitmap_sync_init(RAMState *rs) { rs->start_time =3D 0; rs->bytes_xfer_prev =3D 0; - num_dirty_pages_period =3D 0; + rs->num_dirty_pages_period =3D 0; xbzrle_cache_miss_prev =3D 0; iterations_prev =3D 0; } @@ -660,7 +661,7 @@ static void migration_bitmap_sync(RAMState *rs) =20 trace_migration_bitmap_sync_end(migration_dirty_pages - num_dirty_pages_init); - num_dirty_pages_period +=3D migration_dirty_pages - num_dirty_pages_in= it; + rs->num_dirty_pages_period +=3D migration_dirty_pages - num_dirty_page= s_init; end_time =3D qemu_clock_get_ms(QEMU_CLOCK_REALTIME); =20 /* more than 1 second =3D 1000 millisecons */ @@ -674,7 +675,7 @@ static void migration_bitmap_sync(RAMState *rs) bytes_xfer_now =3D ram_bytes_transferred(); =20 if (s->dirty_pages_rate && - (num_dirty_pages_period * TARGET_PAGE_SIZE > + (rs->num_dirty_pages_period * TARGET_PAGE_SIZE > (bytes_xfer_now - rs->bytes_xfer_prev)/2) && (rs->dirty_rate_high_cnt++ >=3D 2)) { trace_migration_throttle(); @@ -694,11 +695,11 @@ static void migration_bitmap_sync(RAMState *rs) iterations_prev =3D acct_info.iterations; xbzrle_cache_miss_prev =3D acct_info.xbzrle_cache_miss; } - s->dirty_pages_rate =3D num_dirty_pages_period * 1000 + s->dirty_pages_rate =3D rs->num_dirty_pages_period * 1000 / (end_time - rs->start_time); s->dirty_bytes_rate =3D s->dirty_pages_rate * TARGET_PAGE_SIZE; rs->start_time =3D end_time; - num_dirty_pages_period =3D 0; + rs->num_dirty_pages_period =3D 0; } s->dirty_sync_count =3D rs->bitmap_sync_count; if (migrate_use_events()) { --=20 2.9.3 From nobody Thu Nov 6 13:36:10 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 1489586243439361.398861802782; Wed, 15 Mar 2017 06:57:23 -0700 (PDT) Received: from localhost ([::1]:37422 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1co9QV-0003vv-SY for importer@patchew.org; Wed, 15 Mar 2017 09:57:19 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:53536) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1co9K0-0007B9-TL for qemu-devel@nongnu.org; Wed, 15 Mar 2017 09:50:37 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1co9K0-0003GZ-6E for qemu-devel@nongnu.org; Wed, 15 Mar 2017 09:50:37 -0400 Received: from mx1.redhat.com ([209.132.183.28]:57814) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1co9K0-0003GJ-02 for qemu-devel@nongnu.org; Wed, 15 Mar 2017 09:50:36 -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 EFBA38124B for ; Wed, 15 Mar 2017 13:50:35 +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 v2FDoNUc002305; Wed, 15 Mar 2017 09:50:34 -0400 DMARC-Filter: OpenDMARC Filter v1.3.2 mx1.redhat.com EFBA38124B Authentication-Results: ext-mx01.extmail.prod.ext.phx2.redhat.com; dmarc=none (p=none dis=none) header.from=redhat.com Authentication-Results: ext-mx01.extmail.prod.ext.phx2.redhat.com; spf=pass smtp.mailfrom=quintela@redhat.com DKIM-Filter: OpenDKIM Filter v2.11.0 mx1.redhat.com EFBA38124B From: Juan Quintela To: qemu-devel@nongnu.org Date: Wed, 15 Mar 2017 14:49:57 +0100 Message-Id: <20170315135021.6978-8-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.25]); Wed, 15 Mar 2017 13:50:36 +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 07/31] ram: Move xbzrle_cache_miss_prev 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 Reviewed-by: Dr. David Alan Gilbert Reviewed-by: Philippe Mathieu-Daud=C3=A9 --- migration/ram.c | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/migration/ram.c b/migration/ram.c index b13d2d5..ae077c5 100644 --- a/migration/ram.c +++ b/migration/ram.c @@ -155,6 +155,8 @@ struct RAMState { int64_t bytes_xfer_prev; /* number of dirty pages since start_time */ int64_t num_dirty_pages_period; + /* xbzrle misses since the beggining of the period */ + uint64_t xbzrle_cache_miss_prev; }; typedef struct RAMState RAMState; =20 @@ -601,7 +603,6 @@ static void migration_bitmap_sync_range(ram_addr_t star= t, ram_addr_t length) } =20 /* Fix me: there are too many global variables used in migration process. = */ -static uint64_t xbzrle_cache_miss_prev; static uint64_t iterations_prev; =20 static void migration_bitmap_sync_init(RAMState *rs) @@ -609,7 +610,7 @@ static void migration_bitmap_sync_init(RAMState *rs) rs->start_time =3D 0; rs->bytes_xfer_prev =3D 0; rs->num_dirty_pages_period =3D 0; - xbzrle_cache_miss_prev =3D 0; + rs->xbzrle_cache_miss_prev =3D 0; iterations_prev =3D 0; } =20 @@ -689,11 +690,11 @@ static void migration_bitmap_sync(RAMState *rs) if (iterations_prev !=3D acct_info.iterations) { acct_info.xbzrle_cache_miss_rate =3D (double)(acct_info.xbzrle_cache_miss - - xbzrle_cache_miss_prev) / + rs->xbzrle_cache_miss_prev) / (acct_info.iterations - iterations_prev); } iterations_prev =3D acct_info.iterations; - xbzrle_cache_miss_prev =3D acct_info.xbzrle_cache_miss; + rs->xbzrle_cache_miss_prev =3D acct_info.xbzrle_cache_miss; } s->dirty_pages_rate =3D rs->num_dirty_pages_period * 1000 / (end_time - rs->start_time); --=20 2.9.3 From nobody Thu Nov 6 13:36:10 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 1489586179338230.2039521470175; Wed, 15 Mar 2017 06:56:19 -0700 (PDT) Received: from localhost ([::1]:37418 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1co9PV-00031u-PR for importer@patchew.org; Wed, 15 Mar 2017 09:56:17 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:53553) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1co9K2-0007Cl-EB for qemu-devel@nongnu.org; Wed, 15 Mar 2017 09:50:39 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1co9K1-0003I8-KS for qemu-devel@nongnu.org; Wed, 15 Mar 2017 09:50:38 -0400 Received: from mx1.redhat.com ([209.132.183.28]:39174) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1co9K1-0003HB-Ff for qemu-devel@nongnu.org; Wed, 15 Mar 2017 09:50:37 -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 7972BC04FF86 for ; Wed, 15 Mar 2017 13:50:37 +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 v2FDoNUd002305; Wed, 15 Mar 2017 09:50:36 -0400 DMARC-Filter: OpenDMARC Filter v1.3.2 mx1.redhat.com 7972BC04FF86 Authentication-Results: ext-mx07.extmail.prod.ext.phx2.redhat.com; dmarc=none (p=none dis=none) header.from=redhat.com Authentication-Results: ext-mx07.extmail.prod.ext.phx2.redhat.com; spf=pass smtp.mailfrom=quintela@redhat.com DKIM-Filter: OpenDKIM Filter v2.11.0 mx1.redhat.com 7972BC04FF86 From: Juan Quintela To: qemu-devel@nongnu.org Date: Wed, 15 Mar 2017 14:49:58 +0100 Message-Id: <20170315135021.6978-9-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.31]); Wed, 15 Mar 2017 13:50:37 +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 08/31] ram: Move iterations_prev 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 Reviewed-by: Dr. David Alan Gilbert Reviewed-by: Philippe Mathieu-Daud=C3=A9 --- migration/ram.c | 13 ++++++------- 1 file changed, 6 insertions(+), 7 deletions(-) diff --git a/migration/ram.c b/migration/ram.c index ae077c5..6cdad06 100644 --- a/migration/ram.c +++ b/migration/ram.c @@ -157,6 +157,8 @@ struct RAMState { int64_t num_dirty_pages_period; /* xbzrle misses since the beggining of the period */ uint64_t xbzrle_cache_miss_prev; + /* number of iterations at the beggining of period */ + uint64_t iterations_prev; }; typedef struct RAMState RAMState; =20 @@ -602,16 +604,13 @@ static void migration_bitmap_sync_range(ram_addr_t st= art, ram_addr_t length) cpu_physical_memory_sync_dirty_bitmap(bitmap, start, length); } =20 -/* Fix me: there are too many global variables used in migration process. = */ -static uint64_t iterations_prev; - static void migration_bitmap_sync_init(RAMState *rs) { rs->start_time =3D 0; rs->bytes_xfer_prev =3D 0; rs->num_dirty_pages_period =3D 0; rs->xbzrle_cache_miss_prev =3D 0; - iterations_prev =3D 0; + rs->iterations_prev =3D 0; } =20 /* Returns a summary bitmap of the page sizes of all RAMBlocks; @@ -687,13 +686,13 @@ static void migration_bitmap_sync(RAMState *rs) } =20 if (migrate_use_xbzrle()) { - if (iterations_prev !=3D acct_info.iterations) { + if (rs->iterations_prev !=3D acct_info.iterations) { acct_info.xbzrle_cache_miss_rate =3D (double)(acct_info.xbzrle_cache_miss - rs->xbzrle_cache_miss_prev) / - (acct_info.iterations - iterations_prev); + (acct_info.iterations - rs->iterations_prev); } - iterations_prev =3D acct_info.iterations; + rs->iterations_prev =3D acct_info.iterations; rs->xbzrle_cache_miss_prev =3D acct_info.xbzrle_cache_miss; } s->dirty_pages_rate =3D rs->num_dirty_pages_period * 1000 --=20 2.9.3 From nobody Thu Nov 6 13:36:10 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 1489586187153929.9666032789585; Wed, 15 Mar 2017 06:56:27 -0700 (PDT) Received: from localhost ([::1]:37421 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1co9Pe-00038x-1S for importer@patchew.org; Wed, 15 Mar 2017 09:56:26 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:53604) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1co9K8-0007Iz-2I for qemu-devel@nongnu.org; Wed, 15 Mar 2017 09:50:45 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1co9K3-0003KY-7j for qemu-devel@nongnu.org; Wed, 15 Mar 2017 09:50:44 -0400 Received: from mx1.redhat.com ([209.132.183.28]:48248) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1co9K3-0003JJ-04 for qemu-devel@nongnu.org; Wed, 15 Mar 2017 09:50:39 -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 ED8E7201FB for ; Wed, 15 Mar 2017 13:50:38 +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 v2FDoNUe002305; Wed, 15 Mar 2017 09:50:37 -0400 DMARC-Filter: OpenDMARC Filter v1.3.2 mx1.redhat.com ED8E7201FB Authentication-Results: ext-mx05.extmail.prod.ext.phx2.redhat.com; dmarc=none (p=none dis=none) header.from=redhat.com Authentication-Results: ext-mx05.extmail.prod.ext.phx2.redhat.com; spf=pass smtp.mailfrom=quintela@redhat.com DKIM-Filter: OpenDKIM Filter v2.11.0 mx1.redhat.com ED8E7201FB From: Juan Quintela To: qemu-devel@nongnu.org Date: Wed, 15 Mar 2017 14:49:59 +0100 Message-Id: <20170315135021.6978-10-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.29]); Wed, 15 Mar 2017 13:50:39 +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 09/31] ram: Move dup_pages 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" Once there rename it to its actual meaning, zero_pages. Signed-off-by: Juan Quintela Reviewed-by: Dr. David Alan Gilbert --- migration/ram.c | 26 +++++++++++++++----------- 1 file changed, 15 insertions(+), 11 deletions(-) diff --git a/migration/ram.c b/migration/ram.c index 6cdad06..059e9f1 100644 --- a/migration/ram.c +++ b/migration/ram.c @@ -159,6 +159,9 @@ struct RAMState { uint64_t xbzrle_cache_miss_prev; /* number of iterations at the beggining of period */ uint64_t iterations_prev; + /* Accounting fields */ + /* number of zero pages. It used to be pages filled by the same char.= */ + uint64_t zero_pages; }; typedef struct RAMState RAMState; =20 @@ -166,7 +169,6 @@ static RAMState ram_state; =20 /* accounting for migration statistics */ typedef struct AccountingInfo { - uint64_t dup_pages; uint64_t skipped_pages; uint64_t norm_pages; uint64_t iterations; @@ -186,12 +188,12 @@ static void acct_clear(void) =20 uint64_t dup_mig_bytes_transferred(void) { - return acct_info.dup_pages * TARGET_PAGE_SIZE; + return ram_state.zero_pages * TARGET_PAGE_SIZE; } =20 uint64_t dup_mig_pages_transferred(void) { - return acct_info.dup_pages; + return ram_state.zero_pages; } =20 uint64_t skipped_mig_bytes_transferred(void) @@ -718,13 +720,14 @@ static void migration_bitmap_sync(RAMState *rs) * @p: pointer to the page * @bytes_transferred: increase it with the number of transferred bytes */ -static int save_zero_page(QEMUFile *f, RAMBlock *block, ram_addr_t offset, +static int save_zero_page(RAMState *rs, QEMUFile *f, RAMBlock *block, + ram_addr_t offset, uint8_t *p, uint64_t *bytes_transferred) { int pages =3D -1; =20 if (is_zero_range(p, TARGET_PAGE_SIZE)) { - acct_info.dup_pages++; + rs->zero_pages++; *bytes_transferred +=3D save_page_header(f, block, offset | RAM_SAVE_FLAG_COMP= RESS); qemu_put_byte(f, 0); @@ -797,11 +800,11 @@ static int ram_save_page(RAMState *rs, MigrationState= *ms, QEMUFile *f, if (bytes_xmit > 0) { acct_info.norm_pages++; } else if (bytes_xmit =3D=3D 0) { - acct_info.dup_pages++; + rs->zero_pages++; } } } else { - pages =3D save_zero_page(f, block, offset, p, bytes_transferred); + pages =3D save_zero_page(rs, f, block, offset, p, bytes_transferre= d); if (pages > 0) { /* Must let xbzrle know, otherwise a previous (now 0'd) cached * page would be stale @@ -973,7 +976,7 @@ static int ram_save_compressed_page(RAMState *rs, Migra= tionState *ms, if (bytes_xmit > 0) { acct_info.norm_pages++; } else if (bytes_xmit =3D=3D 0) { - acct_info.dup_pages++; + rs->zero_pages++; } } } else { @@ -985,7 +988,7 @@ static int ram_save_compressed_page(RAMState *rs, Migra= tionState *ms, */ if (block !=3D rs->last_sent_block) { flush_compressed_data(f); - pages =3D save_zero_page(f, block, offset, p, bytes_transferre= d); + 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= */ bytes_xmit =3D save_page_header(f, block, offset | @@ -1006,7 +1009,7 @@ static int ram_save_compressed_page(RAMState *rs, Mig= rationState *ms, } } else { offset |=3D RAM_SAVE_FLAG_CONTINUE; - pages =3D save_zero_page(f, block, offset, p, bytes_transferre= d); + pages =3D save_zero_page(rs, f, block, offset, p, bytes_transf= erred); if (pages =3D=3D -1) { pages =3D compress_page_with_multi_thread(f, block, offset, bytes_transferred); @@ -1428,7 +1431,7 @@ void acct_update_position(QEMUFile *f, size_t size, b= ool zero) { uint64_t pages =3D size / TARGET_PAGE_SIZE; if (zero) { - acct_info.dup_pages +=3D pages; + ram_state.zero_pages +=3D pages; } else { acct_info.norm_pages +=3D pages; bytes_transferred +=3D size; @@ -1941,6 +1944,7 @@ static int ram_save_init_globals(RAMState *rs) =20 rs->dirty_rate_high_cnt =3D 0; rs->bitmap_sync_count =3D 0; + rs->zero_pages =3D 0; migration_bitmap_sync_init(rs); qemu_mutex_init(&migration_bitmap_mutex); =20 --=20 2.9.3 From nobody Thu Nov 6 13:36:10 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 1489586048060626.3982881122095; Wed, 15 Mar 2017 06:54:08 -0700 (PDT) Received: from localhost ([::1]:37407 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1co9NN-00012f-OW for importer@patchew.org; Wed, 15 Mar 2017 09:54:05 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:53606) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1co9K8-0007J1-3C for qemu-devel@nongnu.org; Wed, 15 Mar 2017 09:50:44 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1co9K4-0003LP-Nr for qemu-devel@nongnu.org; Wed, 15 Mar 2017 09:50:44 -0400 Received: from mx1.redhat.com ([209.132.183.28]:53394) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1co9K4-0003Kv-I6 for qemu-devel@nongnu.org; Wed, 15 Mar 2017 09:50:40 -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 83461811A7 for ; Wed, 15 Mar 2017 13:50:40 +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 v2FDoNUf002305; Wed, 15 Mar 2017 09:50:39 -0400 DMARC-Filter: OpenDMARC Filter v1.3.2 mx1.redhat.com 83461811A7 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 83461811A7 From: Juan Quintela To: qemu-devel@nongnu.org Date: Wed, 15 Mar 2017 14:50:00 +0100 Message-Id: <20170315135021.6978-11-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:50:40 +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 10/31] ram: Remove unused dump_mig_dbytes_transferred() 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 Reviewed-by: Dr. David Alan Gilbert --- include/migration/migration.h | 1 - migration/ram.c | 5 ----- 2 files changed, 6 deletions(-) diff --git a/include/migration/migration.h b/include/migration/migration.h index 5720c88..3e6bb68 100644 --- a/include/migration/migration.h +++ b/include/migration/migration.h @@ -276,7 +276,6 @@ void free_xbzrle_decoded_buf(void); =20 void acct_update_position(QEMUFile *f, size_t size, bool zero); =20 -uint64_t dup_mig_bytes_transferred(void); uint64_t dup_mig_pages_transferred(void); uint64_t skipped_mig_bytes_transferred(void); uint64_t skipped_mig_pages_transferred(void); diff --git a/migration/ram.c b/migration/ram.c index 059e9f1..83fe20a 100644 --- a/migration/ram.c +++ b/migration/ram.c @@ -186,11 +186,6 @@ static void acct_clear(void) memset(&acct_info, 0, sizeof(acct_info)); } =20 -uint64_t dup_mig_bytes_transferred(void) -{ - return ram_state.zero_pages * TARGET_PAGE_SIZE; -} - uint64_t dup_mig_pages_transferred(void) { return ram_state.zero_pages; --=20 2.9.3 From nobody Thu Nov 6 13:36:10 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 148958632475593.73910913431632; Wed, 15 Mar 2017 06:58:44 -0700 (PDT) Received: from localhost ([::1]:37429 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1co9Rq-0005W2-IT for importer@patchew.org; Wed, 15 Mar 2017 09:58:42 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:53641) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1co9KA-0007L0-2V for qemu-devel@nongnu.org; Wed, 15 Mar 2017 09:50:47 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1co9K6-0003ME-92 for qemu-devel@nongnu.org; Wed, 15 Mar 2017 09:50:46 -0400 Received: from mx1.redhat.com ([209.132.183.28]:57386) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1co9K6-0003Lf-2q for qemu-devel@nongnu.org; Wed, 15 Mar 2017 09:50:42 -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 0DB183B731 for ; Wed, 15 Mar 2017 13:50:42 +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 v2FDoNUg002305; Wed, 15 Mar 2017 09:50:40 -0400 DMARC-Filter: OpenDMARC Filter v1.3.2 mx1.redhat.com 0DB183B731 Authentication-Results: ext-mx06.extmail.prod.ext.phx2.redhat.com; dmarc=none (p=none dis=none) header.from=redhat.com Authentication-Results: ext-mx06.extmail.prod.ext.phx2.redhat.com; spf=pass smtp.mailfrom=quintela@redhat.com DKIM-Filter: OpenDKIM Filter v2.11.0 mx1.redhat.com 0DB183B731 From: Juan Quintela To: qemu-devel@nongnu.org Date: Wed, 15 Mar 2017 14:50:01 +0100 Message-Id: <20170315135021.6978-12-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.30]); Wed, 15 Mar 2017 13:50:42 +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 11/31] ram: Remove unused pages_skiped variable 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" For compatibility, we need to still send a value, but just specify it and comment the fact. Signed-off-by: Juan Quintela Reviewed-by: Dr. David Alan Gilbert --- include/migration/migration.h | 2 -- migration/migration.c | 3 ++- migration/ram.c | 11 ----------- 3 files changed, 2 insertions(+), 14 deletions(-) diff --git a/include/migration/migration.h b/include/migration/migration.h index 3e6bb68..9c83951 100644 --- a/include/migration/migration.h +++ b/include/migration/migration.h @@ -277,8 +277,6 @@ void free_xbzrle_decoded_buf(void); void acct_update_position(QEMUFile *f, size_t size, bool zero); =20 uint64_t dup_mig_pages_transferred(void); -uint64_t skipped_mig_bytes_transferred(void); -uint64_t skipped_mig_pages_transferred(void); uint64_t norm_mig_bytes_transferred(void); uint64_t norm_mig_pages_transferred(void); uint64_t xbzrle_mig_bytes_transferred(void); diff --git a/migration/migration.c b/migration/migration.c index 3dab684..c3e1b95 100644 --- a/migration/migration.c +++ b/migration/migration.c @@ -639,7 +639,8 @@ static void populate_ram_info(MigrationInfo *info, Migr= ationState *s) info->ram->transferred =3D ram_bytes_transferred(); info->ram->total =3D ram_bytes_total(); info->ram->duplicate =3D dup_mig_pages_transferred(); - info->ram->skipped =3D skipped_mig_pages_transferred(); + /* legacy value. It is not used anymore */ + info->ram->skipped =3D 0; info->ram->normal =3D norm_mig_pages_transferred(); info->ram->normal_bytes =3D norm_mig_bytes_transferred(); info->ram->mbps =3D s->mbps; diff --git a/migration/ram.c b/migration/ram.c index 83fe20a..468f042 100644 --- a/migration/ram.c +++ b/migration/ram.c @@ -169,7 +169,6 @@ static RAMState ram_state; =20 /* accounting for migration statistics */ typedef struct AccountingInfo { - uint64_t skipped_pages; uint64_t norm_pages; uint64_t iterations; uint64_t xbzrle_bytes; @@ -191,16 +190,6 @@ uint64_t dup_mig_pages_transferred(void) return ram_state.zero_pages; } =20 -uint64_t skipped_mig_bytes_transferred(void) -{ - return acct_info.skipped_pages * TARGET_PAGE_SIZE; -} - -uint64_t skipped_mig_pages_transferred(void) -{ - return acct_info.skipped_pages; -} - uint64_t norm_mig_bytes_transferred(void) { return acct_info.norm_pages * TARGET_PAGE_SIZE; --=20 2.9.3 From nobody Thu Nov 6 13:36:10 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 1489586184271717.9171643612884; Wed, 15 Mar 2017 06:56:24 -0700 (PDT) Received: from localhost ([::1]:37420 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1co9Pb-000373-0v for importer@patchew.org; Wed, 15 Mar 2017 09:56:23 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:53624) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1co9K8-0007Jn-Ua for qemu-devel@nongnu.org; Wed, 15 Mar 2017 09:50:46 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1co9K7-0003N6-Ph for qemu-devel@nongnu.org; Wed, 15 Mar 2017 09:50:45 -0400 Received: from mx1.redhat.com ([209.132.183.28]:48360) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1co9K7-0003MQ-H5 for qemu-devel@nongnu.org; Wed, 15 Mar 2017 09:50:43 -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 793DB201FB for ; Wed, 15 Mar 2017 13:50:43 +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 v2FDoNUh002305; Wed, 15 Mar 2017 09:50:42 -0400 DMARC-Filter: OpenDMARC Filter v1.3.2 mx1.redhat.com 793DB201FB Authentication-Results: ext-mx05.extmail.prod.ext.phx2.redhat.com; dmarc=none (p=none dis=none) header.from=redhat.com Authentication-Results: ext-mx05.extmail.prod.ext.phx2.redhat.com; spf=pass smtp.mailfrom=quintela@redhat.com DKIM-Filter: OpenDKIM Filter v2.11.0 mx1.redhat.com 793DB201FB From: Juan Quintela To: qemu-devel@nongnu.org Date: Wed, 15 Mar 2017 14:50:02 +0100 Message-Id: <20170315135021.6978-13-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.29]); Wed, 15 Mar 2017 13:50:43 +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 12/31] ram: Move norm_pages to 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 Reviewed-by: Dr. David Alan Gilbert --- migration/ram.c | 26 ++++++++++++++------------ 1 file changed, 14 insertions(+), 12 deletions(-) diff --git a/migration/ram.c b/migration/ram.c index 468f042..58c7dc7 100644 --- a/migration/ram.c +++ b/migration/ram.c @@ -162,6 +162,8 @@ struct RAMState { /* Accounting fields */ /* number of zero pages. It used to be pages filled by the same char.= */ uint64_t zero_pages; + /* number of normal transferred pages */ + uint64_t norm_pages; }; typedef struct RAMState RAMState; =20 @@ -169,7 +171,6 @@ static RAMState ram_state; =20 /* accounting for migration statistics */ typedef struct AccountingInfo { - uint64_t norm_pages; uint64_t iterations; uint64_t xbzrle_bytes; uint64_t xbzrle_pages; @@ -192,12 +193,12 @@ uint64_t dup_mig_pages_transferred(void) =20 uint64_t norm_mig_bytes_transferred(void) { - return acct_info.norm_pages * TARGET_PAGE_SIZE; + return ram_state.norm_pages * TARGET_PAGE_SIZE; } =20 uint64_t norm_mig_pages_transferred(void) { - return acct_info.norm_pages; + return ram_state.norm_pages; } =20 uint64_t xbzrle_mig_bytes_transferred(void) @@ -782,7 +783,7 @@ static int ram_save_page(RAMState *rs, MigrationState *= ms, QEMUFile *f, if (ret !=3D RAM_SAVE_CONTROL_NOT_SUPP) { if (ret !=3D RAM_SAVE_CONTROL_DELAYED) { if (bytes_xmit > 0) { - acct_info.norm_pages++; + rs->norm_pages++; } else if (bytes_xmit =3D=3D 0) { rs->zero_pages++; } @@ -821,7 +822,7 @@ static int ram_save_page(RAMState *rs, MigrationState *= ms, QEMUFile *f, } *bytes_transferred +=3D TARGET_PAGE_SIZE; pages =3D 1; - acct_info.norm_pages++; + rs->norm_pages++; } =20 XBZRLE_cache_unlock(); @@ -888,8 +889,8 @@ static inline void set_compress_params(CompressParam *p= aram, RAMBlock *block, param->offset =3D offset; } =20 -static int compress_page_with_multi_thread(QEMUFile *f, RAMBlock *block, - ram_addr_t offset, +static int compress_page_with_multi_thread(RAMState *rs, QEMUFile *f, + RAMBlock *block, ram_addr_t off= set, uint64_t *bytes_transferred) { int idx, thread_count, bytes_xmit =3D -1, pages =3D -1; @@ -906,7 +907,7 @@ static int compress_page_with_multi_thread(QEMUFile *f,= RAMBlock *block, qemu_cond_signal(&comp_param[idx].cond); qemu_mutex_unlock(&comp_param[idx].mutex); pages =3D 1; - acct_info.norm_pages++; + rs->norm_pages++; *bytes_transferred +=3D bytes_xmit; break; } @@ -958,7 +959,7 @@ static int ram_save_compressed_page(RAMState *rs, Migra= tionState *ms, if (ret !=3D RAM_SAVE_CONTROL_NOT_SUPP) { if (ret !=3D RAM_SAVE_CONTROL_DELAYED) { if (bytes_xmit > 0) { - acct_info.norm_pages++; + rs->norm_pages++; } else if (bytes_xmit =3D=3D 0) { rs->zero_pages++; } @@ -981,7 +982,7 @@ static int ram_save_compressed_page(RAMState *rs, Migra= tionState *ms, migrate_compress_level()); if (blen > 0) { *bytes_transferred +=3D bytes_xmit + blen; - acct_info.norm_pages++; + rs->norm_pages++; pages =3D 1; } else { qemu_file_set_error(f, blen); @@ -995,7 +996,7 @@ static int ram_save_compressed_page(RAMState *rs, Migra= tionState *ms, offset |=3D RAM_SAVE_FLAG_CONTINUE; pages =3D save_zero_page(rs, f, block, offset, p, bytes_transf= erred); if (pages =3D=3D -1) { - pages =3D compress_page_with_multi_thread(f, block, offset, + pages =3D compress_page_with_multi_thread(rs, f, block, of= fset, bytes_transferred); } else { ram_release_pages(ms, block->idstr, pss->offset, pages); @@ -1417,7 +1418,7 @@ void acct_update_position(QEMUFile *f, size_t size, b= ool zero) if (zero) { ram_state.zero_pages +=3D pages; } else { - acct_info.norm_pages +=3D pages; + ram_state.norm_pages +=3D pages; bytes_transferred +=3D size; qemu_update_position(f, size); } @@ -1929,6 +1930,7 @@ static int ram_save_init_globals(RAMState *rs) rs->dirty_rate_high_cnt =3D 0; rs->bitmap_sync_count =3D 0; rs->zero_pages =3D 0; + rs->norm_pages =3D 0; migration_bitmap_sync_init(rs); qemu_mutex_init(&migration_bitmap_mutex); =20 --=20 2.9.3 From nobody Thu Nov 6 13:36:10 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 1489586379957233.80927845180452; Wed, 15 Mar 2017 06:59:39 -0700 (PDT) Received: from localhost ([::1]:37430 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1co9Sk-0006Hs-BB for importer@patchew.org; Wed, 15 Mar 2017 09:59:38 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:53654) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1co9KB-0007M7-1y for qemu-devel@nongnu.org; Wed, 15 Mar 2017 09:50:48 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1co9KA-0003Oh-AL for qemu-devel@nongnu.org; Wed, 15 Mar 2017 09:50:47 -0400 Received: from mx1.redhat.com ([209.132.183.28]:57442) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1co9KA-0003Nr-5I for qemu-devel@nongnu.org; Wed, 15 Mar 2017 09:50:46 -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 224193B731 for ; Wed, 15 Mar 2017 13:50:46 +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 v2FDoNUi002305; Wed, 15 Mar 2017 09:50:43 -0400 DMARC-Filter: OpenDMARC Filter v1.3.2 mx1.redhat.com 224193B731 Authentication-Results: ext-mx06.extmail.prod.ext.phx2.redhat.com; dmarc=none (p=none dis=none) header.from=redhat.com Authentication-Results: ext-mx06.extmail.prod.ext.phx2.redhat.com; spf=pass smtp.mailfrom=quintela@redhat.com DKIM-Filter: OpenDKIM Filter v2.11.0 mx1.redhat.com 224193B731 From: Juan Quintela To: qemu-devel@nongnu.org Date: Wed, 15 Mar 2017 14:50:03 +0100 Message-Id: <20170315135021.6978-14-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.30]); Wed, 15 Mar 2017 13:50:46 +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 13/31] ram: Remove norm_mig_bytes_transferred 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" Its value can be calculated by other exported. Signed-off-by: Juan Quintela Reviewed-by: Dr. David Alan Gilbert --- include/migration/migration.h | 1 - migration/migration.c | 3 ++- migration/ram.c | 5 ----- 3 files changed, 2 insertions(+), 7 deletions(-) diff --git a/include/migration/migration.h b/include/migration/migration.h index 9c83951..84cef4b 100644 --- a/include/migration/migration.h +++ b/include/migration/migration.h @@ -277,7 +277,6 @@ void free_xbzrle_decoded_buf(void); void acct_update_position(QEMUFile *f, size_t size, bool zero); =20 uint64_t dup_mig_pages_transferred(void); -uint64_t norm_mig_bytes_transferred(void); uint64_t norm_mig_pages_transferred(void); uint64_t xbzrle_mig_bytes_transferred(void); uint64_t xbzrle_mig_pages_transferred(void); diff --git a/migration/migration.c b/migration/migration.c index c3e1b95..46645b6 100644 --- a/migration/migration.c +++ b/migration/migration.c @@ -642,7 +642,8 @@ static void populate_ram_info(MigrationInfo *info, Migr= ationState *s) /* legacy value. It is not used anymore */ info->ram->skipped =3D 0; info->ram->normal =3D norm_mig_pages_transferred(); - info->ram->normal_bytes =3D norm_mig_bytes_transferred(); + info->ram->normal_bytes =3D norm_mig_pages_transferred() * + (1ul << qemu_target_page_bits()); info->ram->mbps =3D s->mbps; info->ram->dirty_sync_count =3D s->dirty_sync_count; info->ram->postcopy_requests =3D s->postcopy_requests; diff --git a/migration/ram.c b/migration/ram.c index 58c7dc7..8caeb4f 100644 --- a/migration/ram.c +++ b/migration/ram.c @@ -191,11 +191,6 @@ uint64_t dup_mig_pages_transferred(void) return ram_state.zero_pages; } =20 -uint64_t norm_mig_bytes_transferred(void) -{ - return ram_state.norm_pages * TARGET_PAGE_SIZE; -} - uint64_t norm_mig_pages_transferred(void) { return ram_state.norm_pages; --=20 2.9.3 From nobody Thu Nov 6 13:36:10 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 1489586315202443.4596110260943; Wed, 15 Mar 2017 06:58:35 -0700 (PDT) Received: from localhost ([::1]:37426 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1co9Rg-0005Nu-U6 for importer@patchew.org; Wed, 15 Mar 2017 09:58:32 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:53664) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1co9KB-0007Mn-OG for qemu-devel@nongnu.org; Wed, 15 Mar 2017 09:50:48 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1co9KA-0003Pu-U9 for qemu-devel@nongnu.org; Wed, 15 Mar 2017 09:50:47 -0400 Received: from mx1.redhat.com ([209.132.183.28]:41986) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1co9KA-0003OS-OB for qemu-devel@nongnu.org; Wed, 15 Mar 2017 09:50:46 -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 B324580462 for ; Wed, 15 Mar 2017 13:50:46 +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 v2FDoNUj002305; Wed, 15 Mar 2017 09:50:45 -0400 DMARC-Filter: OpenDMARC Filter v1.3.2 mx1.redhat.com B324580462 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 B324580462 From: Juan Quintela To: qemu-devel@nongnu.org Date: Wed, 15 Mar 2017 14:50:04 +0100 Message-Id: <20170315135021.6978-15-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:50:46 +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 14/31] ram: Move iterations 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 Reviewed-by: Dr. David Alan Gilbert Reviewed-by: Philippe Mathieu-Daud=C3=A9 --- migration/ram.c | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/migration/ram.c b/migration/ram.c index 8caeb4f..234bdba 100644 --- a/migration/ram.c +++ b/migration/ram.c @@ -164,6 +164,8 @@ struct RAMState { uint64_t zero_pages; /* number of normal transferred pages */ uint64_t norm_pages; + /* Iterations since start */ + uint64_t iterations; }; typedef struct RAMState RAMState; =20 @@ -171,7 +173,6 @@ static RAMState ram_state; =20 /* accounting for migration statistics */ typedef struct AccountingInfo { - uint64_t iterations; uint64_t xbzrle_bytes; uint64_t xbzrle_pages; uint64_t xbzrle_cache_miss; @@ -668,13 +669,13 @@ static void migration_bitmap_sync(RAMState *rs) } =20 if (migrate_use_xbzrle()) { - if (rs->iterations_prev !=3D acct_info.iterations) { + if (rs->iterations_prev !=3D rs->iterations) { acct_info.xbzrle_cache_miss_rate =3D (double)(acct_info.xbzrle_cache_miss - rs->xbzrle_cache_miss_prev) / - (acct_info.iterations - rs->iterations_prev); + (rs->iterations - rs->iterations_prev); } - rs->iterations_prev =3D acct_info.iterations; + rs->iterations_prev =3D rs->iterations; rs->xbzrle_cache_miss_prev =3D acct_info.xbzrle_cache_miss; } s->dirty_pages_rate =3D rs->num_dirty_pages_period * 1000 @@ -1926,6 +1927,7 @@ static int ram_save_init_globals(RAMState *rs) rs->bitmap_sync_count =3D 0; rs->zero_pages =3D 0; rs->norm_pages =3D 0; + rs->iterations =3D 0; migration_bitmap_sync_init(rs); qemu_mutex_init(&migration_bitmap_mutex); =20 @@ -2066,7 +2068,7 @@ static int ram_save_iterate(QEMUFile *f, void *opaque) done =3D 1; break; } - acct_info.iterations++; + rs->iterations++; =20 /* we want to check in the 1st loop, just in case it was the 1st t= ime and we had to sync the dirty bitmap. --=20 2.9.3 From nobody Thu Nov 6 13:36:10 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 1489586462199450.4567671693153; Wed, 15 Mar 2017 07:01:02 -0700 (PDT) Received: from localhost ([::1]:37437 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1co9U4-0007Ry-H2 for importer@patchew.org; Wed, 15 Mar 2017 10:01:00 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:53684) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1co9KD-0007OL-73 for qemu-devel@nongnu.org; Wed, 15 Mar 2017 09:50:50 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1co9KC-0003Sh-BJ for qemu-devel@nongnu.org; Wed, 15 Mar 2017 09:50:49 -0400 Received: from mx1.redhat.com ([209.132.183.28]:48462) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1co9KC-0003RN-5N for qemu-devel@nongnu.org; Wed, 15 Mar 2017 09:50:48 -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 2783313A60 for ; Wed, 15 Mar 2017 13:50:48 +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 v2FDoNUk002305; Wed, 15 Mar 2017 09:50:46 -0400 DMARC-Filter: OpenDMARC Filter v1.3.2 mx1.redhat.com 2783313A60 Authentication-Results: ext-mx05.extmail.prod.ext.phx2.redhat.com; dmarc=none (p=none dis=none) header.from=redhat.com Authentication-Results: ext-mx05.extmail.prod.ext.phx2.redhat.com; spf=pass smtp.mailfrom=quintela@redhat.com DKIM-Filter: OpenDKIM Filter v2.11.0 mx1.redhat.com 2783313A60 From: Juan Quintela To: qemu-devel@nongnu.org Date: Wed, 15 Mar 2017 14:50:05 +0100 Message-Id: <20170315135021.6978-16-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.29]); Wed, 15 Mar 2017 13:50:48 +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 15/31] ram: Move xbzrle_bytes 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 | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/migration/ram.c b/migration/ram.c index 234bdba..02bbe53 100644 --- a/migration/ram.c +++ b/migration/ram.c @@ -166,6 +166,8 @@ struct RAMState { uint64_t norm_pages; /* Iterations since start */ uint64_t iterations; + /* xbzrle transmitted bytes */ + uint64_t xbzrle_bytes; }; typedef struct RAMState RAMState; =20 @@ -173,7 +175,6 @@ static RAMState ram_state; =20 /* accounting for migration statistics */ typedef struct AccountingInfo { - uint64_t xbzrle_bytes; uint64_t xbzrle_pages; uint64_t xbzrle_cache_miss; double xbzrle_cache_miss_rate; @@ -199,7 +200,7 @@ uint64_t norm_mig_pages_transferred(void) =20 uint64_t xbzrle_mig_bytes_transferred(void) { - return acct_info.xbzrle_bytes; + return ram_state.xbzrle_bytes; } =20 uint64_t xbzrle_mig_pages_transferred(void) @@ -527,7 +528,7 @@ static int save_xbzrle_page(QEMUFile *f, RAMState *rs, = uint8_t **current_data, qemu_put_buffer(f, XBZRLE.encoded_buf, encoded_len); bytes_xbzrle +=3D encoded_len + 1 + 2; acct_info.xbzrle_pages++; - acct_info.xbzrle_bytes +=3D bytes_xbzrle; + rs->xbzrle_bytes +=3D bytes_xbzrle; *bytes_transferred +=3D bytes_xbzrle; =20 return 1; @@ -1928,6 +1929,7 @@ static int ram_save_init_globals(RAMState *rs) rs->zero_pages =3D 0; rs->norm_pages =3D 0; rs->iterations =3D 0; + rs->xbzrle_bytes =3D 0; migration_bitmap_sync_init(rs); qemu_mutex_init(&migration_bitmap_mutex); =20 --=20 2.9.3 From nobody Thu Nov 6 13:36:10 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 1489586455641822.9355830702838; Wed, 15 Mar 2017 07:00:55 -0700 (PDT) Received: from localhost ([::1]:37434 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1co9Tu-0007KK-1B for importer@patchew.org; Wed, 15 Mar 2017 10:00:50 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:53706) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1co9KE-0007Px-Nj for qemu-devel@nongnu.org; Wed, 15 Mar 2017 09:50:56 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1co9KD-0003U7-UV for qemu-devel@nongnu.org; Wed, 15 Mar 2017 09:50:50 -0400 Received: from mx1.redhat.com ([209.132.183.28]:57554) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1co9KD-0003Sv-P7 for qemu-devel@nongnu.org; Wed, 15 Mar 2017 09:50:49 -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 B66E3369C4 for ; Wed, 15 Mar 2017 13:50:49 +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 v2FDoNUl002305; Wed, 15 Mar 2017 09:50:48 -0400 DMARC-Filter: OpenDMARC Filter v1.3.2 mx1.redhat.com B66E3369C4 Authentication-Results: ext-mx06.extmail.prod.ext.phx2.redhat.com; dmarc=none (p=none dis=none) header.from=redhat.com Authentication-Results: ext-mx06.extmail.prod.ext.phx2.redhat.com; spf=pass smtp.mailfrom=quintela@redhat.com DKIM-Filter: OpenDKIM Filter v2.11.0 mx1.redhat.com B66E3369C4 From: Juan Quintela To: qemu-devel@nongnu.org Date: Wed, 15 Mar 2017 14:50:06 +0100 Message-Id: <20170315135021.6978-17-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.30]); Wed, 15 Mar 2017 13:50:49 +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 16/31] ram: Move xbzrle_pages 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 | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/migration/ram.c b/migration/ram.c index 02bbe53..ce703e5 100644 --- a/migration/ram.c +++ b/migration/ram.c @@ -168,6 +168,8 @@ struct RAMState { uint64_t iterations; /* xbzrle transmitted bytes */ uint64_t xbzrle_bytes; + /* xbzrle transmmited pages */ + uint64_t xbzrle_pages; }; typedef struct RAMState RAMState; =20 @@ -175,7 +177,6 @@ static RAMState ram_state; =20 /* accounting for migration statistics */ typedef struct AccountingInfo { - uint64_t xbzrle_pages; uint64_t xbzrle_cache_miss; double xbzrle_cache_miss_rate; uint64_t xbzrle_overflows; @@ -205,7 +206,7 @@ uint64_t xbzrle_mig_bytes_transferred(void) =20 uint64_t xbzrle_mig_pages_transferred(void) { - return acct_info.xbzrle_pages; + return ram_state.xbzrle_pages; } =20 uint64_t xbzrle_mig_pages_cache_miss(void) @@ -527,7 +528,7 @@ static int save_xbzrle_page(QEMUFile *f, RAMState *rs, = uint8_t **current_data, qemu_put_be16(f, encoded_len); qemu_put_buffer(f, XBZRLE.encoded_buf, encoded_len); bytes_xbzrle +=3D encoded_len + 1 + 2; - acct_info.xbzrle_pages++; + rs->xbzrle_pages++; rs->xbzrle_bytes +=3D bytes_xbzrle; *bytes_transferred +=3D bytes_xbzrle; =20 @@ -1930,6 +1931,7 @@ static int ram_save_init_globals(RAMState *rs) rs->norm_pages =3D 0; rs->iterations =3D 0; rs->xbzrle_bytes =3D 0; + rs->xbzrle_pages =3D 0; migration_bitmap_sync_init(rs); qemu_mutex_init(&migration_bitmap_mutex); =20 --=20 2.9.3 From nobody Thu Nov 6 13:36:10 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 1489586320922261.25157366184817; Wed, 15 Mar 2017 06:58:40 -0700 (PDT) Received: from localhost ([::1]:37428 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1co9Rm-0005Sk-Ku for importer@patchew.org; Wed, 15 Mar 2017 09:58:38 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:53772) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1co9KK-0007Sy-22 for qemu-devel@nongnu.org; Wed, 15 Mar 2017 09:50:57 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1co9KF-0003XK-Eu for qemu-devel@nongnu.org; Wed, 15 Mar 2017 09:50:55 -0400 Received: from mx1.redhat.com ([209.132.183.28]:53612) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1co9KF-0003Vo-8d for qemu-devel@nongnu.org; Wed, 15 Mar 2017 09:50:51 -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 40D3E80F94 for ; Wed, 15 Mar 2017 13:50:51 +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 v2FDoNUm002305; Wed, 15 Mar 2017 09:50:49 -0400 DMARC-Filter: OpenDMARC Filter v1.3.2 mx1.redhat.com 40D3E80F94 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 40D3E80F94 From: Juan Quintela To: qemu-devel@nongnu.org Date: Wed, 15 Mar 2017 14:50:07 +0100 Message-Id: <20170315135021.6978-18-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:50:51 +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 17/31] ram: Move xbzrle_cache_miss 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 | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/migration/ram.c b/migration/ram.c index ce703e5..8470db0 100644 --- a/migration/ram.c +++ b/migration/ram.c @@ -170,6 +170,8 @@ struct RAMState { uint64_t xbzrle_bytes; /* xbzrle transmmited pages */ uint64_t xbzrle_pages; + /* xbzrle number of cache miss */ + uint64_t xbzrle_cache_miss; }; typedef struct RAMState RAMState; =20 @@ -177,7 +179,6 @@ static RAMState ram_state; =20 /* accounting for migration statistics */ typedef struct AccountingInfo { - uint64_t xbzrle_cache_miss; double xbzrle_cache_miss_rate; uint64_t xbzrle_overflows; } AccountingInfo; @@ -211,7 +212,7 @@ uint64_t xbzrle_mig_pages_transferred(void) =20 uint64_t xbzrle_mig_pages_cache_miss(void) { - return acct_info.xbzrle_cache_miss; + return ram_state.xbzrle_cache_miss; } =20 double xbzrle_mig_cache_miss_rate(void) @@ -480,7 +481,7 @@ static int save_xbzrle_page(QEMUFile *f, RAMState *rs, = uint8_t **current_data, uint8_t *prev_cached_page; =20 if (!cache_is_cached(XBZRLE.cache, current_addr, rs->bitmap_sync_count= )) { - acct_info.xbzrle_cache_miss++; + rs->xbzrle_cache_miss++; if (!last_stage) { if (cache_insert(XBZRLE.cache, current_addr, *current_data, rs->bitmap_sync_count) =3D=3D -1) { @@ -673,12 +674,12 @@ static void migration_bitmap_sync(RAMState *rs) if (migrate_use_xbzrle()) { if (rs->iterations_prev !=3D rs->iterations) { acct_info.xbzrle_cache_miss_rate =3D - (double)(acct_info.xbzrle_cache_miss - + (double)(rs->xbzrle_cache_miss - rs->xbzrle_cache_miss_prev) / (rs->iterations - rs->iterations_prev); } rs->iterations_prev =3D rs->iterations; - rs->xbzrle_cache_miss_prev =3D acct_info.xbzrle_cache_miss; + rs->xbzrle_cache_miss_prev =3D rs->xbzrle_cache_miss; } s->dirty_pages_rate =3D rs->num_dirty_pages_period * 1000 / (end_time - rs->start_time); @@ -1932,6 +1933,7 @@ static int ram_save_init_globals(RAMState *rs) rs->iterations =3D 0; rs->xbzrle_bytes =3D 0; rs->xbzrle_pages =3D 0; + rs->xbzrle_cache_miss =3D 0; migration_bitmap_sync_init(rs); qemu_mutex_init(&migration_bitmap_mutex); =20 --=20 2.9.3 From nobody Thu Nov 6 13:36:10 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 1489586618989572.5456236892326; Wed, 15 Mar 2017 07:03:38 -0700 (PDT) Received: from localhost ([::1]:37454 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1co9WX-00018Q-VO for importer@patchew.org; Wed, 15 Mar 2017 10:03:34 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:53773) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1co9KK-0007Sz-27 for qemu-devel@nongnu.org; Wed, 15 Mar 2017 09:50:56 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1co9KG-0003Zu-U8 for qemu-devel@nongnu.org; Wed, 15 Mar 2017 09:50:55 -0400 Received: from mx1.redhat.com ([209.132.183.28]:12012) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1co9KG-0003Yd-Ni for qemu-devel@nongnu.org; Wed, 15 Mar 2017 09:50:52 -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 B3756A89D for ; Wed, 15 Mar 2017 13:50:52 +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 v2FDoNUn002305; Wed, 15 Mar 2017 09:50:51 -0400 DMARC-Filter: OpenDMARC Filter v1.3.2 mx1.redhat.com B3756A89D Authentication-Results: ext-mx05.extmail.prod.ext.phx2.redhat.com; dmarc=none (p=none dis=none) header.from=redhat.com Authentication-Results: ext-mx05.extmail.prod.ext.phx2.redhat.com; spf=pass smtp.mailfrom=quintela@redhat.com DKIM-Filter: OpenDKIM Filter v2.11.0 mx1.redhat.com B3756A89D From: Juan Quintela To: qemu-devel@nongnu.org Date: Wed, 15 Mar 2017 14:50:08 +0100 Message-Id: <20170315135021.6978-19-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.29]); Wed, 15 Mar 2017 13:50:52 +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 18/31] ram: move xbzrle_cache_miss_rate 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 | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/migration/ram.c b/migration/ram.c index 8470db0..23a7317 100644 --- a/migration/ram.c +++ b/migration/ram.c @@ -172,6 +172,8 @@ struct RAMState { uint64_t xbzrle_pages; /* xbzrle number of cache miss */ uint64_t xbzrle_cache_miss; + /* xbzrle miss rate */ + double xbzrle_cache_miss_rate; }; typedef struct RAMState RAMState; =20 @@ -179,7 +181,6 @@ static RAMState ram_state; =20 /* accounting for migration statistics */ typedef struct AccountingInfo { - double xbzrle_cache_miss_rate; uint64_t xbzrle_overflows; } AccountingInfo; =20 @@ -217,7 +218,7 @@ uint64_t xbzrle_mig_pages_cache_miss(void) =20 double xbzrle_mig_cache_miss_rate(void) { - return acct_info.xbzrle_cache_miss_rate; + return ram_state.xbzrle_cache_miss_rate; } =20 uint64_t xbzrle_mig_pages_overflow(void) @@ -673,7 +674,7 @@ static void migration_bitmap_sync(RAMState *rs) =20 if (migrate_use_xbzrle()) { if (rs->iterations_prev !=3D rs->iterations) { - acct_info.xbzrle_cache_miss_rate =3D + rs->xbzrle_cache_miss_rate =3D (double)(rs->xbzrle_cache_miss - rs->xbzrle_cache_miss_prev) / (rs->iterations - rs->iterations_prev); @@ -1934,6 +1935,7 @@ static int ram_save_init_globals(RAMState *rs) rs->xbzrle_bytes =3D 0; rs->xbzrle_pages =3D 0; rs->xbzrle_cache_miss =3D 0; + rs->xbzrle_cache_miss_rate =3D 0; migration_bitmap_sync_init(rs); qemu_mutex_init(&migration_bitmap_mutex); =20 --=20 2.9.3 From nobody Thu Nov 6 13:36:10 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 1489586765218523.281829204428; Wed, 15 Mar 2017 07:06:05 -0700 (PDT) Received: from localhost ([::1]:37463 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1co9Yt-0003Jx-M9 for importer@patchew.org; Wed, 15 Mar 2017 10:05:59 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:53774) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1co9KK-0007T0-2C for qemu-devel@nongnu.org; Wed, 15 Mar 2017 09:50:56 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1co9KI-0003cy-JD for qemu-devel@nongnu.org; Wed, 15 Mar 2017 09:50:55 -0400 Received: from mx1.redhat.com ([209.132.183.28]:53148) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1co9KI-0003bH-8Q for qemu-devel@nongnu.org; Wed, 15 Mar 2017 09:50:54 -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 4160A635D2 for ; Wed, 15 Mar 2017 13:50:54 +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 v2FDoNUo002305; Wed, 15 Mar 2017 09:50:52 -0400 DMARC-Filter: OpenDMARC Filter v1.3.2 mx1.redhat.com 4160A635D2 Authentication-Results: ext-mx10.extmail.prod.ext.phx2.redhat.com; dmarc=none (p=none dis=none) header.from=redhat.com Authentication-Results: ext-mx10.extmail.prod.ext.phx2.redhat.com; spf=pass smtp.mailfrom=quintela@redhat.com DKIM-Filter: OpenDKIM Filter v2.11.0 mx1.redhat.com 4160A635D2 From: Juan Quintela To: qemu-devel@nongnu.org Date: Wed, 15 Mar 2017 14:50:09 +0100 Message-Id: <20170315135021.6978-20-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.39]); Wed, 15 Mar 2017 13:50:54 +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 19/31] ram: move xbzrle_overflows 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" Once there, remove the now unused AccountingInfo struct and var. Signed-off-by: Juan Quintela --- migration/ram.c | 21 +++++---------------- 1 file changed, 5 insertions(+), 16 deletions(-) diff --git a/migration/ram.c b/migration/ram.c index 23a7317..75ad17f 100644 --- a/migration/ram.c +++ b/migration/ram.c @@ -174,23 +174,13 @@ struct RAMState { uint64_t xbzrle_cache_miss; /* xbzrle miss rate */ double xbzrle_cache_miss_rate; + /* xbzrle number of overflows */ + uint64_t xbzrle_overflows; }; typedef struct RAMState RAMState; =20 static RAMState ram_state; =20 -/* accounting for migration statistics */ -typedef struct AccountingInfo { - uint64_t xbzrle_overflows; -} AccountingInfo; - -static AccountingInfo acct_info; - -static void acct_clear(void) -{ - memset(&acct_info, 0, sizeof(acct_info)); -} - uint64_t dup_mig_pages_transferred(void) { return ram_state.zero_pages; @@ -223,7 +213,7 @@ double xbzrle_mig_cache_miss_rate(void) =20 uint64_t xbzrle_mig_pages_overflow(void) { - return acct_info.xbzrle_overflows; + return ram_state.xbzrle_overflows; } =20 static QemuMutex migration_bitmap_mutex; @@ -510,7 +500,7 @@ static int save_xbzrle_page(QEMUFile *f, RAMState *rs, = uint8_t **current_data, return 0; } else if (encoded_len =3D=3D -1) { trace_save_xbzrle_page_overflow(); - acct_info.xbzrle_overflows++; + rs->xbzrle_overflows++; /* update data in the cache */ if (!last_stage) { memcpy(prev_cached_page, *current_data, TARGET_PAGE_SIZE); @@ -1936,6 +1926,7 @@ static int ram_save_init_globals(RAMState *rs) rs->xbzrle_pages =3D 0; rs->xbzrle_cache_miss =3D 0; rs->xbzrle_cache_miss_rate =3D 0; + rs->xbzrle_overflows =3D 0; migration_bitmap_sync_init(rs); qemu_mutex_init(&migration_bitmap_mutex); =20 @@ -1966,8 +1957,6 @@ static int ram_save_init_globals(RAMState *rs) XBZRLE.encoded_buf =3D NULL; return -1; } - - acct_clear(); } =20 /* For memory_global_dirty_log_start below. */ --=20 2.9.3 From nobody Thu Nov 6 13:36:10 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 14895869099324.720895955564629; Wed, 15 Mar 2017 07:08:29 -0700 (PDT) Received: from localhost ([::1]:37478 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1co9bB-0005T5-IJ for importer@patchew.org; Wed, 15 Mar 2017 10:08:21 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:53802) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1co9KL-0007U5-DH for qemu-devel@nongnu.org; Wed, 15 Mar 2017 09:50:58 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1co9KK-0003f3-2S for qemu-devel@nongnu.org; Wed, 15 Mar 2017 09:50:57 -0400 Received: from mx1.redhat.com ([209.132.183.28]:47552) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1co9KJ-0003dj-Ou for qemu-devel@nongnu.org; Wed, 15 Mar 2017 09:50:55 -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 B949A4DD60 for ; Wed, 15 Mar 2017 13:50:55 +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 v2FDoNUp002305; Wed, 15 Mar 2017 09:50:54 -0400 DMARC-Filter: OpenDMARC Filter v1.3.2 mx1.redhat.com B949A4DD60 Authentication-Results: ext-mx09.extmail.prod.ext.phx2.redhat.com; dmarc=none (p=none dis=none) header.from=redhat.com Authentication-Results: ext-mx09.extmail.prod.ext.phx2.redhat.com; spf=pass smtp.mailfrom=quintela@redhat.com DKIM-Filter: OpenDKIM Filter v2.11.0 mx1.redhat.com B949A4DD60 From: Juan Quintela To: qemu-devel@nongnu.org Date: Wed, 15 Mar 2017 14:50:10 +0100 Message-Id: <20170315135021.6978-21-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.38]); Wed, 15 Mar 2017 13:50:55 +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 20/31] ram: move migration_dirty_pages to 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 | 38 ++++++++++++++++++++------------------ 1 file changed, 20 insertions(+), 18 deletions(-) diff --git a/migration/ram.c b/migration/ram.c index 75ad17f..606e836 100644 --- a/migration/ram.c +++ b/migration/ram.c @@ -176,6 +176,8 @@ struct RAMState { double xbzrle_cache_miss_rate; /* xbzrle number of overflows */ uint64_t xbzrle_overflows; + /* number of dirty bits in the bitmap */ + uint64_t migration_dirty_pages; }; typedef struct RAMState RAMState; =20 @@ -216,8 +218,12 @@ uint64_t xbzrle_mig_pages_overflow(void) return ram_state.xbzrle_overflows; } =20 +static ram_addr_t ram_save_remaining(void) +{ + return ram_state.migration_dirty_pages; +} + static QemuMutex migration_bitmap_mutex; -static uint64_t migration_dirty_pages; =20 /* used by the search for pages to send */ struct PageSearchStatus { @@ -559,7 +565,7 @@ ram_addr_t migration_bitmap_find_dirty(RAMState *rs, RA= MBlock *rb, return (next - base) << TARGET_PAGE_BITS; } =20 -static inline bool migration_bitmap_clear_dirty(ram_addr_t addr) +static inline bool migration_bitmap_clear_dirty(RAMState *rs, ram_addr_t a= ddr) { bool ret; int nr =3D addr >> TARGET_PAGE_BITS; @@ -568,16 +574,17 @@ static inline bool migration_bitmap_clear_dirty(ram_a= ddr_t addr) ret =3D test_and_clear_bit(nr, bitmap); =20 if (ret) { - migration_dirty_pages--; + rs->migration_dirty_pages--; } return ret; } =20 -static void migration_bitmap_sync_range(ram_addr_t start, ram_addr_t lengt= h) +static void migration_bitmap_sync_range(RAMState *rs, ram_addr_t start, + ram_addr_t length) { unsigned long *bitmap; bitmap =3D atomic_rcu_read(&migration_bitmap_rcu)->bmap; - migration_dirty_pages +=3D + rs-> migration_dirty_pages +=3D cpu_physical_memory_sync_dirty_bitmap(bitmap, start, length); } =20 @@ -610,7 +617,7 @@ uint64_t ram_pagesize_summary(void) static void migration_bitmap_sync(RAMState *rs) { RAMBlock *block; - uint64_t num_dirty_pages_init =3D migration_dirty_pages; + uint64_t num_dirty_pages_init =3D rs->migration_dirty_pages; MigrationState *s =3D migrate_get_current(); int64_t end_time; int64_t bytes_xfer_now; @@ -631,14 +638,14 @@ static void migration_bitmap_sync(RAMState *rs) qemu_mutex_lock(&migration_bitmap_mutex); rcu_read_lock(); QLIST_FOREACH_RCU(block, &ram_list.blocks, next) { - migration_bitmap_sync_range(block->offset, block->used_length); + migration_bitmap_sync_range(rs, block->offset, block->used_length); } rcu_read_unlock(); qemu_mutex_unlock(&migration_bitmap_mutex); =20 - trace_migration_bitmap_sync_end(migration_dirty_pages + trace_migration_bitmap_sync_end(rs->migration_dirty_pages - num_dirty_pages_init); - rs->num_dirty_pages_period +=3D migration_dirty_pages - num_dirty_page= s_init; + rs->num_dirty_pages_period +=3D rs->migration_dirty_pages - num_dirty_= pages_init; end_time =3D qemu_clock_get_ms(QEMU_CLOCK_REALTIME); =20 /* more than 1 second =3D 1000 millisecons */ @@ -1264,7 +1271,7 @@ static int ram_save_target_page(RAMState *rs, Migrati= onState *ms, QEMUFile *f, int res =3D 0; =20 /* Check the pages is dirty and if it is send it */ - if (migration_bitmap_clear_dirty(dirty_ram_abs)) { + 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, @@ -1414,11 +1421,6 @@ void acct_update_position(QEMUFile *f, size_t size, = bool zero) } } =20 -static ram_addr_t ram_save_remaining(void) -{ - return migration_dirty_pages; -} - uint64_t ram_bytes_remaining(void) { return ram_save_remaining() * TARGET_PAGE_SIZE; @@ -1517,7 +1519,7 @@ void migration_bitmap_extend(ram_addr_t old, ram_addr= _t new) =20 atomic_rcu_set(&migration_bitmap_rcu, bitmap); qemu_mutex_unlock(&migration_bitmap_mutex); - migration_dirty_pages +=3D new - old; + ram_state.migration_dirty_pages +=3D new - old; call_rcu(old_bitmap, migration_bitmap_free, rcu); } } @@ -1771,7 +1773,7 @@ static void postcopy_chunk_hostpages_pass(MigrationSt= ate *ms, bool unsent_pass, * Remark them as dirty, updating the count for any pages * that weren't previously dirty. */ - migration_dirty_pages +=3D !test_and_set_bit(page, bitmap); + ram_state.migration_dirty_pages +=3D !test_and_set_bit(pag= e, bitmap); } } =20 @@ -1984,7 +1986,7 @@ static int ram_save_init_globals(RAMState *rs) * Count the total number of pages used by ram blocks not including any * gaps due to alignment or unplugs. */ - migration_dirty_pages =3D ram_bytes_total() >> TARGET_PAGE_BITS; + rs->migration_dirty_pages =3D ram_bytes_total() >> TARGET_PAGE_BITS; =20 memory_global_dirty_log_start(); migration_bitmap_sync(rs); --=20 2.9.3 From nobody Thu Nov 6 13:36:10 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 1489586608130268.69106689560033; Wed, 15 Mar 2017 07:03:28 -0700 (PDT) Received: from localhost ([::1]:37451 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1co9WN-0000yb-Fn for importer@patchew.org; Wed, 15 Mar 2017 10:03:23 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:53822) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1co9KM-0007V0-EM for qemu-devel@nongnu.org; Wed, 15 Mar 2017 09:50:59 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1co9KL-0003hS-Ig for qemu-devel@nongnu.org; Wed, 15 Mar 2017 09:50:58 -0400 Received: from mx1.redhat.com ([209.132.183.28]:53204) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1co9KL-0003g9-9O for qemu-devel@nongnu.org; Wed, 15 Mar 2017 09:50:57 -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 43748635C5 for ; Wed, 15 Mar 2017 13:50:57 +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 v2FDoNUq002305; Wed, 15 Mar 2017 09:50:55 -0400 DMARC-Filter: OpenDMARC Filter v1.3.2 mx1.redhat.com 43748635C5 Authentication-Results: ext-mx10.extmail.prod.ext.phx2.redhat.com; dmarc=none (p=none dis=none) header.from=redhat.com Authentication-Results: ext-mx10.extmail.prod.ext.phx2.redhat.com; spf=pass smtp.mailfrom=quintela@redhat.com DKIM-Filter: OpenDKIM Filter v2.11.0 mx1.redhat.com 43748635C5 From: Juan Quintela To: qemu-devel@nongnu.org Date: Wed, 15 Mar 2017 14:50:11 +0100 Message-Id: <20170315135021.6978-22-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.39]); Wed, 15 Mar 2017 13:50:57 +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 21/31] ram: Everything was init to zero, so use memset 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" And then init only things that are not zero by default. Signed-off-by: Juan Quintela Reviewed-by: Dr. David Alan Gilbert --- migration/ram.c | 25 +++---------------------- 1 file changed, 3 insertions(+), 22 deletions(-) diff --git a/migration/ram.c b/migration/ram.c index 606e836..7f56b5f 100644 --- a/migration/ram.c +++ b/migration/ram.c @@ -588,15 +588,6 @@ static void migration_bitmap_sync_range(RAMState *rs, = ram_addr_t start, cpu_physical_memory_sync_dirty_bitmap(bitmap, start, length); } =20 -static void migration_bitmap_sync_init(RAMState *rs) -{ - rs->start_time =3D 0; - rs->bytes_xfer_prev =3D 0; - rs->num_dirty_pages_period =3D 0; - rs->xbzrle_cache_miss_prev =3D 0; - rs->iterations_prev =3D 0; -} - /* Returns a summary bitmap of the page sizes of all RAMBlocks; * for VMs with just normal pages this is equivalent to the * host page size. If it's got some huge pages then it's the OR @@ -1915,21 +1906,11 @@ err: return ret; } =20 -static int ram_save_init_globals(RAMState *rs) +static int ram_state_init(RAMState *rs) { int64_t ram_bitmap_pages; /* Size of bitmap in pages, including gaps */ =20 - rs->dirty_rate_high_cnt =3D 0; - rs->bitmap_sync_count =3D 0; - rs->zero_pages =3D 0; - rs->norm_pages =3D 0; - rs->iterations =3D 0; - rs->xbzrle_bytes =3D 0; - rs->xbzrle_pages =3D 0; - rs->xbzrle_cache_miss =3D 0; - rs->xbzrle_cache_miss_rate =3D 0; - rs->xbzrle_overflows =3D 0; - migration_bitmap_sync_init(rs); + memset(rs, 0, sizeof(*rs)); qemu_mutex_init(&migration_bitmap_mutex); =20 if (migrate_use_xbzrle()) { @@ -2010,7 +1991,7 @@ static int ram_save_setup(QEMUFile *f, void *opaque) =20 /* migration has already setup the bitmap, reuse it. */ if (!migration_in_colo_state()) { - if (ram_save_init_globals(rs) < 0) { + if (ram_state_init(rs) < 0) { return -1; } } --=20 2.9.3 From nobody Thu Nov 6 13:36:10 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 1489586752322552.9114091679031; Wed, 15 Mar 2017 07:05:52 -0700 (PDT) Received: from localhost ([::1]:37460 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1co9Yf-00039m-Uv for importer@patchew.org; Wed, 15 Mar 2017 10:05:46 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:53857) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1co9KO-0007Wn-5o for qemu-devel@nongnu.org; Wed, 15 Mar 2017 09:51:01 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1co9KN-0003k6-2e for qemu-devel@nongnu.org; Wed, 15 Mar 2017 09:51:00 -0400 Received: from mx1.redhat.com ([209.132.183.28]:53768) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1co9KM-0003io-QY for qemu-devel@nongnu.org; Wed, 15 Mar 2017 09:50:59 -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 C044680F8E for ; Wed, 15 Mar 2017 13:50:58 +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 v2FDoNUr002305; Wed, 15 Mar 2017 09:50:57 -0400 DMARC-Filter: OpenDMARC Filter v1.3.2 mx1.redhat.com C044680F8E 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 C044680F8E From: Juan Quintela To: qemu-devel@nongnu.org Date: Wed, 15 Mar 2017 14:50:12 +0100 Message-Id: <20170315135021.6978-23-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:50:58 +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 22/31] ram: move migration_bitmap_mutex 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 | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/migration/ram.c b/migration/ram.c index 7f56b5f..c14293c 100644 --- a/migration/ram.c +++ b/migration/ram.c @@ -178,6 +178,8 @@ struct RAMState { uint64_t xbzrle_overflows; /* number of dirty bits in the bitmap */ uint64_t migration_dirty_pages; + /* protects modification of the bitmap */ + QemuMutex bitmap_mutex; }; typedef struct RAMState RAMState; =20 @@ -223,8 +225,6 @@ static ram_addr_t ram_save_remaining(void) return ram_state.migration_dirty_pages; } =20 -static QemuMutex migration_bitmap_mutex; - /* used by the search for pages to send */ struct PageSearchStatus { /* Current block being searched */ @@ -626,13 +626,13 @@ static void migration_bitmap_sync(RAMState *rs) trace_migration_bitmap_sync_start(); memory_global_dirty_log_sync(); =20 - qemu_mutex_lock(&migration_bitmap_mutex); + qemu_mutex_lock(&rs->bitmap_mutex); rcu_read_lock(); QLIST_FOREACH_RCU(block, &ram_list.blocks, next) { migration_bitmap_sync_range(rs, block->offset, block->used_length); } rcu_read_unlock(); - qemu_mutex_unlock(&migration_bitmap_mutex); + qemu_mutex_unlock(&rs->bitmap_mutex); =20 trace_migration_bitmap_sync_end(rs->migration_dirty_pages - num_dirty_pages_init); @@ -1498,7 +1498,7 @@ void migration_bitmap_extend(ram_addr_t old, ram_addr= _t new) * it is safe to migration if migration_bitmap is cleared bit * at the same time. */ - qemu_mutex_lock(&migration_bitmap_mutex); + qemu_mutex_lock(&ram_state.bitmap_mutex); bitmap_copy(bitmap->bmap, old_bitmap->bmap, old); bitmap_set(bitmap->bmap, old, new - old); =20 @@ -1509,7 +1509,7 @@ void migration_bitmap_extend(ram_addr_t old, ram_addr= _t new) bitmap->unsentmap =3D NULL; =20 atomic_rcu_set(&migration_bitmap_rcu, bitmap); - qemu_mutex_unlock(&migration_bitmap_mutex); + qemu_mutex_unlock(&ram_state.bitmap_mutex); ram_state.migration_dirty_pages +=3D new - old; call_rcu(old_bitmap, migration_bitmap_free, rcu); } @@ -1911,7 +1911,7 @@ static int ram_state_init(RAMState *rs) int64_t ram_bitmap_pages; /* Size of bitmap in pages, including gaps */ =20 memset(rs, 0, sizeof(*rs)); - qemu_mutex_init(&migration_bitmap_mutex); + qemu_mutex_init(&rs->bitmap_mutex); =20 if (migrate_use_xbzrle()) { XBZRLE_cache_lock(); --=20 2.9.3 From nobody Thu Nov 6 13:36:10 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 1489586464787194.26975338249338; Wed, 15 Mar 2017 07:01:04 -0700 (PDT) Received: from localhost ([::1]:37436 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1co9U2-0007Ph-SA for importer@patchew.org; Wed, 15 Mar 2017 10:00:58 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:53883) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1co9KQ-0007Z7-3l for qemu-devel@nongnu.org; Wed, 15 Mar 2017 09:51:06 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1co9KO-0003kX-NR for qemu-devel@nongnu.org; Wed, 15 Mar 2017 09:51:02 -0400 Received: from mx1.redhat.com ([209.132.183.28]:57714) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1co9KO-0003kF-Av for qemu-devel@nongnu.org; Wed, 15 Mar 2017 09:51:00 -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 4E7B23B731 for ; Wed, 15 Mar 2017 13:51:00 +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 v2FDoNUs002305; Wed, 15 Mar 2017 09:50:58 -0400 DMARC-Filter: OpenDMARC Filter v1.3.2 mx1.redhat.com 4E7B23B731 Authentication-Results: ext-mx06.extmail.prod.ext.phx2.redhat.com; dmarc=none (p=none dis=none) header.from=redhat.com Authentication-Results: ext-mx06.extmail.prod.ext.phx2.redhat.com; spf=pass smtp.mailfrom=quintela@redhat.com DKIM-Filter: OpenDKIM Filter v2.11.0 mx1.redhat.com 4E7B23B731 From: Juan Quintela To: qemu-devel@nongnu.org Date: Wed, 15 Mar 2017 14:50:13 +0100 Message-Id: <20170315135021.6978-24-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.30]); Wed, 15 Mar 2017 13:51:00 +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 23/31] ram: Move migration_bitmap_rcu 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" Once there, rename the type to be shorter. Signed-off-by: Juan Quintela Reviewed-by: Dr. David Alan Gilbert --- migration/ram.c | 79 ++++++++++++++++++++++++++++++-----------------------= ---- 1 file changed, 42 insertions(+), 37 deletions(-) diff --git a/migration/ram.c b/migration/ram.c index c14293c..d39d185 100644 --- a/migration/ram.c +++ b/migration/ram.c @@ -132,6 +132,19 @@ out: return ret; } =20 +struct RAMBitmap { + struct rcu_head rcu; + /* Main migration bitmap */ + unsigned long *bmap; + /* bitmap of pages that haven't been sent even once + * only maintained and used in postcopy at the moment + * where it's used to send the dirtymap at the start + * of the postcopy phase + */ + unsigned long *unsentmap; +}; +typedef struct RAMBitmap RAMBitmap; + /* State of RAM for migration */ struct RAMState { /* Last block that we have visited searching for dirty pages */ @@ -180,6 +193,8 @@ struct RAMState { uint64_t migration_dirty_pages; /* protects modification of the bitmap */ QemuMutex bitmap_mutex; + /* Ram Bitmap protected by RCU */ + RAMBitmap *ram_bitmap; }; typedef struct RAMState RAMState; =20 @@ -236,18 +251,6 @@ struct PageSearchStatus { }; typedef struct PageSearchStatus PageSearchStatus; =20 -static struct BitmapRcu { - struct rcu_head rcu; - /* Main migration bitmap */ - unsigned long *bmap; - /* bitmap of pages that haven't been sent even once - * only maintained and used in postcopy at the moment - * where it's used to send the dirtymap at the start - * of the postcopy phase - */ - unsigned long *unsentmap; -} *migration_bitmap_rcu; - struct CompressParam { bool done; bool quit; @@ -554,7 +557,7 @@ ram_addr_t migration_bitmap_find_dirty(RAMState *rs, RA= MBlock *rb, =20 unsigned long next; =20 - bitmap =3D atomic_rcu_read(&migration_bitmap_rcu)->bmap; + bitmap =3D atomic_rcu_read(&rs->ram_bitmap)->bmap; if (rs->ram_bulk_stage && nr > base) { next =3D nr + 1; } else { @@ -569,7 +572,7 @@ static inline bool migration_bitmap_clear_dirty(RAMStat= e *rs, ram_addr_t addr) { bool ret; int nr =3D addr >> TARGET_PAGE_BITS; - unsigned long *bitmap =3D atomic_rcu_read(&migration_bitmap_rcu)->bmap; + unsigned long *bitmap =3D atomic_rcu_read(&rs->ram_bitmap)->bmap; =20 ret =3D test_and_clear_bit(nr, bitmap); =20 @@ -583,7 +586,7 @@ static void migration_bitmap_sync_range(RAMState *rs, r= am_addr_t start, ram_addr_t length) { unsigned long *bitmap; - bitmap =3D atomic_rcu_read(&migration_bitmap_rcu)->bmap; + bitmap =3D atomic_rcu_read(&rs->ram_bitmap)->bmap; rs-> migration_dirty_pages +=3D cpu_physical_memory_sync_dirty_bitmap(bitmap, start, length); } @@ -1115,14 +1118,14 @@ static bool get_queued_page(RAMState *rs, Migration= State *ms, PageSearchStatus * */ if (block) { unsigned long *bitmap; - bitmap =3D atomic_rcu_read(&migration_bitmap_rcu)->bmap; + bitmap =3D atomic_rcu_read(&rs->ram_bitmap)->bmap; dirty =3D test_bit(*ram_addr_abs >> TARGET_PAGE_BITS, bitmap); if (!dirty) { trace_get_queued_page_not_dirty( block->idstr, (uint64_t)offset, (uint64_t)*ram_addr_abs, test_bit(*ram_addr_abs >> TARGET_PAGE_BITS, - atomic_rcu_read(&migration_bitmap_rcu)->unsentmap= )); + atomic_rcu_read(&rs->ram_bitmap)->unsentmap)); } else { trace_get_queued_page(block->idstr, (uint64_t)offset, @@ -1276,7 +1279,7 @@ static int ram_save_target_page(RAMState *rs, Migrati= onState *ms, QEMUFile *f, if (res < 0) { return res; } - unsentmap =3D atomic_rcu_read(&migration_bitmap_rcu)->unsentmap; + unsentmap =3D atomic_rcu_read(&rs->ram_bitmap)->unsentmap; if (unsentmap) { clear_bit(dirty_ram_abs >> TARGET_PAGE_BITS, unsentmap); } @@ -1440,7 +1443,7 @@ void free_xbzrle_decoded_buf(void) xbzrle_decoded_buf =3D NULL; } =20 -static void migration_bitmap_free(struct BitmapRcu *bmap) +static void migration_bitmap_free(struct RAMBitmap *bmap) { g_free(bmap->bmap); g_free(bmap->unsentmap); @@ -1449,11 +1452,13 @@ static void migration_bitmap_free(struct BitmapRcu = *bmap) =20 static void ram_migration_cleanup(void *opaque) { + RAMState *rs =3D opaque; + /* caller have hold iothread lock or is in a bh, so there is * no writing race against this migration_bitmap */ - struct BitmapRcu *bitmap =3D migration_bitmap_rcu; - atomic_rcu_set(&migration_bitmap_rcu, NULL); + struct RAMBitmap *bitmap =3D rs->ram_bitmap; + atomic_rcu_set(&rs->ram_bitmap, NULL); if (bitmap) { memory_global_dirty_log_stop(); call_rcu(bitmap, migration_bitmap_free, rcu); @@ -1488,9 +1493,9 @@ void migration_bitmap_extend(ram_addr_t old, ram_addr= _t new) /* called in qemu main thread, so there is * no writing race against this migration_bitmap */ - if (migration_bitmap_rcu) { - struct BitmapRcu *old_bitmap =3D migration_bitmap_rcu, *bitmap; - bitmap =3D g_new(struct BitmapRcu, 1); + if (ram_state.ram_bitmap) { + struct RAMBitmap *old_bitmap =3D ram_state.ram_bitmap, *bitmap; + bitmap =3D g_new(struct RAMBitmap, 1); bitmap->bmap =3D bitmap_new(new); =20 /* prevent migration_bitmap content from being set bit @@ -1508,7 +1513,7 @@ void migration_bitmap_extend(ram_addr_t old, ram_addr= _t new) */ bitmap->unsentmap =3D NULL; =20 - atomic_rcu_set(&migration_bitmap_rcu, bitmap); + atomic_rcu_set(&ram_state.ram_bitmap, bitmap); qemu_mutex_unlock(&ram_state.bitmap_mutex); ram_state.migration_dirty_pages +=3D new - old; call_rcu(old_bitmap, migration_bitmap_free, rcu); @@ -1529,7 +1534,7 @@ void ram_debug_dump_bitmap(unsigned long *todump, boo= l expected) char linebuf[129]; =20 if (!todump) { - todump =3D atomic_rcu_read(&migration_bitmap_rcu)->bmap; + todump =3D atomic_rcu_read(&ram_state.ram_bitmap)->bmap; } =20 for (cur =3D 0; cur < ram_pages; cur +=3D linelen) { @@ -1559,7 +1564,7 @@ void ram_debug_dump_bitmap(unsigned long *todump, boo= l expected) void ram_postcopy_migrated_memory_release(MigrationState *ms) { struct RAMBlock *block; - unsigned long *bitmap =3D atomic_rcu_read(&migration_bitmap_rcu)->bmap; + unsigned long *bitmap =3D atomic_rcu_read(&ram_state.ram_bitmap)->bmap; =20 QLIST_FOREACH_RCU(block, &ram_list.blocks, next) { unsigned long first =3D block->offset >> TARGET_PAGE_BITS; @@ -1591,7 +1596,7 @@ static int postcopy_send_discard_bm_ram(MigrationStat= e *ms, unsigned long current; unsigned long *unsentmap; =20 - unsentmap =3D atomic_rcu_read(&migration_bitmap_rcu)->unsentmap; + unsentmap =3D atomic_rcu_read(&ram_state.ram_bitmap)->unsentmap; for (current =3D start; current < end; ) { unsigned long one =3D find_next_bit(unsentmap, end, current); =20 @@ -1680,8 +1685,8 @@ static void postcopy_chunk_hostpages_pass(MigrationSt= ate *ms, bool unsent_pass, return; } =20 - bitmap =3D atomic_rcu_read(&migration_bitmap_rcu)->bmap; - unsentmap =3D atomic_rcu_read(&migration_bitmap_rcu)->unsentmap; + bitmap =3D atomic_rcu_read(&ram_state.ram_bitmap)->bmap; + unsentmap =3D atomic_rcu_read(&ram_state.ram_bitmap)->unsentmap; =20 if (unsent_pass) { /* Find a sent page */ @@ -1836,7 +1841,7 @@ int ram_postcopy_send_discard_bitmap(MigrationState *= ms) /* This should be our last sync, the src is now paused */ migration_bitmap_sync(&ram_state); =20 - unsentmap =3D atomic_rcu_read(&migration_bitmap_rcu)->unsentmap; + unsentmap =3D atomic_rcu_read(&ram_state.ram_bitmap)->unsentmap; if (!unsentmap) { /* We don't have a safe way to resize the sentmap, so * if the bitmap was resized it will be NULL at this @@ -1857,7 +1862,7 @@ int ram_postcopy_send_discard_bitmap(MigrationState *= ms) /* * Update the unsentmap to be unsentmap =3D unsentmap | dirty */ - bitmap =3D atomic_rcu_read(&migration_bitmap_rcu)->bmap; + bitmap =3D atomic_rcu_read(&ram_state.ram_bitmap)->bmap; bitmap_or(unsentmap, unsentmap, bitmap, last_ram_offset() >> TARGET_PAGE_BITS); =20 @@ -1950,16 +1955,16 @@ static int ram_state_init(RAMState *rs) bytes_transferred =3D 0; ram_state_reset(rs); =20 - migration_bitmap_rcu =3D g_new0(struct BitmapRcu, 1); + rs->ram_bitmap =3D g_new0(struct RAMBitmap, 1); /* Skip setting bitmap if there is no RAM */ if (ram_bytes_total()) { ram_bitmap_pages =3D last_ram_offset() >> TARGET_PAGE_BITS; - migration_bitmap_rcu->bmap =3D bitmap_new(ram_bitmap_pages); - bitmap_set(migration_bitmap_rcu->bmap, 0, ram_bitmap_pages); + rs->ram_bitmap->bmap =3D bitmap_new(ram_bitmap_pages); + bitmap_set(rs->ram_bitmap->bmap, 0, ram_bitmap_pages); =20 if (migrate_postcopy_ram()) { - migration_bitmap_rcu->unsentmap =3D bitmap_new(ram_bitmap_page= s); - bitmap_set(migration_bitmap_rcu->unsentmap, 0, ram_bitmap_page= s); + rs->ram_bitmap->unsentmap =3D bitmap_new(ram_bitmap_pages); + bitmap_set(rs->ram_bitmap->unsentmap, 0, ram_bitmap_pages); } } =20 --=20 2.9.3 From nobody Thu Nov 6 13:36:10 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 From nobody Thu Nov 6 13:36:10 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 From nobody Thu Nov 6 13:36:10 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 1489586524433733.7362720202144; Wed, 15 Mar 2017 07:02:04 -0700 (PDT) Received: from localhost ([::1]:37445 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1co9V3-0008IG-7I for importer@patchew.org; Wed, 15 Mar 2017 10:02:01 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:53926) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1co9KU-0007cm-2Z 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 1co9KT-0003rO-1D for qemu-devel@nongnu.org; Wed, 15 Mar 2017 09:51:06 -0400 Received: from mx1.redhat.com ([209.132.183.28]:47704) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1co9KS-0003pu-Sd for qemu-devel@nongnu.org; Wed, 15 Mar 2017 09:51:04 -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 CCC764E4CA for ; Wed, 15 Mar 2017 13:51:04 +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 v2FDoNUv002305; Wed, 15 Mar 2017 09:51:03 -0400 DMARC-Filter: OpenDMARC Filter v1.3.2 mx1.redhat.com CCC764E4CA Authentication-Results: ext-mx09.extmail.prod.ext.phx2.redhat.com; dmarc=none (p=none dis=none) header.from=redhat.com Authentication-Results: ext-mx09.extmail.prod.ext.phx2.redhat.com; spf=pass smtp.mailfrom=quintela@redhat.com DKIM-Filter: OpenDKIM Filter v2.11.0 mx1.redhat.com CCC764E4CA From: Juan Quintela To: qemu-devel@nongnu.org Date: Wed, 15 Mar 2017 14:50:16 +0100 Message-Id: <20170315135021.6978-27-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.38]); Wed, 15 Mar 2017 13:51:04 +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 26/31] ram: Remove ram_save_remaining 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" Just unfold it. Move ram_bytes_remaining() with the rest of exported functions. Signed-off-by: Juan Quintela --- migration/ram.c | 19 +++++++------------ 1 file changed, 7 insertions(+), 12 deletions(-) diff --git a/migration/ram.c b/migration/ram.c index 9c9533d..e7db39c 100644 --- a/migration/ram.c +++ b/migration/ram.c @@ -237,16 +237,16 @@ uint64_t xbzrle_mig_pages_overflow(void) return ram_state.xbzrle_overflows; } =20 -static ram_addr_t ram_save_remaining(void) -{ - return ram_state.migration_dirty_pages; -} - uint64_t ram_bytes_transferred(void) { return ram_state.bytes_transferred; } =20 +uint64_t ram_bytes_remaining(void) +{ + return ram_state.migration_dirty_pages * TARGET_PAGE_SIZE; +} + /* used by the search for pages to send */ struct PageSearchStatus { /* Current block being searched */ @@ -1398,11 +1398,6 @@ void acct_update_position(QEMUFile *f, size_t size, = bool zero) } } =20 -uint64_t ram_bytes_remaining(void) -{ - return ram_save_remaining() * TARGET_PAGE_SIZE; -} - uint64_t ram_bytes_total(void) { RAMBlock *block; @@ -2109,7 +2104,7 @@ static void ram_save_pending(QEMUFile *f, void *opaqu= e, uint64_t max_size, RAMState *rs =3D opaque; uint64_t remaining_size; =20 - remaining_size =3D ram_save_remaining() * TARGET_PAGE_SIZE; + remaining_size =3D rs->migration_dirty_pages * TARGET_PAGE_SIZE; =20 if (!migration_in_postcopy(migrate_get_current()) && remaining_size < max_size) { @@ -2118,7 +2113,7 @@ static void ram_save_pending(QEMUFile *f, void *opaqu= e, uint64_t max_size, migration_bitmap_sync(rs); rcu_read_unlock(); qemu_mutex_unlock_iothread(); - remaining_size =3D ram_save_remaining() * TARGET_PAGE_SIZE; + remaining_size =3D rs->migration_dirty_pages * TARGET_PAGE_SIZE; } =20 /* We can do postcopy, and all the data is postcopiable */ --=20 2.9.3 From nobody Thu Nov 6 13:36:10 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 1489586954831605.7055479368637; Wed, 15 Mar 2017 07:09:14 -0700 (PDT) Received: from localhost ([::1]:37480 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1co9bz-0006QM-B5 for importer@patchew.org; Wed, 15 Mar 2017 10:09:11 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:53948) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1co9KV-0007e0-Cl for qemu-devel@nongnu.org; Wed, 15 Mar 2017 09:51:08 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1co9KU-0003uD-Ko for qemu-devel@nongnu.org; Wed, 15 Mar 2017 09:51:07 -0400 Received: from mx1.redhat.com ([209.132.183.28]:53036) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1co9KU-0003sg-Ft for qemu-devel@nongnu.org; Wed, 15 Mar 2017 09:51:06 -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 74FB6C05AA63 for ; Wed, 15 Mar 2017 13:51:06 +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 v2FDoNUw002305; Wed, 15 Mar 2017 09:51:05 -0400 DMARC-Filter: OpenDMARC Filter v1.3.2 mx1.redhat.com 74FB6C05AA63 Authentication-Results: ext-mx08.extmail.prod.ext.phx2.redhat.com; dmarc=none (p=none dis=none) header.from=redhat.com Authentication-Results: ext-mx08.extmail.prod.ext.phx2.redhat.com; spf=pass smtp.mailfrom=quintela@redhat.com DKIM-Filter: OpenDKIM Filter v2.11.0 mx1.redhat.com 74FB6C05AA63 From: Juan Quintela To: qemu-devel@nongnu.org Date: Wed, 15 Mar 2017 14:50:17 +0100 Message-Id: <20170315135021.6978-28-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.32]); Wed, 15 Mar 2017 13:51:06 +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 27/31] ram: Move last_req_rb to 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" It was on MigrationState when it is only used inside ram.c for postcopy. Problem is that we need to access it without being able to pass it RAMState directly. Signed-off-by: Juan Quintela --- include/migration/migration.h | 2 -- migration/migration.c | 1 - migration/ram.c | 6 ++++-- 3 files changed, 4 insertions(+), 5 deletions(-) diff --git a/include/migration/migration.h b/include/migration/migration.h index 84cef4b..e032fb0 100644 --- a/include/migration/migration.h +++ b/include/migration/migration.h @@ -189,8 +189,6 @@ struct MigrationState /* Queue of outstanding page requests from the destination */ QemuMutex src_page_req_mutex; QSIMPLEQ_HEAD(src_page_requests, MigrationSrcPageRequest) src_page_req= uests; - /* The RAMBlock used in the last src_page_request */ - RAMBlock *last_req_rb; /* The semaphore is used to notify COLO thread that failover is finish= ed */ QemuSemaphore colo_exit_sem; =20 diff --git a/migration/migration.c b/migration/migration.c index 46645b6..4f19382 100644 --- a/migration/migration.c +++ b/migration/migration.c @@ -1114,7 +1114,6 @@ MigrationState *migrate_init(const MigrationParams *p= arams) s->postcopy_after_devices =3D false; s->postcopy_requests =3D 0; s->migration_thread_running =3D false; - s->last_req_rb =3D NULL; error_free(s->error); s->error =3D NULL; =20 diff --git a/migration/ram.c b/migration/ram.c index e7db39c..50ca1da 100644 --- a/migration/ram.c +++ b/migration/ram.c @@ -197,6 +197,8 @@ struct RAMState { QemuMutex bitmap_mutex; /* Ram Bitmap protected by RCU */ RAMBitmap *ram_bitmap; + /* The RAMBlock used in the last src_page_request */ + RAMBlock *last_req_rb; }; typedef struct RAMState RAMState; =20 @@ -1190,7 +1192,7 @@ int ram_save_queue_pages(MigrationState *ms, const ch= ar *rbname, rcu_read_lock(); if (!rbname) { /* Reuse last RAMBlock */ - ramblock =3D ms->last_req_rb; + ramblock =3D ram_state.last_req_rb; =20 if (!ramblock) { /* @@ -1208,7 +1210,7 @@ int ram_save_queue_pages(MigrationState *ms, const ch= ar *rbname, error_report("ram_save_queue_pages no block '%s'", rbname); goto err; } - ms->last_req_rb =3D ramblock; + ram_state.last_req_rb =3D ramblock; } trace_ram_save_queue_pages(ramblock->idstr, start, len); if (start+len > ramblock->used_length) { --=20 2.9.3 From nobody Thu Nov 6 13:36:10 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 1489586679375976.4348664520936; Wed, 15 Mar 2017 07:04:39 -0700 (PDT) Received: from localhost ([::1]:37457 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1co9XW-00022n-3A for importer@patchew.org; Wed, 15 Mar 2017 10:04:34 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:53962) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1co9KX-0007fn-1u for qemu-devel@nongnu.org; Wed, 15 Mar 2017 09:51:10 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1co9KW-0003wR-6B for qemu-devel@nongnu.org; Wed, 15 Mar 2017 09:51:09 -0400 Received: from mx1.redhat.com ([209.132.183.28]:58400) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1co9KV-0003vH-TQ for qemu-devel@nongnu.org; Wed, 15 Mar 2017 09:51:08 -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 D37FA81245 for ; Wed, 15 Mar 2017 13:51:07 +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 v2FDoNUx002305; Wed, 15 Mar 2017 09:51:06 -0400 DMARC-Filter: OpenDMARC Filter v1.3.2 mx1.redhat.com D37FA81245 Authentication-Results: ext-mx01.extmail.prod.ext.phx2.redhat.com; dmarc=none (p=none dis=none) header.from=redhat.com Authentication-Results: ext-mx01.extmail.prod.ext.phx2.redhat.com; spf=pass smtp.mailfrom=quintela@redhat.com DKIM-Filter: OpenDKIM Filter v2.11.0 mx1.redhat.com D37FA81245 From: Juan Quintela To: qemu-devel@nongnu.org Date: Wed, 15 Mar 2017 14:50:18 +0100 Message-Id: <20170315135021.6978-29-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.25]); Wed, 15 Mar 2017 13:51:08 +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 28/31] ram: Create ram_dirty_sync_count() 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" This is a ram field that was inside MigrationState. Move it to RAMState and make it the same that the other ram stats. Signed-off-by: Juan Quintela --- include/migration/migration.h | 2 +- migration/migration.c | 3 +-- migration/ram.c | 6 +++++- 3 files changed, 7 insertions(+), 4 deletions(-) diff --git a/include/migration/migration.h b/include/migration/migration.h index e032fb0..54a1a4f 100644 --- a/include/migration/migration.h +++ b/include/migration/migration.h @@ -171,7 +171,6 @@ struct MigrationState bool enabled_capabilities[MIGRATION_CAPABILITY__MAX]; int64_t xbzrle_cache_size; int64_t setup_time; - int64_t dirty_sync_count; /* Count of requests incoming from destination */ int64_t postcopy_requests; =20 @@ -270,6 +269,7 @@ void migrate_decompress_threads_join(void); uint64_t ram_bytes_remaining(void); uint64_t ram_bytes_transferred(void); uint64_t ram_bytes_total(void); +uint64_t ram_dirty_sync_count(void); void free_xbzrle_decoded_buf(void); =20 void acct_update_position(QEMUFile *f, size_t size, bool zero); diff --git a/migration/migration.c b/migration/migration.c index 4f19382..09d02be 100644 --- a/migration/migration.c +++ b/migration/migration.c @@ -645,7 +645,7 @@ static void populate_ram_info(MigrationInfo *info, Migr= ationState *s) info->ram->normal_bytes =3D norm_mig_pages_transferred() * (1ul << qemu_target_page_bits()); info->ram->mbps =3D s->mbps; - info->ram->dirty_sync_count =3D s->dirty_sync_count; + info->ram->dirty_sync_count =3D ram_dirty_sync_count(); info->ram->postcopy_requests =3D s->postcopy_requests; =20 if (s->state !=3D MIGRATION_STATUS_COMPLETED) { @@ -1109,7 +1109,6 @@ MigrationState *migrate_init(const MigrationParams *p= arams) s->dirty_pages_rate =3D 0; s->dirty_bytes_rate =3D 0; s->setup_time =3D 0; - s->dirty_sync_count =3D 0; s->start_postcopy =3D false; s->postcopy_after_devices =3D false; s->postcopy_requests =3D 0; diff --git a/migration/ram.c b/migration/ram.c index 50ca1da..4563e3d 100644 --- a/migration/ram.c +++ b/migration/ram.c @@ -249,6 +249,11 @@ uint64_t ram_bytes_remaining(void) return ram_state.migration_dirty_pages * TARGET_PAGE_SIZE; } =20 +uint64_t ram_dirty_sync_count(void) +{ + return ram_state.bitmap_sync_count; +} + /* used by the search for pages to send */ struct PageSearchStatus { /* Current block being searched */ @@ -686,7 +691,6 @@ static void migration_bitmap_sync(RAMState *rs) rs->start_time =3D end_time; rs->num_dirty_pages_period =3D 0; } - s->dirty_sync_count =3D rs->bitmap_sync_count; if (migrate_use_events()) { qapi_event_send_migration_pass(rs->bitmap_sync_count, NULL); } --=20 2.9.3 From nobody Thu Nov 6 13:36:10 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 1489587021347922.3297083309865; Wed, 15 Mar 2017 07:10:21 -0700 (PDT) Received: from localhost ([::1]:37489 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1co9d2-0007LO-RN for importer@patchew.org; Wed, 15 Mar 2017 10:10:16 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:53976) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1co9KY-0007hc-Jl for qemu-devel@nongnu.org; Wed, 15 Mar 2017 09:51:11 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1co9KX-0003y4-Tf for qemu-devel@nongnu.org; Wed, 15 Mar 2017 09:51:10 -0400 Received: from mx1.redhat.com ([209.132.183.28]:53426) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1co9KX-0003xH-Cl for qemu-devel@nongnu.org; Wed, 15 Mar 2017 09:51:09 -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 5769064473 for ; Wed, 15 Mar 2017 13:51:09 +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 v2FDoNV0002305; Wed, 15 Mar 2017 09:51:08 -0400 DMARC-Filter: OpenDMARC Filter v1.3.2 mx1.redhat.com 5769064473 Authentication-Results: ext-mx10.extmail.prod.ext.phx2.redhat.com; dmarc=none (p=none dis=none) header.from=redhat.com Authentication-Results: ext-mx10.extmail.prod.ext.phx2.redhat.com; spf=pass smtp.mailfrom=quintela@redhat.com DKIM-Filter: OpenDKIM Filter v2.11.0 mx1.redhat.com 5769064473 From: Juan Quintela To: qemu-devel@nongnu.org Date: Wed, 15 Mar 2017 14:50:19 +0100 Message-Id: <20170315135021.6978-30-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.39]); Wed, 15 Mar 2017 13:51:09 +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 29/31] ram: Remove dirty_bytes_rate 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" It can be recalculated from dirty_pages_rate. Signed-off-by: Juan Quintela Reviewed-by: Dr. David Alan Gilbert --- include/migration/migration.h | 1 - migration/migration.c | 5 ++--- migration/ram.c | 1 - 3 files changed, 2 insertions(+), 5 deletions(-) diff --git a/include/migration/migration.h b/include/migration/migration.h index 54a1a4f..42b9edf 100644 --- a/include/migration/migration.h +++ b/include/migration/migration.h @@ -167,7 +167,6 @@ struct MigrationState int64_t downtime; int64_t expected_downtime; int64_t dirty_pages_rate; - int64_t dirty_bytes_rate; bool enabled_capabilities[MIGRATION_CAPABILITY__MAX]; int64_t xbzrle_cache_size; int64_t setup_time; diff --git a/migration/migration.c b/migration/migration.c index 09d02be..2f8c440 100644 --- a/migration/migration.c +++ b/migration/migration.c @@ -1107,7 +1107,6 @@ MigrationState *migrate_init(const MigrationParams *p= arams) s->downtime =3D 0; s->expected_downtime =3D 0; s->dirty_pages_rate =3D 0; - s->dirty_bytes_rate =3D 0; s->setup_time =3D 0; s->start_postcopy =3D false; s->postcopy_after_devices =3D false; @@ -1999,8 +1998,8 @@ static void *migration_thread(void *opaque) bandwidth, max_size); /* if we haven't sent anything, we don't want to recalculate 10000 is a small enough number for our purposes */ - if (s->dirty_bytes_rate && transferred_bytes > 10000) { - s->expected_downtime =3D s->dirty_bytes_rate / bandwidth; + if (s->dirty_pages_rate && transferred_bytes > 10000) { + s->expected_downtime =3D s->dirty_pages_rate * (1ul << qem= u_target_page_bits())/ bandwidth; } =20 qemu_file_reset_rate_limit(s->to_dst_file); diff --git a/migration/ram.c b/migration/ram.c index 4563e3d..1006e60 100644 --- a/migration/ram.c +++ b/migration/ram.c @@ -687,7 +687,6 @@ static void migration_bitmap_sync(RAMState *rs) } s->dirty_pages_rate =3D rs->num_dirty_pages_period * 1000 / (end_time - rs->start_time); - s->dirty_bytes_rate =3D s->dirty_pages_rate * TARGET_PAGE_SIZE; rs->start_time =3D end_time; rs->num_dirty_pages_period =3D 0; } --=20 2.9.3 From nobody Thu Nov 6 13:36:10 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 1489586890418387.88455026678594; Wed, 15 Mar 2017 07:08:10 -0700 (PDT) Received: from localhost ([::1]:37476 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1co9ay-0005Gm-1d for importer@patchew.org; Wed, 15 Mar 2017 10:08:08 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:53992) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1co9Ka-0007jM-9p for qemu-devel@nongnu.org; Wed, 15 Mar 2017 09:51:17 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1co9KZ-0003yl-6S for qemu-devel@nongnu.org; Wed, 15 Mar 2017 09:51:12 -0400 Received: from mx1.redhat.com ([209.132.183.28]:42390) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1co9KY-0003yD-Tl for qemu-devel@nongnu.org; Wed, 15 Mar 2017 09:51:11 -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 DB8C285547 for ; Wed, 15 Mar 2017 13:51:10 +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 v2FDoNV1002305; Wed, 15 Mar 2017 09:51:09 -0400 DMARC-Filter: OpenDMARC Filter v1.3.2 mx1.redhat.com DB8C285547 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 DB8C285547 From: Juan Quintela To: qemu-devel@nongnu.org Date: Wed, 15 Mar 2017 14:50:20 +0100 Message-Id: <20170315135021.6978-31-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:11 +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 30/31] ram: move dirty_pages_rate to 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" Treat it like the rest of ram stats counters. Export its value the same way. As an added bonus, no more MigrationState used in migration_bitmap_sync(); Signed-off-by: Juan Quintela Reviewed-by: Dr. David Alan Gilbert --- include/migration/migration.h | 2 +- migration/migration.c | 7 +++---- migration/ram.c | 12 +++++++++--- 3 files changed, 13 insertions(+), 8 deletions(-) diff --git a/include/migration/migration.h b/include/migration/migration.h index 42b9edf..43bdf86 100644 --- a/include/migration/migration.h +++ b/include/migration/migration.h @@ -166,7 +166,6 @@ struct MigrationState int64_t total_time; int64_t downtime; int64_t expected_downtime; - int64_t dirty_pages_rate; bool enabled_capabilities[MIGRATION_CAPABILITY__MAX]; int64_t xbzrle_cache_size; int64_t setup_time; @@ -269,6 +268,7 @@ uint64_t ram_bytes_remaining(void); uint64_t ram_bytes_transferred(void); uint64_t ram_bytes_total(void); uint64_t ram_dirty_sync_count(void); +uint64_t ram_dirty_pages_rate(void); void free_xbzrle_decoded_buf(void); =20 void acct_update_position(QEMUFile *f, size_t size, bool zero); diff --git a/migration/migration.c b/migration/migration.c index 2f8c440..0a70d55 100644 --- a/migration/migration.c +++ b/migration/migration.c @@ -650,7 +650,7 @@ static void populate_ram_info(MigrationInfo *info, Migr= ationState *s) =20 if (s->state !=3D MIGRATION_STATUS_COMPLETED) { info->ram->remaining =3D ram_bytes_remaining(); - info->ram->dirty_pages_rate =3D s->dirty_pages_rate; + info->ram->dirty_pages_rate =3D ram_dirty_pages_rate(); } } =20 @@ -1106,7 +1106,6 @@ MigrationState *migrate_init(const MigrationParams *p= arams) s->mbps =3D 0.0; s->downtime =3D 0; s->expected_downtime =3D 0; - s->dirty_pages_rate =3D 0; s->setup_time =3D 0; s->start_postcopy =3D false; s->postcopy_after_devices =3D false; @@ -1998,8 +1997,8 @@ static void *migration_thread(void *opaque) bandwidth, max_size); /* if we haven't sent anything, we don't want to recalculate 10000 is a small enough number for our purposes */ - if (s->dirty_pages_rate && transferred_bytes > 10000) { - s->expected_downtime =3D s->dirty_pages_rate * (1ul << qem= u_target_page_bits())/ bandwidth; + if (ram_dirty_pages_rate() && transferred_bytes > 10000) { + s->expected_downtime =3D ram_dirty_pages_rate() * (1ul << = qemu_target_page_bits())/ bandwidth; } =20 qemu_file_reset_rate_limit(s->to_dst_file); diff --git a/migration/ram.c b/migration/ram.c index 1006e60..b85f58f 100644 --- a/migration/ram.c +++ b/migration/ram.c @@ -193,6 +193,8 @@ struct RAMState { uint64_t migration_dirty_pages; /* total number of bytes transferred */ uint64_t bytes_transferred; + /* number of dirtied pages in the last second */ + uint64_t dirty_pages_rate; /* protects modification of the bitmap */ QemuMutex bitmap_mutex; /* Ram Bitmap protected by RCU */ @@ -254,6 +256,11 @@ uint64_t ram_dirty_sync_count(void) return ram_state.bitmap_sync_count; } =20 +uint64_t ram_dirty_pages_rate(void) +{ + return ram_state.dirty_pages_rate; +} + /* used by the search for pages to send */ struct PageSearchStatus { /* Current block being searched */ @@ -624,7 +631,6 @@ static void migration_bitmap_sync(RAMState *rs) { RAMBlock *block; uint64_t num_dirty_pages_init =3D rs->migration_dirty_pages; - MigrationState *s =3D migrate_get_current(); int64_t end_time; int64_t bytes_xfer_now; =20 @@ -664,7 +670,7 @@ static void migration_bitmap_sync(RAMState *rs) throttling */ bytes_xfer_now =3D ram_bytes_transferred(); =20 - if (s->dirty_pages_rate && + if (rs->dirty_pages_rate && (rs->num_dirty_pages_period * TARGET_PAGE_SIZE > (bytes_xfer_now - rs->bytes_xfer_prev)/2) && (rs->dirty_rate_high_cnt++ >=3D 2)) { @@ -685,7 +691,7 @@ static void migration_bitmap_sync(RAMState *rs) rs->iterations_prev =3D rs->iterations; rs->xbzrle_cache_miss_prev =3D rs->xbzrle_cache_miss; } - s->dirty_pages_rate =3D rs->num_dirty_pages_period * 1000 + rs->dirty_pages_rate =3D rs->num_dirty_pages_period * 1000 / (end_time - rs->start_time); rs->start_time =3D end_time; rs->num_dirty_pages_period =3D 0; --=20 2.9.3 From nobody Thu Nov 6 13:36:10 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 1489587128157584.8839937162458; Wed, 15 Mar 2017 07:12:08 -0700 (PDT) Received: from localhost ([::1]:37514 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1co9em-0000Xi-PE for importer@patchew.org; Wed, 15 Mar 2017 10:12:04 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:54025) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1co9Kf-0007nv-AL for qemu-devel@nongnu.org; Wed, 15 Mar 2017 09:51:18 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1co9Ka-000415-NG for qemu-devel@nongnu.org; Wed, 15 Mar 2017 09:51:17 -0400 Received: from mx1.redhat.com ([209.132.183.28]:53118) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1co9Ka-0003zq-FE for qemu-devel@nongnu.org; Wed, 15 Mar 2017 09:51:12 -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 6E1F5C05AA61 for ; Wed, 15 Mar 2017 13:51:12 +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 v2FDoNV2002305; Wed, 15 Mar 2017 09:51:11 -0400 DMARC-Filter: OpenDMARC Filter v1.3.2 mx1.redhat.com 6E1F5C05AA61 Authentication-Results: ext-mx08.extmail.prod.ext.phx2.redhat.com; dmarc=none (p=none dis=none) header.from=redhat.com Authentication-Results: ext-mx08.extmail.prod.ext.phx2.redhat.com; spf=pass smtp.mailfrom=quintela@redhat.com DKIM-Filter: OpenDKIM Filter v2.11.0 mx1.redhat.com 6E1F5C05AA61 From: Juan Quintela To: qemu-devel@nongnu.org Date: Wed, 15 Mar 2017 14:50:21 +0100 Message-Id: <20170315135021.6978-32-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.32]); Wed, 15 Mar 2017 13:51:12 +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 31/31] ram: move postcopy_requests 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 --- include/migration/migration.h | 3 +-- migration/migration.c | 3 +-- migration/ram.c | 9 ++++++++- 3 files changed, 10 insertions(+), 5 deletions(-) diff --git a/include/migration/migration.h b/include/migration/migration.h index 43bdf86..bc48a8e 100644 --- a/include/migration/migration.h +++ b/include/migration/migration.h @@ -169,8 +169,6 @@ struct MigrationState bool enabled_capabilities[MIGRATION_CAPABILITY__MAX]; int64_t xbzrle_cache_size; int64_t setup_time; - /* Count of requests incoming from destination */ - int64_t postcopy_requests; =20 /* Flag set once the migration has been asked to enter postcopy */ bool start_postcopy; @@ -269,6 +267,7 @@ uint64_t ram_bytes_transferred(void); uint64_t ram_bytes_total(void); uint64_t ram_dirty_sync_count(void); uint64_t ram_dirty_pages_rate(void); +uint64_t ram_postcopy_requests(void); void free_xbzrle_decoded_buf(void); =20 void acct_update_position(QEMUFile *f, size_t size, bool zero); diff --git a/migration/migration.c b/migration/migration.c index 0a70d55..0df6111 100644 --- a/migration/migration.c +++ b/migration/migration.c @@ -646,7 +646,7 @@ static void populate_ram_info(MigrationInfo *info, Migr= ationState *s) (1ul << qemu_target_page_bits()); info->ram->mbps =3D s->mbps; info->ram->dirty_sync_count =3D ram_dirty_sync_count(); - info->ram->postcopy_requests =3D s->postcopy_requests; + info->ram->postcopy_requests =3D ram_postcopy_requests(); =20 if (s->state !=3D MIGRATION_STATUS_COMPLETED) { info->ram->remaining =3D ram_bytes_remaining(); @@ -1109,7 +1109,6 @@ MigrationState *migrate_init(const MigrationParams *p= arams) s->setup_time =3D 0; s->start_postcopy =3D false; s->postcopy_after_devices =3D false; - s->postcopy_requests =3D 0; s->migration_thread_running =3D false; error_free(s->error); s->error =3D NULL; diff --git a/migration/ram.c b/migration/ram.c index b85f58f..91f9fb5 100644 --- a/migration/ram.c +++ b/migration/ram.c @@ -195,6 +195,8 @@ struct RAMState { uint64_t bytes_transferred; /* number of dirtied pages in the last second */ uint64_t dirty_pages_rate; + /* Count of requests incoming from destination */ + uint64_t postcopy_requests; /* protects modification of the bitmap */ QemuMutex bitmap_mutex; /* Ram Bitmap protected by RCU */ @@ -261,6 +263,11 @@ uint64_t ram_dirty_pages_rate(void) return ram_state.dirty_pages_rate; } =20 +uint64_t ram_postcopy_requests(void) +{ + return ram_state.postcopy_requests; +} + /* used by the search for pages to send */ struct PageSearchStatus { /* Current block being searched */ @@ -1197,7 +1204,7 @@ int ram_save_queue_pages(MigrationState *ms, const ch= ar *rbname, { RAMBlock *ramblock; =20 - ms->postcopy_requests++; + ram_state.postcopy_requests++; rcu_read_lock(); if (!rbname) { /* Reuse last RAMBlock */ --=20 2.9.3