From nobody Fri May 3 08:55:07 2024 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 1490302077392186.88413052013425; Thu, 23 Mar 2017 13:47:57 -0700 (PDT) Received: from localhost ([::1]:58550 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1cr9eF-0000r4-RJ for importer@patchew.org; Thu, 23 Mar 2017 16:47:55 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:45160) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1cr9cJ-0007bQ-KJ for qemu-devel@nongnu.org; Thu, 23 Mar 2017 16:45:58 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1cr9cF-0008Ue-Tg for qemu-devel@nongnu.org; Thu, 23 Mar 2017 16:45:55 -0400 Received: from mx1.redhat.com ([209.132.183.28]:35764) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1cr9cF-0008TT-Jt for qemu-devel@nongnu.org; Thu, 23 Mar 2017 16:45:51 -0400 Received: from smtp.corp.redhat.com (int-mx02.intmail.prod.int.phx2.redhat.com [10.5.11.12]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 93D0B61E7C for ; Thu, 23 Mar 2017 20:45:51 +0000 (UTC) Received: from secure.mitica (ovpn-116-230.ams2.redhat.com [10.36.116.230]) by smtp.corp.redhat.com (Postfix) with ESMTP id A45F153; Thu, 23 Mar 2017 20:45:47 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mx1.redhat.com 93D0B61E7C 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 93D0B61E7C From: Juan Quintela To: qemu-devel@nongnu.org Date: Thu, 23 Mar 2017 21:44:54 +0100 Message-Id: <20170323204544.12015-2-quintela@redhat.com> In-Reply-To: <20170323204544.12015-1-quintela@redhat.com> References: <20170323204544.12015-1-quintela@redhat.com> X-Scanned-By: MIMEDefang 2.79 on 10.5.11.12 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.39]); Thu, 23 Mar 2017 20:45: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 01/51] ram: Update all functions comments 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: 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" Added doc comments for existing functions comment and rewrite them in a common style. Signed-off-by: Juan Quintela --- migration/ram.c | 348 ++++++++++++++++++++++++++++++++++++----------------= ---- 1 file changed, 227 insertions(+), 121 deletions(-) diff --git a/migration/ram.c b/migration/ram.c index de1e0a3..76f1fc4 100644 --- a/migration/ram.c +++ b/migration/ram.c @@ -96,11 +96,17 @@ static void XBZRLE_cache_unlock(void) qemu_mutex_unlock(&XBZRLE.lock); } =20 -/* - * called from qmp_migrate_set_cache_size in main thread, possibly while - * a migration is in progress. - * A running migration maybe using the cache and might finish during this - * call, hence changes to the cache are protected by XBZRLE.lock(). +/** + * xbzrle_cache_resize: resize the xbzrle cache + * + * This function is called from qmp_migrate_set_cache_size in main + * thread, possibly while a migration is in progress. A running + * migration may be using the cache and might finish during this call, + * hence changes to the cache are protected by XBZRLE.lock(). + * + * Returns the new_size or negative in case of error. + * + * @new_size: new cache size */ int64_t xbzrle_cache_resize(int64_t new_size) { @@ -323,6 +329,7 @@ static inline void terminate_compression_threads(void) int idx, thread_count; =20 thread_count =3D migrate_compress_threads(); + for (idx =3D 0; idx < thread_count; idx++) { qemu_mutex_lock(&comp_param[idx].mutex); comp_param[idx].quit =3D true; @@ -383,11 +390,11 @@ void migrate_compress_threads_create(void) } =20 /** - * save_page_header: Write page header to wire + * save_page_header: write page header to wire * * If this is the 1st block, it also writes the block identification * - * Returns: Number of bytes written + * Returns the number of bytes written * * @f: QEMUFile where to send the data * @block: block that contains the page we want to send @@ -410,11 +417,14 @@ static size_t save_page_header(QEMUFile *f, RAMBlock = *block, ram_addr_t offset) return size; } =20 -/* Reduce amount of guest cpu execution to hopefully slow down memory writ= es. - * If guest dirty memory rate is reduced below the rate at which we can - * transfer pages to the destination then we should be able to complete - * migration. Some workloads dirty memory way too fast and will not effect= ively - * converge, even with auto-converge. +/** + * mig_throotle_guest_down: throotle down the guest + * + * Reduce amount of guest cpu execution to hopefully slow down memory + * writes. If guest dirty memory rate is reduced below the rate at + * which we can transfer pages to the destination then we should be + * able to complete migration. Some workloads dirty memory way too + * fast and will not effectively converge, even with auto-converge. */ static void mig_throttle_guest_down(void) { @@ -431,11 +441,16 @@ static void mig_throttle_guest_down(void) } } =20 -/* Update the xbzrle cache to reflect a page that's been sent as all 0. +/** + * xbzrle_cache_zero_page: insert a zero page in the XBZRLE cache + * + * @current_addr: address for the zero page + * + * Update the xbzrle cache to reflect a page that's been sent as all 0. * The important thing is that a stale (not-yet-0'd) page be replaced * by the new data. * 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 + * 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) { @@ -459,8 +474,8 @@ static void xbzrle_cache_zero_page(ram_addr_t current_a= ddr) * -1 means that xbzrle would be longer than normal * * @f: QEMUFile where to send the data - * @current_data: - * @current_addr: + * @current_data: contents of the page + * @current_addr: addr of the page * @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 @@ -530,13 +545,17 @@ static int save_xbzrle_page(QEMUFile *f, uint8_t **cu= rrent_data, return 1; } =20 -/* Called with rcu_read_lock() to protect migration_bitmap - * rb: The RAMBlock to search for dirty pages in - * start: Start address (typically so we can continue from previous page) - * ram_addr_abs: Pointer into which to store the address of the dirty page - * within the global ram_addr space +/** + * migration_bitmap_find_dirty: find the next drity page from start * - * Returns: byte offset within memory region of the start of a dirty page + * Called with rcu_read_lock() to protect migration_bitmap + * + * Returns the byte offset within memory region of the start of a dirty pa= ge + * + * @rb: RAMBlock where to search for dirty pages + * @start: starting address (typically so we can continue from previous pa= ge) + * @ram_addr_abs: pointer into which to store the address of the dirty page + * within the global ram_addr space */ static inline ram_addr_t migration_bitmap_find_dirty(RAMBlock *rb, @@ -600,10 +619,14 @@ static void migration_bitmap_sync_init(void) iterations_prev =3D 0; } =20 -/* 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 - * of all the different page sizes. +/** + * ram_pagesize_summary: calculate all the pagesizes of a VM + * + * 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 of all the + * different page sizes. */ uint64_t ram_pagesize_summary(void) { @@ -693,9 +716,9 @@ static void migration_bitmap_sync(void) } =20 /** - * save_zero_page: Send the zero page to the stream + * save_zero_page: send the zero page to the stream * - * Returns: Number of pages written. + * Returns the number of pages written. * * @f: QEMUFile where to send the data * @block: block that contains the page we want to send @@ -731,14 +754,14 @@ static void ram_release_pages(MigrationState *ms, con= st char *block_name, } =20 /** - * ram_save_page: Send the given page to the stream + * ram_save_page: send the given page to the stream * - * Returns: Number of pages written. + * Returns the number of pages written. * < 0 - error * >=3D0 - Number of pages written - this might legally be 0 * if xbzrle noticed the page was the same. * - * @ms: The current migration state. + * @ms: current migration state * @f: QEMUFile where to send the data * @block: block that contains the page we want to send * @offset: offset inside the block for the page @@ -921,9 +944,9 @@ static int compress_page_with_multi_thread(QEMUFile *f,= RAMBlock *block, /** * ram_save_compressed_page: compress the given page and send it to the st= ream * - * Returns: Number of pages written. + * Returns the number of pages written. * - * @ms: The current migration state. + * @ms: current migration state * @f: QEMUFile where to send the data * @block: block that contains the page we want to send * @offset: offset inside the block for the page @@ -1000,17 +1023,17 @@ static int ram_save_compressed_page(MigrationState = *ms, QEMUFile *f, return pages; } =20 -/* - * Find the next dirty page and update any state associated with - * the search process. +/** + * find_dirty_block: find the next dirty page and update any state + * associated with the search process. * - * Returns: True if a page is found + * Returns if a page is found * - * @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 + * @f: QEMUFile where to send the data + * @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, bool *again, ram_addr_t *ram_addr_abs) @@ -1055,13 +1078,17 @@ static bool find_dirty_block(QEMUFile *f, PageSearc= hStatus *pss, } } =20 -/* +/** + * unqueue_page: gets a page of the queue + * * Helper for 'get_queued_page' - gets a page off the queue - * ms: MigrationState in - * *offset: Used to return the offset within the RAMBlock - * ram_addr_abs: global offset in the dirty/sent bitmaps * - * Returns: block (or NULL if none available) + * Returns the block of the page (or NULL if none available) + * + * @ms: current migration state + * @offset: used to return the offset within the RAMBlock + * @ram_addr_abs: pointer into which to store the address of the dirty page + * within the global ram_addr space */ static RAMBlock *unqueue_page(MigrationState *ms, ram_addr_t *offset, ram_addr_t *ram_addr_abs) @@ -1091,15 +1118,17 @@ static RAMBlock *unqueue_page(MigrationState *ms, r= am_addr_t *offset, return block; } =20 -/* - * Unqueue a page from the queue fed by postcopy page requests; skips pages - * that are already sent (!dirty) +/** + * get_queued_page: unqueue a page from the postocpy requests * - * ms: MigrationState in - * pss: PageSearchStatus structure updated with found block/offset - * ram_addr_abs: global offset in the dirty/sent bitmaps + * Skips pages that are already sent (!dirty) * - * Returns: true if a queued page is found + * Returns if a queued page is found + * + * @ms: current migration state + * @pss: data about the state of the current dirty page scan + * @ram_addr_abs: pointer into which to store the address of the dirty page + * within the global ram_addr space */ static bool get_queued_page(MigrationState *ms, PageSearchStatus *pss, ram_addr_t *ram_addr_abs) @@ -1157,11 +1186,12 @@ static bool get_queued_page(MigrationState *ms, Pag= eSearchStatus *pss, } =20 /** - * flush_page_queue: Flush any remaining pages in the ram request queue - * it should be empty at the end anyway, but in error cases there may be - * some left. + * flush_page_queue: flush any remaining pages in the ram request queue * - * ms: MigrationState + * It should be empty at the end anyway, but in error cases there may + * xbe some left. + * + * @ms: current migration state */ void flush_page_queue(MigrationState *ms) { @@ -1179,12 +1209,17 @@ void flush_page_queue(MigrationState *ms) } =20 /** - * Queue the pages for transmission, e.g. a request from postcopy destinat= ion - * ms: MigrationStatus in which the queue is held - * rbname: The RAMBlock the request is for - may be NULL (to mean reuse = last) - * start: Offset from the start of the RAMBlock - * len: Length (in bytes) to send - * Return: 0 on success + * ram_save_queue_pages: queue the page for transmission + * + * A request from postcopy destination for example. + * + * Returns zero on success or negative on error + * + * @ms: current migration state + * @rbname: Name of the RAMBLock of the request. NULL means the + * same that last one. + * @start: starting address from the start of the RAMBlock + * @len: length (in bytes) to send */ int ram_save_queue_pages(MigrationState *ms, const char *rbname, ram_addr_t start, ram_addr_t len) @@ -1243,17 +1278,16 @@ err: } =20 /** - * ram_save_target_page: Save one target page + * ram_save_target_page: save one target page * + * Returns the umber of pages written * + * @ms: current migration 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; + * @pss: data about the page we want to send * @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. + * @dirty_ram_abs: address of the start of the dirty page in ram_addr_t sp= ace */ static int ram_save_target_page(MigrationState *ms, QEMUFile *f, PageSearchStatus *pss, @@ -1295,20 +1329,19 @@ static int ram_save_target_page(MigrationState *ms,= QEMUFile *f, } =20 /** - * ram_save_host_page: Starting at *offset send pages up to the end - * of the current host page. It's valid for the initi= al - * offset to point into the middle of a host page - * in which case the remainder of the hostpage is sent. - * Only dirty target pages are sent. - * Note that the host page size may be a huge page for= this - * block. + * ram_save_host_page: save a whole host page * - * Returns: Number of pages written. + * Starting at *offset send pages up to the end of the current host + * page. It's valid for the initial offset to point into the middle of + * a host page in which case the remainder of the hostpage is sent. + * Only dirty target pages are sent. Note that the host page size may + * be a huge page for this block. * + * Returns the number of pages written or negative on error + * + * @ms: current migration 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 - * sent + * @pss: data about the page we want to send * @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 @@ -1340,12 +1373,11 @@ static int ram_save_host_page(MigrationState *ms, Q= EMUFile *f, } =20 /** - * ram_find_and_save_block: Finds a dirty page and sends it to f + * ram_find_and_save_block: finds a dirty page and sends it to f * * Called within an RCU critical section. * - * Returns: The number of pages written - * 0 means no dirty pages + * Returns the number of pages written where zero means no dirty pages * * @f: QEMUFile where to send the data * @last_stage: if we are at the completion stage @@ -1580,12 +1612,19 @@ void ram_postcopy_migrated_memory_release(Migration= State *ms) } } =20 -/* +/** + * postcopy_send_discard_bm_ram: discard a RAMBlock + * + * Returns zero on success + * * Callback from postcopy_each_ram_send_discard for each RAMBlock * Note: At this point the 'unsentmap' is the processed bitmap combined * with the dirtymap; so a '1' means it's either dirty or unsent. - * start,length: Indexes into the bitmap for the first bit - * representing the named block and length in target-pages + * + * @ms: current migration state + * @pds: state for postcopy + * @start: RAMBlock starting page + * @length: RAMBlock size */ static int postcopy_send_discard_bm_ram(MigrationState *ms, PostcopyDiscardState *pds, @@ -1621,13 +1660,18 @@ static int postcopy_send_discard_bm_ram(MigrationSt= ate *ms, return 0; } =20 -/* +/** + * postcopy_each_ram_send_discard: discard all RAMBlocks + * + * Returns 0 for success or negative for error + * * Utility for the outgoing postcopy code. * Calls postcopy_send_discard_bm_ram for each RAMBlock * passing it bitmap indexes and name. - * Returns: 0 on success * (qemu_ram_foreach_block ends up passing unscaled lengths * which would mean postcopy code would have to deal with target page) + * + * @ms: current migration state */ static int postcopy_each_ram_send_discard(MigrationState *ms) { @@ -1656,17 +1700,21 @@ static int postcopy_each_ram_send_discard(Migration= State *ms) return 0; } =20 -/* - * Helper for postcopy_chunk_hostpages; it's called twice to cleanup - * the two bitmaps, that are similar, but one is inverted. +/** + * postcopy_chuck_hostpages_pass: canocalize bitmap in hostpages * - * We search for runs of target-pages that don't start or end on a - * host page boundary; - * unsent_pass=3Dtrue: Cleans up partially unsent host pages by searching - * the unsentmap - * unsent_pass=3Dfalse: Cleans up partially dirty host pages by searching - * the main migration bitmap + * Helper for postcopy_chunk_hostpages; it's called twice to + * canonicalize the two bitmaps, that are similar, but one is + * inverted. * + * Postcopy requires that all target pages in a hostpage are dirty or + * clean, not a mix. This function canonicalizes the bitmaps. + * + * @ms: current migration state + * @unsent_pass: if true we need to canonicalize partially unsent host pag= es + * otherwise we need to canonicalize partially dirty host pa= ges + * @block: block that contains the page we want to canonicalize + * @pds: state for postcopy */ static void postcopy_chunk_hostpages_pass(MigrationState *ms, bool unsent_= pass, RAMBlock *block, @@ -1784,14 +1832,18 @@ static void postcopy_chunk_hostpages_pass(Migration= State *ms, bool unsent_pass, } } =20 -/* +/** + * postcopy_chuck_hostpages: discrad any partially sent host page + * * Utility for the outgoing postcopy code. * * Discard any partially sent host-page size chunks, mark any partially * dirty host-page size chunks as all dirty. In this case the host-page * is the host-page for the particular RAMBlock, i.e. it might be a huge p= age * - * Returns: 0 on success + * Returns zero on success + * + * @ms: current migration state */ static int postcopy_chunk_hostpages(MigrationState *ms) { @@ -1822,7 +1874,11 @@ static int postcopy_chunk_hostpages(MigrationState *= ms) return 0; } =20 -/* +/** + * ram_postcopy_send_discard_bitmap: transmit the discard bitmap + * + * Returns zero on success + * * Transmit the set of pages to be discarded after precopy to the target * these are pages that: * a) Have been previously transmitted but are now dirty again @@ -1830,6 +1886,8 @@ static int postcopy_chunk_hostpages(MigrationState *m= s) * any pages on the destination that have been mapped by background * tasks get discarded (transparent huge pages is the specific conc= ern) * Hopefully this is pretty sparse + * + * @ms: current migration state */ int ram_postcopy_send_discard_bitmap(MigrationState *ms) { @@ -1878,13 +1936,16 @@ int ram_postcopy_send_discard_bitmap(MigrationState= *ms) return ret; } =20 -/* - * At the start of the postcopy phase of migration, any now-dirty - * precopied pages are discarded. +/** + * ram_discard_range: discard dirtied pages at the beginning of postcopy * - * start, length describe a byte address range within the RAMBlock + * Returns zero on success * - * Returns 0 on success. + * @mis: current migration incoming state + * @block_name: Name of the RAMBLock of the request. NULL means the + * same that last one. + * @start: RAMBlock starting page + * @length: RAMBlock size */ int ram_discard_range(MigrationIncomingState *mis, const char *block_name, @@ -1987,12 +2048,21 @@ static int ram_save_init_globals(void) return 0; } =20 -/* Each of ram_save_setup, ram_save_iterate and ram_save_complete has +/* + * Each of ram_save_setup, ram_save_iterate and ram_save_complete has * long-running RCU critical section. When rcu-reclaims in the code * start to become numerous it will be necessary to reduce the * granularity of these critical sections. */ =20 +/** + * ram_save_setup: Setup RAM for migration + * + * Returns zero to indicate success and negative for error + * + * @f: QEMUFile where to send the data + * @opaque: RAMState pointer + */ static int ram_save_setup(QEMUFile *f, void *opaque) { RAMBlock *block; @@ -2027,6 +2097,14 @@ static int ram_save_setup(QEMUFile *f, void *opaque) return 0; } =20 +/** + * ram_save_setup: iterative stage for migration + * + * Returns zero to indicate success and negative for error + * + * @f: QEMUFile where to send the data + * @opaque: RAMState pointer + */ static int ram_save_iterate(QEMUFile *f, void *opaque) { int ret; @@ -2091,7 +2169,16 @@ static int ram_save_iterate(QEMUFile *f, void *opaqu= e) return done; } =20 -/* Called with iothread lock */ +/** + * ram_save_complete: function called to send the remaining amount of ram + * + * Returns zero to indicate success + * + * Called with iothread lock + * + * @f: QEMUFile where to send the data + * @opaque: RAMState pointer + */ static int ram_save_complete(QEMUFile *f, void *opaque) { rcu_read_lock(); @@ -2185,17 +2272,17 @@ static int load_xbzrle(QEMUFile *f, ram_addr_t addr= , void *host) return 0; } =20 -/* Must be called from within a rcu critical section. +/** + * ram_block_from_stream: read a RAMBlock id from the migration stream + * + * Must be called from within a rcu critical section. + * * Returns a pointer from within the RCU-protected ram_list. - */ -/* - * Read a RAMBlock ID from the stream f. * - * f: Stream to read from - * flags: Page flags (mostly to see if it's a continuation of previous blo= ck) + * @f: QEMUFile where to read the data from + * @flags: Page flags (mostly to see if it's a continuation of previous bl= ock) */ -static inline RAMBlock *ram_block_from_stream(QEMUFile *f, - int flags) +static inline RAMBlock *ram_block_from_stream(QEMUFile *f, int flags) { static RAMBlock *block =3D NULL; char id[256]; @@ -2232,9 +2319,15 @@ static inline void *host_from_ram_block_offset(RAMBl= ock *block, return block->host + offset; } =20 -/* +/** + * ram_handle_compressed: handle the zero page case + * * If a page (or a whole RDMA chunk) has been * determined to be zero, then zap it. + * + * @host: host address for the zero page + * @ch: what the page is filled from. We only support zero + * @size: size of the zero page */ void ram_handle_compressed(void *host, uint8_t ch, uint64_t size) { @@ -2373,9 +2466,16 @@ static void decompress_data_with_multi_threads(QEMUF= ile *f, qemu_mutex_unlock(&decomp_done_lock); } =20 -/* - * Allocate data structures etc needed by incoming migration with postcopy= -ram - * postcopy-ram's similarly names postcopy_ram_incoming_init does the work +/** + * ram_postococpy_incoming_init: allocate postcopy data structures + * + * Returns 0 for success and negative if there was one error + * + * @mis: current migration incoming state + * + * Allocate data structures etc needed by incoming migration with + * postcopy-ram postcopy-ram's similarly names + * postcopy_ram_incoming_init does the work */ int ram_postcopy_incoming_init(MigrationIncomingState *mis) { @@ -2384,9 +2484,15 @@ int ram_postcopy_incoming_init(MigrationIncomingStat= e *mis) return postcopy_ram_incoming_init(mis, ram_pages); } =20 -/* +/** + * ram_load_postocpy: load a page in postcopy case + * + * Returns 0 for success or -errno in case of error + * * Called in postcopy mode by ram_load(). * rcu_read_lock is taken prior to this being called. + * + * @f: QEMUFile where to send the data */ static int ram_load_postcopy(QEMUFile *f) { --=20 2.9.3 From nobody Fri May 3 08:55:07 2024 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 1490302067660883.7103530532618; Thu, 23 Mar 2017 13:47:47 -0700 (PDT) Received: from localhost ([::1]:58548 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1cr9e6-0000YK-7J for importer@patchew.org; Thu, 23 Mar 2017 16:47:46 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:45124) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1cr9cH-0007aT-Tu for qemu-devel@nongnu.org; Thu, 23 Mar 2017 16:45:55 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1cr9cH-0008VO-2a for qemu-devel@nongnu.org; Thu, 23 Mar 2017 16:45:53 -0400 Received: from mx1.redhat.com ([209.132.183.28]:38198) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1cr9cG-0008V6-Sz for qemu-devel@nongnu.org; Thu, 23 Mar 2017 16:45:52 -0400 Received: from smtp.corp.redhat.com (int-mx02.intmail.prod.int.phx2.redhat.com [10.5.11.12]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id DEFE2342C73 for ; Thu, 23 Mar 2017 20:45:52 +0000 (UTC) Received: from secure.mitica (ovpn-116-230.ams2.redhat.com [10.36.116.230]) by smtp.corp.redhat.com (Postfix) with ESMTP id E907C53; Thu, 23 Mar 2017 20:45:51 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mx1.redhat.com DEFE2342C73 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 DEFE2342C73 From: Juan Quintela To: qemu-devel@nongnu.org Date: Thu, 23 Mar 2017 21:44:55 +0100 Message-Id: <20170323204544.12015-3-quintela@redhat.com> In-Reply-To: <20170323204544.12015-1-quintela@redhat.com> References: <20170323204544.12015-1-quintela@redhat.com> X-Scanned-By: MIMEDefang 2.79 on 10.5.11.12 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.38]); Thu, 23 Mar 2017 20:45:53 +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/51] ram: rename block_name to rbname 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: 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" So all places are consisten on the nambing of a block name parameter. Signed-off-by: Juan Quintela Reviewed-by: Dr. David Alan Gilbert --- migration/ram.c | 17 ++++++++--------- 1 file changed, 8 insertions(+), 9 deletions(-) diff --git a/migration/ram.c b/migration/ram.c index 76f1fc4..21047c5 100644 --- a/migration/ram.c +++ b/migration/ram.c @@ -743,14 +743,14 @@ static int save_zero_page(QEMUFile *f, RAMBlock *bloc= k, ram_addr_t offset, return pages; } =20 -static void ram_release_pages(MigrationState *ms, const char *block_name, +static void ram_release_pages(MigrationState *ms, const char *rbname, uint64_t offset, int pages) { if (!migrate_release_ram() || !migration_in_postcopy(ms)) { return; } =20 - ram_discard_range(NULL, block_name, offset, pages << TARGET_PAGE_BITS); + ram_discard_range(NULL, rbname, offset, pages << TARGET_PAGE_BITS); } =20 /** @@ -1942,25 +1942,24 @@ int ram_postcopy_send_discard_bitmap(MigrationState= *ms) * Returns zero on success * * @mis: current migration incoming state - * @block_name: Name of the RAMBLock of the request. NULL means the - * same that last one. + * @rbname: name of the RAMBLock of the request. NULL means the + * same that last one. * @start: RAMBlock starting page * @length: RAMBlock size */ int ram_discard_range(MigrationIncomingState *mis, - const char *block_name, + const char *rbname, uint64_t start, size_t length) { int ret =3D -1; =20 - trace_ram_discard_range(block_name, start, length); + trace_ram_discard_range(rbname, start, length); =20 rcu_read_lock(); - RAMBlock *rb =3D qemu_ram_block_by_name(block_name); + RAMBlock *rb =3D qemu_ram_block_by_name(rbname); =20 if (!rb) { - error_report("ram_discard_range: Failed to find block '%s'", - block_name); + error_report("ram_discard_range: Failed to find block '%s'", rbnam= e); goto err; } =20 --=20 2.9.3 From nobody Fri May 3 08:55:07 2024 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 1490302075645878.5068502601601; Thu, 23 Mar 2017 13:47:55 -0700 (PDT) Received: from localhost ([::1]:58549 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1cr9eE-0000of-80 for importer@patchew.org; Thu, 23 Mar 2017 16:47:54 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:45181) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1cr9cL-0007cX-4z for qemu-devel@nongnu.org; Thu, 23 Mar 2017 16:46:00 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1cr9cI-0008WO-Ml for qemu-devel@nongnu.org; Thu, 23 Mar 2017 16:45:57 -0400 Received: from mx1.redhat.com ([209.132.183.28]:39108) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1cr9cI-0008W1-E9 for qemu-devel@nongnu.org; Thu, 23 Mar 2017 16:45:54 -0400 Received: from smtp.corp.redhat.com (int-mx02.intmail.prod.int.phx2.redhat.com [10.5.11.12]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 71A0D804EF for ; Thu, 23 Mar 2017 20:45:54 +0000 (UTC) Received: from secure.mitica (ovpn-116-230.ams2.redhat.com [10.36.116.230]) by smtp.corp.redhat.com (Postfix) with ESMTP id 3E64453; Thu, 23 Mar 2017 20:45:53 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mx1.redhat.com 71A0D804EF 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 71A0D804EF From: Juan Quintela To: qemu-devel@nongnu.org Date: Thu, 23 Mar 2017 21:44:56 +0100 Message-Id: <20170323204544.12015-4-quintela@redhat.com> In-Reply-To: <20170323204544.12015-1-quintela@redhat.com> References: <20170323204544.12015-1-quintela@redhat.com> X-Scanned-By: MIMEDefang 2.79 on 10.5.11.12 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.27]); Thu, 23 Mar 2017 20:45: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 03/51] ram: Create 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: 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 create a struct where to put all the ram state Start with the following fields: 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 -- Fix typo and warnings Signed-off-by: Juan Quintela Reviewed-by: Peter Xu --- migration/ram.c | 140 +++++++++++++++++++++++++++++++++-------------------= ---- 1 file changed, 83 insertions(+), 57 deletions(-) diff --git a/migration/ram.c b/migration/ram.c index 21047c5..a6e90d7 100644 --- a/migration/ram.c +++ b/migration/ram.c @@ -142,6 +142,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 offset 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; @@ -217,16 +234,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 { @@ -444,6 +453,7 @@ static void mig_throttle_guest_down(void) /** * xbzrle_cache_zero_page: insert a zero page in the XBZRLE cache * + * @rs: current RAM state * @current_addr: address for the zero page * * Update the xbzrle cache to reflect a page that's been sent as all 0. @@ -452,9 +462,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 @@ -552,13 +562,14 @@ static int save_xbzrle_page(QEMUFile *f, uint8_t **cu= rrent_data, * * Returns the byte offset within memory region of the start of a dirty pa= ge * + * @rs: current RAM state * @rb: RAMBlock where to search for dirty pages * @start: starting address (typically so we can continue from previous pa= ge) * @ram_addr_abs: pointer into which to store the address of the dirty page * within the global ram_addr space */ 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) { @@ -571,7 +582,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); @@ -761,6 +772,7 @@ static void ram_release_pages(MigrationState *ms, const= char *rbname, * >=3D0 - Number of pages written - this might legally be 0 * if xbzrle noticed the page was the same. * + * @rs: current RAM state * @ms: current migration state * @f: QEMUFile where to send the data * @block: block that contains the page we want to send @@ -768,8 +780,9 @@ static void ram_release_pages(MigrationState *ms, const= char *rbname, * @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; @@ -795,7 +808,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) { @@ -812,9 +825,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= ); @@ -946,6 +959,7 @@ static int compress_page_with_multi_thread(QEMUFile *f,= RAMBlock *block, * * Returns the number of pages written. * + * @rs: current RAM state * @ms: current migration state * @f: QEMUFile where to send the data * @block: block that contains the page we want to send @@ -953,7 +967,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) { @@ -987,7 +1002,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) { @@ -1029,19 +1044,20 @@ static int ram_save_compressed_page(MigrationState = *ms, QEMUFile *f, * * Returns if a page is found * + * @rs: current RAM state * @f: QEMUFile where to send the data * @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. @@ -1058,7 +1074,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. @@ -1125,12 +1141,14 @@ static RAMBlock *unqueue_page(MigrationState *ms, r= am_addr_t *offset, * * Returns if a queued page is found * + * @rs: current RAM state * @ms: current migration state * @pss: data about the state of the current dirty page scan * @ram_addr_abs: pointer into which to store the address of the dirty page * within the global ram_addr space */ -static bool get_queued_page(MigrationState *ms, PageSearchStatus *pss, +static bool get_queued_page(RAMState *rs, MigrationState *ms, + PageSearchStatus *pss, ram_addr_t *ram_addr_abs) { RAMBlock *block; @@ -1171,7 +1189,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 @@ -1282,6 +1300,7 @@ err: * * Returns the umber of pages written * + * @rs: current RAM state * @ms: current migration state * @f: QEMUFile where to send the data * @pss: data about the page we want to send @@ -1289,7 +1308,7 @@ err: * @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_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, @@ -1301,11 +1320,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 @@ -1321,7 +1340,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 @@ -1339,6 +1358,7 @@ static int ram_save_target_page(MigrationState *ms, Q= EMUFile *f, * * Returns the number of pages written or negative on error * + * @rs: current RAM state * @ms: current migration state * @f: QEMUFile where to send the data * @pss: data about the page we want to send @@ -1346,7 +1366,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, @@ -1356,7 +1376,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; @@ -1379,6 +1399,7 @@ static int ram_save_host_page(MigrationState *ms, QEM= UFile *f, * * Returns the number of pages written where zero means no dirty pages * + * @rs: current 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 @@ -1387,7 +1408,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; @@ -1402,8 +1423,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) { @@ -1412,22 +1433,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; } @@ -1509,13 +1530,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 */ @@ -1847,12 +1868,13 @@ static void postcopy_chunk_hostpages_pass(Migration= State *ms, bool unsent_pass, */ static int postcopy_chunk_hostpages(MigrationState *ms) { + RAMState *rs =3D &ram_state; 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; + rs->last_seen_block =3D NULL; + rs->last_sent_block =3D NULL; + rs->last_offset =3D 0; =20 QLIST_FOREACH_RCU(block, &ram_list.blocks, next) { unsigned long first =3D block->offset >> TARGET_PAGE_BITS; @@ -1971,7 +1993,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 @@ -2017,7 +2039,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 */ @@ -2064,11 +2086,12 @@ static int ram_save_init_globals(void) */ 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; } } @@ -2106,14 +2129,15 @@ static int ram_save_setup(QEMUFile *f, void *opaque) */ 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 */ @@ -2126,7 +2150,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; @@ -2180,6 +2204,8 @@ static int ram_save_iterate(QEMUFile *f, void *opaque) */ static int ram_save_complete(QEMUFile *f, void *opaque) { + RAMState *rs =3D opaque; + rcu_read_lock(); =20 if (!migration_in_postcopy(migrate_get_current())) { @@ -2194,7 +2220,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) { @@ -2778,5 +2804,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 Fri May 3 08:55:07 2024 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 1490302214819282.5231328560842; Thu, 23 Mar 2017 13:50:14 -0700 (PDT) Received: from localhost ([::1]:58555 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1cr9gT-0002co-HY for importer@patchew.org; Thu, 23 Mar 2017 16:50:13 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:45175) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1cr9cK-0007cL-SW for qemu-devel@nongnu.org; Thu, 23 Mar 2017 16:46:00 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1cr9cJ-00005L-WB for qemu-devel@nongnu.org; Thu, 23 Mar 2017 16:45:56 -0400 Received: from mx1.redhat.com ([209.132.183.28]:34458) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1cr9cJ-000057-OZ for qemu-devel@nongnu.org; Thu, 23 Mar 2017 16:45:55 -0400 Received: from smtp.corp.redhat.com (int-mx02.intmail.prod.int.phx2.redhat.com [10.5.11.12]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id BC7977AE9A for ; Thu, 23 Mar 2017 20:45:55 +0000 (UTC) Received: from secure.mitica (ovpn-116-230.ams2.redhat.com [10.36.116.230]) by smtp.corp.redhat.com (Postfix) with ESMTP id C375A7FCC7; Thu, 23 Mar 2017 20:45:54 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mx1.redhat.com BC7977AE9A 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 BC7977AE9A From: Juan Quintela To: qemu-devel@nongnu.org Date: Thu, 23 Mar 2017 21:44:57 +0100 Message-Id: <20170323204544.12015-5-quintela@redhat.com> In-Reply-To: <20170323204544.12015-1-quintela@redhat.com> References: <20170323204544.12015-1-quintela@redhat.com> X-Scanned-By: MIMEDefang 2.79 on 10.5.11.12 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.25]); Thu, 23 Mar 2017 20:45: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 04/51] 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: 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: Peter Xu --- migration/ram.c | 21 +++++++++++---------- 1 file changed, 11 insertions(+), 10 deletions(-) diff --git a/migration/ram.c b/migration/ram.c index a6e90d7..1d5bf22 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 /***********************************************************/ @@ -154,6 +152,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 @@ -651,7 +651,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; MigrationState *s =3D migrate_get_current(); @@ -696,9 +696,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; @@ -1919,7 +1919,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) { @@ -1997,7 +1997,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); @@ -2061,7 +2061,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(); @@ -2209,7 +2209,7 @@ static int ram_save_complete(QEMUFile *f, void *opaqu= e) 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); @@ -2242,6 +2242,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; @@ -2250,7 +2251,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 Fri May 3 08:55:07 2024 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 1490302360380280.98478101170997; Thu, 23 Mar 2017 13:52:40 -0700 (PDT) Received: from localhost ([::1]:58570 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1cr9ip-0004nd-49 for importer@patchew.org; Thu, 23 Mar 2017 16:52:39 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:45235) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1cr9cO-0007eN-3f for qemu-devel@nongnu.org; Thu, 23 Mar 2017 16:46:01 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1cr9cL-00006E-BD for qemu-devel@nongnu.org; Thu, 23 Mar 2017 16:46:00 -0400 Received: from mx1.redhat.com ([209.132.183.28]:35846) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1cr9cL-00005Z-3F for qemu-devel@nongnu.org; Thu, 23 Mar 2017 16:45:57 -0400 Received: from smtp.corp.redhat.com (int-mx02.intmail.prod.int.phx2.redhat.com [10.5.11.12]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 1483A61E5F for ; Thu, 23 Mar 2017 20:45:57 +0000 (UTC) Received: from secure.mitica (ovpn-116-230.ams2.redhat.com [10.36.116.230]) by smtp.corp.redhat.com (Postfix) with ESMTP id 1C74F7FCC7; Thu, 23 Mar 2017 20:45:55 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mx1.redhat.com 1483A61E5F 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 1483A61E5F From: Juan Quintela To: qemu-devel@nongnu.org Date: Thu, 23 Mar 2017 21:44:58 +0100 Message-Id: <20170323204544.12015-6-quintela@redhat.com> In-Reply-To: <20170323204544.12015-1-quintela@redhat.com> References: <20170323204544.12015-1-quintela@redhat.com> X-Scanned-By: MIMEDefang 2.79 on 10.5.11.12 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.39]); Thu, 23 Mar 2017 20:45: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 05/51] 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: 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: Peter Xu --- migration/ram.c | 23 ++++++++++++----------- 1 file changed, 12 insertions(+), 11 deletions(-) diff --git a/migration/ram.c b/migration/ram.c index 1d5bf22..f811e81 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 @@ -154,6 +152,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 @@ -471,7 +471,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 @@ -483,6 +483,7 @@ static void xbzrle_cache_zero_page(RAMState *rs, ram_ad= dr_t current_addr) * 0 means that page is identical to the one already sent * -1 means that xbzrle would be longer than normal * + * @rs: current RAM state * @f: QEMUFile where to send the data * @current_data: contents of the page * @current_addr: addr of the page @@ -491,7 +492,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(RAMState *rs, QEMUFile *f, uint8_t **current_d= ata, ram_addr_t current_addr, RAMBlock *block, ram_addr_t offset, bool last_stage, uint64_t *bytes_transferred) @@ -499,11 +500,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 @@ -658,7 +659,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(); @@ -720,9 +721,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 @@ -829,7 +830,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(rs, f, &p, current_addr, block, offset, last_stage, bytes_transferred= ); if (!last_stage) { /* Can't send this cached data async, since the cache page @@ -1998,7 +1999,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 Fri May 3 08:55:07 2024 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 1490302218239403.8549208534463; Thu, 23 Mar 2017 13:50:18 -0700 (PDT) Received: from localhost ([::1]:58556 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1cr9gX-0002fG-1b for importer@patchew.org; Thu, 23 Mar 2017 16:50:17 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:45237) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1cr9cO-0007eO-3q for qemu-devel@nongnu.org; Thu, 23 Mar 2017 16:46:01 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1cr9cM-000079-Lp for qemu-devel@nongnu.org; Thu, 23 Mar 2017 16:46:00 -0400 Received: from mx1.redhat.com ([209.132.183.28]:34506) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1cr9cM-00006U-Cs for qemu-devel@nongnu.org; Thu, 23 Mar 2017 16:45:58 -0400 Received: from smtp.corp.redhat.com (int-mx02.intmail.prod.int.phx2.redhat.com [10.5.11.12]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 5F7417AE98 for ; Thu, 23 Mar 2017 20:45:58 +0000 (UTC) Received: from secure.mitica (ovpn-116-230.ams2.redhat.com [10.36.116.230]) by smtp.corp.redhat.com (Postfix) with ESMTP id 654C27FCC0; Thu, 23 Mar 2017 20:45:57 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mx1.redhat.com 5F7417AE98 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 5F7417AE98 From: Juan Quintela To: qemu-devel@nongnu.org Date: Thu, 23 Mar 2017 21:44:59 +0100 Message-Id: <20170323204544.12015-7-quintela@redhat.com> In-Reply-To: <20170323204544.12015-1-quintela@redhat.com> References: <20170323204544.12015-1-quintela@redhat.com> X-Scanned-By: MIMEDefang 2.79 on 10.5.11.12 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.25]); Thu, 23 Mar 2017 20:45: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 06/51] 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: 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: Peter Xu --- migration/ram.c | 20 +++++++++++--------- 1 file changed, 11 insertions(+), 9 deletions(-) diff --git a/migration/ram.c b/migration/ram.c index f811e81..5881805 100644 --- a/migration/ram.c +++ b/migration/ram.c @@ -154,6 +154,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 @@ -617,14 +620,13 @@ 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 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; @@ -665,8 +667,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(); @@ -685,7 +687,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. @@ -716,9 +718,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; @@ -2000,7 +2002,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 Fri May 3 08:55:07 2024 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 149030236237595.49459660842774; Thu, 23 Mar 2017 13:52:42 -0700 (PDT) Received: from localhost ([::1]:58571 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1cr9ir-0004p3-5t for importer@patchew.org; Thu, 23 Mar 2017 16:52:41 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:45248) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1cr9cO-0007eP-L1 for qemu-devel@nongnu.org; Thu, 23 Mar 2017 16:46:01 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1cr9cN-00007m-Rj for qemu-devel@nongnu.org; Thu, 23 Mar 2017 16:46:00 -0400 Received: from mx1.redhat.com ([209.132.183.28]:35894) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1cr9cN-00007T-Lr for qemu-devel@nongnu.org; Thu, 23 Mar 2017 16:45:59 -0400 Received: from smtp.corp.redhat.com (int-mx02.intmail.prod.int.phx2.redhat.com [10.5.11.12]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id A7A63624CD for ; Thu, 23 Mar 2017 20:45:59 +0000 (UTC) Received: from secure.mitica (ovpn-116-230.ams2.redhat.com [10.36.116.230]) by smtp.corp.redhat.com (Postfix) with ESMTP id B0E3F77ECB; Thu, 23 Mar 2017 20:45:58 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mx1.redhat.com A7A63624CD 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 A7A63624CD From: Juan Quintela To: qemu-devel@nongnu.org Date: Thu, 23 Mar 2017 21:45:00 +0100 Message-Id: <20170323204544.12015-8-quintela@redhat.com> In-Reply-To: <20170323204544.12015-1-quintela@redhat.com> References: <20170323204544.12015-1-quintela@redhat.com> X-Scanned-By: MIMEDefang 2.79 on 10.5.11.12 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.39]); Thu, 23 Mar 2017 20:45:59 +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/51] 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: 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: Peter Xu --- migration/ram.c | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) diff --git a/migration/ram.c b/migration/ram.c index 5881805..5e53b47 100644 --- a/migration/ram.c +++ b/migration/ram.c @@ -157,6 +157,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 @@ -620,14 +622,13 @@ 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 bytes_xfer_prev; static uint64_t xbzrle_cache_miss_prev; static uint64_t iterations_prev; =20 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; @@ -663,8 +664,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) { @@ -698,13 +699,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 Fri May 3 08:55:07 2024 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 1490302496454887.8404466001449; Thu, 23 Mar 2017 13:54:56 -0700 (PDT) Received: from localhost ([::1]:58578 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1cr9l1-0006v1-18 for importer@patchew.org; Thu, 23 Mar 2017 16:54:55 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:45287) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1cr9cR-0007hG-PE for qemu-devel@nongnu.org; Thu, 23 Mar 2017 16:46:04 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1cr9cQ-00009C-NQ for qemu-devel@nongnu.org; Thu, 23 Mar 2017 16:46:03 -0400 Received: from mx1.redhat.com ([209.132.183.28]:34576) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1cr9cQ-00008v-Fg for qemu-devel@nongnu.org; Thu, 23 Mar 2017 16:46:02 -0400 Received: from smtp.corp.redhat.com (int-mx02.intmail.prod.int.phx2.redhat.com [10.5.11.12]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 73EAF7AE9A for ; Thu, 23 Mar 2017 20:46:02 +0000 (UTC) Received: from secure.mitica (ovpn-116-230.ams2.redhat.com [10.36.116.230]) by smtp.corp.redhat.com (Postfix) with ESMTP id 04CF37FCC7; Thu, 23 Mar 2017 20:45:59 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mx1.redhat.com 73EAF7AE9A 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 73EAF7AE9A From: Juan Quintela To: qemu-devel@nongnu.org Date: Thu, 23 Mar 2017 21:45:01 +0100 Message-Id: <20170323204544.12015-9-quintela@redhat.com> In-Reply-To: <20170323204544.12015-1-quintela@redhat.com> References: <20170323204544.12015-1-quintela@redhat.com> X-Scanned-By: MIMEDefang 2.79 on 10.5.11.12 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.25]); Thu, 23 Mar 2017 20:46: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 08/51] 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: 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: Peter Xu --- migration/ram.c | 20 +++++++++++--------- 1 file changed, 11 insertions(+), 9 deletions(-) diff --git a/migration/ram.c b/migration/ram.c index 5e53b47..748d047 100644 --- a/migration/ram.c +++ b/migration/ram.c @@ -159,6 +159,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 @@ -612,13 +614,13 @@ static inline bool migration_bitmap_clear_dirty(ram_a= ddr_t addr) return ret; } =20 -static int64_t num_dirty_pages_period; -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 cpu_physical_memory_sync_dirty_bitmap(bitma= p, - start, length, &num_dirty_pages_period); + start, length, &rs->num_dirty_pages_period); } =20 /* Fix me: there are too many global variables used in migration process. = */ @@ -629,7 +631,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; } @@ -678,12 +680,12 @@ 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(num_dirty_pages_period); + trace_migration_bitmap_sync_end(rs->num_dirty_pages_period); =20 end_time =3D qemu_clock_get_ms(QEMU_CLOCK_REALTIME); =20 @@ -698,7 +700,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(); @@ -718,11 +720,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 Fri May 3 08:55:07 2024 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 1490302231745723.5192965771845; Thu, 23 Mar 2017 13:50:31 -0700 (PDT) Received: from localhost ([::1]:58562 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1cr9gk-0002sQ-Fq for importer@patchew.org; Thu, 23 Mar 2017 16:50:30 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:45307) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1cr9cS-0007hP-Ov for qemu-devel@nongnu.org; Thu, 23 Mar 2017 16:46:05 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1cr9cR-00009e-W4 for qemu-devel@nongnu.org; Thu, 23 Mar 2017 16:46:04 -0400 Received: from mx1.redhat.com ([209.132.183.28]:46952) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1cr9cR-00009J-QM for qemu-devel@nongnu.org; Thu, 23 Mar 2017 16:46:03 -0400 Received: from smtp.corp.redhat.com (int-mx02.intmail.prod.int.phx2.redhat.com [10.5.11.12]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id C84A8C05AA41 for ; Thu, 23 Mar 2017 20:46:03 +0000 (UTC) Received: from secure.mitica (ovpn-116-230.ams2.redhat.com [10.36.116.230]) by smtp.corp.redhat.com (Postfix) with ESMTP id C65A153; Thu, 23 Mar 2017 20:46:02 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mx1.redhat.com C84A8C05AA41 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 C84A8C05AA41 From: Juan Quintela To: qemu-devel@nongnu.org Date: Thu, 23 Mar 2017 21:45:02 +0100 Message-Id: <20170323204544.12015-10-quintela@redhat.com> In-Reply-To: <20170323204544.12015-1-quintela@redhat.com> References: <20170323204544.12015-1-quintela@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.12 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.32]); Thu, 23 Mar 2017 20:46:03 +0000 (UTC) Content-Transfer-Encoding: quoted-printable 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/51] 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: 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-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 748d047..826ba6d 100644 --- a/migration/ram.c +++ b/migration/ram.c @@ -161,6 +161,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 beginning of the period */ + uint64_t xbzrle_cache_miss_prev; }; typedef struct RAMState RAMState; =20 @@ -624,7 +626,6 @@ static void migration_bitmap_sync_range(RAMState *rs, r= am_addr_t start, } =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) @@ -632,7 +633,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 @@ -714,11 +715,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 Fri May 3 08:55:07 2024 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 1490302375869595.6360701215605; Thu, 23 Mar 2017 13:52:55 -0700 (PDT) Received: from localhost ([::1]:58572 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1cr9j4-00051g-5x for importer@patchew.org; Thu, 23 Mar 2017 16:52:54 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:45331) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1cr9cU-0007jF-5P for qemu-devel@nongnu.org; Thu, 23 Mar 2017 16:46:09 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1cr9cT-0000AE-7o for qemu-devel@nongnu.org; Thu, 23 Mar 2017 16:46:06 -0400 Received: from mx1.redhat.com ([209.132.183.28]:59546) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1cr9cT-00009v-2k for qemu-devel@nongnu.org; Thu, 23 Mar 2017 16:46:05 -0400 Received: from smtp.corp.redhat.com (int-mx02.intmail.prod.int.phx2.redhat.com [10.5.11.12]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 18EDD7E9CB for ; Thu, 23 Mar 2017 20:46:05 +0000 (UTC) Received: from secure.mitica (ovpn-116-230.ams2.redhat.com [10.36.116.230]) by smtp.corp.redhat.com (Postfix) with ESMTP id 22F557FCC8; Thu, 23 Mar 2017 20:46:03 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mx1.redhat.com 18EDD7E9CB Authentication-Results: ext-mx02.extmail.prod.ext.phx2.redhat.com; dmarc=none (p=none dis=none) header.from=redhat.com Authentication-Results: ext-mx02.extmail.prod.ext.phx2.redhat.com; spf=pass smtp.mailfrom=quintela@redhat.com DKIM-Filter: OpenDKIM Filter v2.11.0 mx1.redhat.com 18EDD7E9CB From: Juan Quintela To: qemu-devel@nongnu.org Date: Thu, 23 Mar 2017 21:45:03 +0100 Message-Id: <20170323204544.12015-11-quintela@redhat.com> In-Reply-To: <20170323204544.12015-1-quintela@redhat.com> References: <20170323204544.12015-1-quintela@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.12 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.26]); Thu, 23 Mar 2017 20:46:05 +0000 (UTC) Content-Transfer-Encoding: quoted-printable 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/51] 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: 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-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 826ba6d..d8428c1 100644 --- a/migration/ram.c +++ b/migration/ram.c @@ -163,6 +163,8 @@ struct RAMState { int64_t num_dirty_pages_period; /* xbzrle misses since the beginning of the period */ uint64_t xbzrle_cache_miss_prev; + /* number of iterations at the beginning of period */ + uint64_t iterations_prev; }; typedef struct RAMState RAMState; =20 @@ -625,16 +627,13 @@ static void migration_bitmap_sync_range(RAMState *rs,= ram_addr_t start, start, length, &rs->num_dirty_pages_period); } =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 /** @@ -712,13 +711,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 Fri May 3 08:55:07 2024 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 1490302235587242.96749257186127; Thu, 23 Mar 2017 13:50:35 -0700 (PDT) Received: from localhost ([::1]:58563 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1cr9go-0002wv-82 for importer@patchew.org; Thu, 23 Mar 2017 16:50:34 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:45356) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1cr9cX-0007mE-BM for qemu-devel@nongnu.org; Thu, 23 Mar 2017 16:46:10 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1cr9cU-0000Al-Mg for qemu-devel@nongnu.org; Thu, 23 Mar 2017 16:46:09 -0400 Received: from mx1.redhat.com ([209.132.183.28]:44944) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1cr9cU-0000AK-EU for qemu-devel@nongnu.org; Thu, 23 Mar 2017 16:46:06 -0400 Received: from smtp.corp.redhat.com (int-mx02.intmail.prod.int.phx2.redhat.com [10.5.11.12]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 6DC53C0467F1 for ; Thu, 23 Mar 2017 20:46:06 +0000 (UTC) Received: from secure.mitica (ovpn-116-230.ams2.redhat.com [10.36.116.230]) by smtp.corp.redhat.com (Postfix) with ESMTP id 7473177ECB; Thu, 23 Mar 2017 20:46:05 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mx1.redhat.com 6DC53C0467F1 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 6DC53C0467F1 From: Juan Quintela To: qemu-devel@nongnu.org Date: Thu, 23 Mar 2017 21:45:04 +0100 Message-Id: <20170323204544.12015-12-quintela@redhat.com> In-Reply-To: <20170323204544.12015-1-quintela@redhat.com> References: <20170323204544.12015-1-quintela@redhat.com> X-Scanned-By: MIMEDefang 2.79 on 10.5.11.12 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.31]); Thu, 23 Mar 2017 20:46: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 11/51] 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: 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 Reviewed-by: Peter Xu --- migration/ram.c | 29 ++++++++++++++++++----------- 1 file changed, 18 insertions(+), 11 deletions(-) diff --git a/migration/ram.c b/migration/ram.c index d8428c1..0da133f 100644 --- a/migration/ram.c +++ b/migration/ram.c @@ -165,6 +165,9 @@ struct RAMState { uint64_t xbzrle_cache_miss_prev; /* number of iterations at the beginning 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 @@ -172,7 +175,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; @@ -192,12 +194,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) @@ -737,19 +739,21 @@ static void migration_bitmap_sync(RAMState *rs) * * Returns the number of pages written. * + * @rs: current RAM state * @f: QEMUFile where to send the data * @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(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); @@ -822,11 +826,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 @@ -998,7 +1002,7 @@ static int ram_save_compressed_page(RAMState *rs, Migr= ationState *ms, if (bytes_xmit > 0) { acct_info.norm_pages++; } else if (bytes_xmit =3D=3D 0) { - acct_info.dup_pages++; + rs->zero_pages++; } } } else { @@ -1010,7 +1014,7 @@ static int ram_save_compressed_page(RAMState *rs, Mig= rationState *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 | @@ -1031,7 +1035,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); @@ -1462,8 +1466,10 @@ static int ram_find_and_save_block(RAMState *rs, QEM= UFile *f, bool last_stage, void acct_update_position(QEMUFile *f, size_t size, bool zero) { uint64_t pages =3D size / TARGET_PAGE_SIZE; + RAMState *rs =3D &ram_state; + if (zero) { - acct_info.dup_pages +=3D pages; + rs->zero_pages +=3D pages; } else { acct_info.norm_pages +=3D pages; bytes_transferred +=3D size; @@ -2005,6 +2011,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 Fri May 3 08:55:07 2024 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 1490302497248378.8555518008594; Thu, 23 Mar 2017 13:54:57 -0700 (PDT) Received: from localhost ([::1]:58579 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1cr9l2-0006wL-3j for importer@patchew.org; Thu, 23 Mar 2017 16:54:56 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:45355) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1cr9cX-0007mD-B9 for qemu-devel@nongnu.org; Thu, 23 Mar 2017 16:46:10 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1cr9cV-0000CI-UD for qemu-devel@nongnu.org; Thu, 23 Mar 2017 16:46:09 -0400 Received: from mx1.redhat.com ([209.132.183.28]:44958) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1cr9cV-0000BJ-O8 for qemu-devel@nongnu.org; Thu, 23 Mar 2017 16:46:07 -0400 Received: from smtp.corp.redhat.com (int-mx02.intmail.prod.int.phx2.redhat.com [10.5.11.12]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id B2F1FC04B31F for ; Thu, 23 Mar 2017 20:46:07 +0000 (UTC) Received: from secure.mitica (ovpn-116-230.ams2.redhat.com [10.36.116.230]) by smtp.corp.redhat.com (Postfix) with ESMTP id BD61053; Thu, 23 Mar 2017 20:46:06 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mx1.redhat.com B2F1FC04B31F 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 B2F1FC04B31F From: Juan Quintela To: qemu-devel@nongnu.org Date: Thu, 23 Mar 2017 21:45:05 +0100 Message-Id: <20170323204544.12015-13-quintela@redhat.com> In-Reply-To: <20170323204544.12015-1-quintela@redhat.com> References: <20170323204544.12015-1-quintela@redhat.com> X-Scanned-By: MIMEDefang 2.79 on 10.5.11.12 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.31]); Thu, 23 Mar 2017 20:46:07 +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/51] ram: Remove unused dup_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: 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: Peter Xu --- 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 0da133f..af385c4 100644 --- a/migration/ram.c +++ b/migration/ram.c @@ -192,11 +192,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 Fri May 3 08:55:07 2024 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 1490302510155991.0926363744612; Thu, 23 Mar 2017 13:55:10 -0700 (PDT) Received: from localhost ([::1]:58580 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1cr9lF-00078n-27 for importer@patchew.org; Thu, 23 Mar 2017 16:55:09 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:45371) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1cr9cY-0007mc-4o for qemu-devel@nongnu.org; Thu, 23 Mar 2017 16:46:11 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1cr9cX-0000DF-70 for qemu-devel@nongnu.org; Thu, 23 Mar 2017 16:46:10 -0400 Received: from mx1.redhat.com ([209.132.183.28]:39650) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1cr9cX-0000Cx-17 for qemu-devel@nongnu.org; Thu, 23 Mar 2017 16:46:09 -0400 Received: from smtp.corp.redhat.com (int-mx02.intmail.prod.int.phx2.redhat.com [10.5.11.12]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 084E115567 for ; Thu, 23 Mar 2017 20:46:09 +0000 (UTC) Received: from secure.mitica (ovpn-116-230.ams2.redhat.com [10.36.116.230]) by smtp.corp.redhat.com (Postfix) with ESMTP id 113AB53; Thu, 23 Mar 2017 20:46:07 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mx1.redhat.com 084E115567 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 084E115567 From: Juan Quintela To: qemu-devel@nongnu.org Date: Thu, 23 Mar 2017 21:45:06 +0100 Message-Id: <20170323204544.12015-14-quintela@redhat.com> In-Reply-To: <20170323204544.12015-1-quintela@redhat.com> References: <20170323204544.12015-1-quintela@redhat.com> X-Scanned-By: MIMEDefang 2.79 on 10.5.11.12 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.29]); Thu, 23 Mar 2017 20:46: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 13/51] ram: Remove unused pages_skipped 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: 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 Reviewed-by: Peter Xu --- 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 54060f7..c078157 100644 --- a/migration/migration.c +++ b/migration/migration.c @@ -643,7 +643,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 af385c4..57f5858 100644 --- a/migration/ram.c +++ b/migration/ram.c @@ -175,7 +175,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; @@ -197,16 +196,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 Fri May 3 08:55:07 2024 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 1490302633056804.0770834852779; Thu, 23 Mar 2017 13:57:13 -0700 (PDT) Received: from localhost ([::1]:58593 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1cr9nD-0000Vd-SD for importer@patchew.org; Thu, 23 Mar 2017 16:57:11 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:45394) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1cr9cZ-0007oI-NW for qemu-devel@nongnu.org; Thu, 23 Mar 2017 16:46:13 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1cr9cY-0000EZ-Jp for qemu-devel@nongnu.org; Thu, 23 Mar 2017 16:46:11 -0400 Received: from mx1.redhat.com ([209.132.183.28]:59578) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1cr9cY-0000DX-BX for qemu-devel@nongnu.org; Thu, 23 Mar 2017 16:46:10 -0400 Received: from smtp.corp.redhat.com (int-mx02.intmail.prod.int.phx2.redhat.com [10.5.11.12]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 51DCC7E9E1 for ; Thu, 23 Mar 2017 20:46:10 +0000 (UTC) Received: from secure.mitica (ovpn-116-230.ams2.redhat.com [10.36.116.230]) by smtp.corp.redhat.com (Postfix) with ESMTP id 5B52A7FCC7; Thu, 23 Mar 2017 20:46:09 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mx1.redhat.com 51DCC7E9E1 Authentication-Results: ext-mx02.extmail.prod.ext.phx2.redhat.com; dmarc=none (p=none dis=none) header.from=redhat.com Authentication-Results: ext-mx02.extmail.prod.ext.phx2.redhat.com; spf=pass smtp.mailfrom=quintela@redhat.com DKIM-Filter: OpenDKIM Filter v2.11.0 mx1.redhat.com 51DCC7E9E1 From: Juan Quintela To: qemu-devel@nongnu.org Date: Thu, 23 Mar 2017 21:45:07 +0100 Message-Id: <20170323204544.12015-15-quintela@redhat.com> In-Reply-To: <20170323204544.12015-1-quintela@redhat.com> References: <20170323204544.12015-1-quintela@redhat.com> X-Scanned-By: MIMEDefang 2.79 on 10.5.11.12 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.26]); Thu, 23 Mar 2017 20:46:10 +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/51] 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: 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: Peter Xu --- migration/ram.c | 26 ++++++++++++++------------ 1 file changed, 14 insertions(+), 12 deletions(-) diff --git a/migration/ram.c b/migration/ram.c index 57f5858..2c36729 100644 --- a/migration/ram.c +++ b/migration/ram.c @@ -168,6 +168,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 @@ -175,7 +177,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; @@ -198,12 +199,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) @@ -808,7 +809,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++; } @@ -847,7 +848,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(); @@ -914,8 +915,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; @@ -932,7 +933,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; } @@ -984,7 +985,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++; } @@ -1007,7 +1008,7 @@ static int ram_save_compressed_page(RAMState *rs, Mig= rationState *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); @@ -1021,7 +1022,7 @@ static int ram_save_compressed_page(RAMState *rs, Mig= rationState *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); @@ -1455,7 +1456,7 @@ void acct_update_position(QEMUFile *f, size_t size, b= ool zero) if (zero) { rs->zero_pages +=3D pages; } else { - acct_info.norm_pages +=3D pages; + rs->norm_pages +=3D pages; bytes_transferred +=3D size; qemu_update_position(f, size); } @@ -1996,6 +1997,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 Fri May 3 08:55:07 2024 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 1490302645563725.0481228785367; Thu, 23 Mar 2017 13:57:25 -0700 (PDT) Received: from localhost ([::1]:58595 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1cr9nQ-0000mV-DK for importer@patchew.org; Thu, 23 Mar 2017 16:57:24 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:45405) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1cr9ca-0007pF-Mf for qemu-devel@nongnu.org; Thu, 23 Mar 2017 16:46:13 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1cr9cZ-0000FI-Qb for qemu-devel@nongnu.org; Thu, 23 Mar 2017 16:46:12 -0400 Received: from mx1.redhat.com ([209.132.183.28]:47324) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1cr9cZ-0000Eg-Kb for qemu-devel@nongnu.org; Thu, 23 Mar 2017 16:46:11 -0400 Received: from smtp.corp.redhat.com (int-mx02.intmail.prod.int.phx2.redhat.com [10.5.11.12]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 9B3CC3B713 for ; Thu, 23 Mar 2017 20:46:11 +0000 (UTC) Received: from secure.mitica (ovpn-116-230.ams2.redhat.com [10.36.116.230]) by smtp.corp.redhat.com (Postfix) with ESMTP id A4FB77FCC7; Thu, 23 Mar 2017 20:46:10 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mx1.redhat.com 9B3CC3B713 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 9B3CC3B713 From: Juan Quintela To: qemu-devel@nongnu.org Date: Thu, 23 Mar 2017 21:45:08 +0100 Message-Id: <20170323204544.12015-16-quintela@redhat.com> In-Reply-To: <20170323204544.12015-1-quintela@redhat.com> References: <20170323204544.12015-1-quintela@redhat.com> X-Scanned-By: MIMEDefang 2.79 on 10.5.11.12 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.30]); Thu, 23 Mar 2017 20:46: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 15/51] 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: 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 c078157..e532430 100644 --- a/migration/migration.c +++ b/migration/migration.c @@ -646,7 +646,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 2c36729..9fa3bd7 100644 --- a/migration/ram.c +++ b/migration/ram.c @@ -197,11 +197,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 Fri May 3 08:55:07 2024 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 1490302782757632.7767295316086; Thu, 23 Mar 2017 13:59:42 -0700 (PDT) Received: from localhost ([::1]:58603 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1cr9pd-0002xP-Ky for importer@patchew.org; Thu, 23 Mar 2017 16:59:41 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:45428) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1cr9cc-0007qg-18 for qemu-devel@nongnu.org; Thu, 23 Mar 2017 16:46:14 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1cr9cb-0000Gh-3o for qemu-devel@nongnu.org; Thu, 23 Mar 2017 16:46:14 -0400 Received: from mx1.redhat.com ([209.132.183.28]:47350) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1cr9ca-0000GG-UT for qemu-devel@nongnu.org; Thu, 23 Mar 2017 16:46:13 -0400 Received: from smtp.corp.redhat.com (int-mx02.intmail.prod.int.phx2.redhat.com [10.5.11.12]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id ED05E3B713 for ; Thu, 23 Mar 2017 20:46:12 +0000 (UTC) Received: from secure.mitica (ovpn-116-230.ams2.redhat.com [10.36.116.230]) by smtp.corp.redhat.com (Postfix) with ESMTP id EEDBB53; Thu, 23 Mar 2017 20:46:11 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mx1.redhat.com ED05E3B713 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 ED05E3B713 From: Juan Quintela To: qemu-devel@nongnu.org Date: Thu, 23 Mar 2017 21:45:09 +0100 Message-Id: <20170323204544.12015-17-quintela@redhat.com> In-Reply-To: <20170323204544.12015-1-quintela@redhat.com> References: <20170323204544.12015-1-quintela@redhat.com> X-Scanned-By: MIMEDefang 2.79 on 10.5.11.12 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.30]); Thu, 23 Mar 2017 20:46:13 +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/51] 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: 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: Peter Xu --- migration/ram.c | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/migration/ram.c b/migration/ram.c index 9fa3bd7..690ca8f 100644 --- a/migration/ram.c +++ b/migration/ram.c @@ -170,6 +170,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 @@ -177,7 +179,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; @@ -693,13 +694,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 @@ -1993,6 +1994,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 @@ -2150,7 +2152,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 Fri May 3 08:55:07 2024 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 1490302770966178.5696088385847; Thu, 23 Mar 2017 13:59:30 -0700 (PDT) Received: from localhost ([::1]:58602 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1cr9pR-0002nH-PZ for importer@patchew.org; Thu, 23 Mar 2017 16:59:29 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:45444) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1cr9cd-0007rz-A7 for qemu-devel@nongnu.org; Thu, 23 Mar 2017 16:46:18 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1cr9cc-0000Hk-Er for qemu-devel@nongnu.org; Thu, 23 Mar 2017 16:46:15 -0400 Received: from mx1.redhat.com ([209.132.183.28]:39420) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1cr9cc-0000H8-9L for qemu-devel@nongnu.org; Thu, 23 Mar 2017 16:46:14 -0400 Received: from smtp.corp.redhat.com (int-mx02.intmail.prod.int.phx2.redhat.com [10.5.11.12]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 45C21804E5 for ; Thu, 23 Mar 2017 20:46:14 +0000 (UTC) Received: from secure.mitica (ovpn-116-230.ams2.redhat.com [10.36.116.230]) by smtp.corp.redhat.com (Postfix) with ESMTP id 4B69053; Thu, 23 Mar 2017 20:46:13 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mx1.redhat.com 45C21804E5 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 45C21804E5 From: Juan Quintela To: qemu-devel@nongnu.org Date: Thu, 23 Mar 2017 21:45:10 +0100 Message-Id: <20170323204544.12015-18-quintela@redhat.com> In-Reply-To: <20170323204544.12015-1-quintela@redhat.com> References: <20170323204544.12015-1-quintela@redhat.com> X-Scanned-By: MIMEDefang 2.79 on 10.5.11.12 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.27]); Thu, 23 Mar 2017 20:46:14 +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/51] 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: 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: Peter Xu --- migration/ram.c | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/migration/ram.c b/migration/ram.c index 690ca8f..721fd66 100644 --- a/migration/ram.c +++ b/migration/ram.c @@ -172,6 +172,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 @@ -179,7 +181,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; @@ -205,7 +206,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) @@ -544,7 +545,7 @@ static int save_xbzrle_page(RAMState *rs, QEMUFile *f, = 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; @@ -1995,6 +1996,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 Fri May 3 08:55:07 2024 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 1490302926894533.9998825629663; Thu, 23 Mar 2017 14:02:06 -0700 (PDT) Received: from localhost ([::1]:58620 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1cr9rx-00052m-IS for importer@patchew.org; Thu, 23 Mar 2017 17:02:05 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:45483) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1cr9cg-0007uy-Hh for qemu-devel@nongnu.org; Thu, 23 Mar 2017 16:46:19 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1cr9cd-0000IK-Pc for qemu-devel@nongnu.org; Thu, 23 Mar 2017 16:46:18 -0400 Received: from mx1.redhat.com ([209.132.183.28]:47430) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1cr9cd-0000I2-J3 for qemu-devel@nongnu.org; Thu, 23 Mar 2017 16:46:15 -0400 Received: from smtp.corp.redhat.com (int-mx02.intmail.prod.int.phx2.redhat.com [10.5.11.12]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 8D6553DBD4 for ; Thu, 23 Mar 2017 20:46:15 +0000 (UTC) Received: from secure.mitica (ovpn-116-230.ams2.redhat.com [10.36.116.230]) by smtp.corp.redhat.com (Postfix) with ESMTP id 9744C53; Thu, 23 Mar 2017 20:46:14 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mx1.redhat.com 8D6553DBD4 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 8D6553DBD4 From: Juan Quintela To: qemu-devel@nongnu.org Date: Thu, 23 Mar 2017 21:45:11 +0100 Message-Id: <20170323204544.12015-19-quintela@redhat.com> In-Reply-To: <20170323204544.12015-1-quintela@redhat.com> References: <20170323204544.12015-1-quintela@redhat.com> X-Scanned-By: MIMEDefang 2.79 on 10.5.11.12 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.30]); Thu, 23 Mar 2017 20:46:15 +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/51] 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: 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: Peter Xu --- migration/ram.c | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/migration/ram.c b/migration/ram.c index 721fd66..b4e647a 100644 --- a/migration/ram.c +++ b/migration/ram.c @@ -174,6 +174,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 @@ -181,7 +183,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; @@ -211,7 +212,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) @@ -544,7 +545,7 @@ static int save_xbzrle_page(RAMState *rs, QEMUFile *f, = 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 @@ -1997,6 +1998,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 Fri May 3 08:55:07 2024 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 1490302693160756.2585620834245; Thu, 23 Mar 2017 13:58:13 -0700 (PDT) Received: from localhost ([::1]:58597 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1cr9oB-0001T2-I1 for importer@patchew.org; Thu, 23 Mar 2017 16:58:11 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:45487) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1cr9cg-0007vR-Vz for qemu-devel@nongnu.org; Thu, 23 Mar 2017 16:46:20 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1cr9cf-0000JM-Th for qemu-devel@nongnu.org; Thu, 23 Mar 2017 16:46:19 -0400 Received: from mx1.redhat.com ([209.132.183.28]:37668) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1cr9cf-0000Iz-Nr for qemu-devel@nongnu.org; Thu, 23 Mar 2017 16:46:17 -0400 Received: from smtp.corp.redhat.com (int-mx02.intmail.prod.int.phx2.redhat.com [10.5.11.12]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id ACB508B13F for ; Thu, 23 Mar 2017 20:46:17 +0000 (UTC) Received: from secure.mitica (ovpn-116-230.ams2.redhat.com [10.36.116.230]) by smtp.corp.redhat.com (Postfix) with ESMTP id E06B353; Thu, 23 Mar 2017 20:46:15 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mx1.redhat.com ACB508B13F 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 ACB508B13F From: Juan Quintela To: qemu-devel@nongnu.org Date: Thu, 23 Mar 2017 21:45:12 +0100 Message-Id: <20170323204544.12015-20-quintela@redhat.com> In-Reply-To: <20170323204544.12015-1-quintela@redhat.com> References: <20170323204544.12015-1-quintela@redhat.com> X-Scanned-By: MIMEDefang 2.79 on 10.5.11.12 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.28]); Thu, 23 Mar 2017 20:46:17 +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/51] 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: 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: Peter Xu --- migration/ram.c | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/migration/ram.c b/migration/ram.c index b4e647a..cc19406 100644 --- a/migration/ram.c +++ b/migration/ram.c @@ -176,6 +176,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 @@ -183,7 +185,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; @@ -217,7 +218,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) @@ -497,7 +498,7 @@ static int save_xbzrle_page(RAMState *rs, QEMUFile *f, = 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) { @@ -698,12 +699,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); @@ -1999,6 +2000,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 Fri May 3 08:55:07 2024 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 1490303081894967.291518268941; Thu, 23 Mar 2017 14:04:41 -0700 (PDT) Received: from localhost ([::1]:58628 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1cr9uS-0007MH-Ka for importer@patchew.org; Thu, 23 Mar 2017 17:04:40 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:45516) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1cr9ci-0007wb-3k for qemu-devel@nongnu.org; Thu, 23 Mar 2017 16:46:21 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1cr9ch-0000L8-5t for qemu-devel@nongnu.org; Thu, 23 Mar 2017 16:46:20 -0400 Received: from mx1.redhat.com ([209.132.183.28]:38718) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1cr9ch-0000KE-0H for qemu-devel@nongnu.org; Thu, 23 Mar 2017 16:46:19 -0400 Received: from smtp.corp.redhat.com (int-mx02.intmail.prod.int.phx2.redhat.com [10.5.11.12]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 0554F4E4D0 for ; Thu, 23 Mar 2017 20:46:19 +0000 (UTC) Received: from secure.mitica (ovpn-116-230.ams2.redhat.com [10.36.116.230]) by smtp.corp.redhat.com (Postfix) with ESMTP id 0A92A53; Thu, 23 Mar 2017 20:46:17 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mx1.redhat.com 0554F4E4D0 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 0554F4E4D0 From: Juan Quintela To: qemu-devel@nongnu.org Date: Thu, 23 Mar 2017 21:45:13 +0100 Message-Id: <20170323204544.12015-21-quintela@redhat.com> In-Reply-To: <20170323204544.12015-1-quintela@redhat.com> References: <20170323204544.12015-1-quintela@redhat.com> X-Scanned-By: MIMEDefang 2.79 on 10.5.11.12 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.38]); Thu, 23 Mar 2017 20:46:19 +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/51] 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: 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: Peter Xu --- migration/ram.c | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/migration/ram.c b/migration/ram.c index cc19406..c398ff9 100644 --- a/migration/ram.c +++ b/migration/ram.c @@ -178,6 +178,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 @@ -185,7 +187,6 @@ static RAMState ram_state; =20 /* accounting for migration statistics */ typedef struct AccountingInfo { - double xbzrle_cache_miss_rate; uint64_t xbzrle_overflows; } AccountingInfo; =20 @@ -223,7 +224,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) @@ -698,7 +699,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); @@ -2001,6 +2002,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 Fri May 3 08:55:07 2024 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 1490302830633881.331425979399; Thu, 23 Mar 2017 14:00:30 -0700 (PDT) Received: from localhost ([::1]:58611 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1cr9qN-0003fu-2E for importer@patchew.org; Thu, 23 Mar 2017 17:00:27 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:45530) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1cr9cj-0007xt-Bi for qemu-devel@nongnu.org; Thu, 23 Mar 2017 16:46:22 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1cr9ci-0000Nc-FU for qemu-devel@nongnu.org; Thu, 23 Mar 2017 16:46:21 -0400 Received: from mx1.redhat.com ([209.132.183.28]:37726) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1cr9ci-0000M0-9o for qemu-devel@nongnu.org; Thu, 23 Mar 2017 16:46:20 -0400 Received: from smtp.corp.redhat.com (int-mx02.intmail.prod.int.phx2.redhat.com [10.5.11.12]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 4BB9680474 for ; Thu, 23 Mar 2017 20:46:20 +0000 (UTC) Received: from secure.mitica (ovpn-116-230.ams2.redhat.com [10.36.116.230]) by smtp.corp.redhat.com (Postfix) with ESMTP id 55D9A53; Thu, 23 Mar 2017 20:46:19 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mx1.redhat.com 4BB9680474 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 4BB9680474 From: Juan Quintela To: qemu-devel@nongnu.org Date: Thu, 23 Mar 2017 21:45:14 +0100 Message-Id: <20170323204544.12015-22-quintela@redhat.com> In-Reply-To: <20170323204544.12015-1-quintela@redhat.com> References: <20170323204544.12015-1-quintela@redhat.com> X-Scanned-By: MIMEDefang 2.79 on 10.5.11.12 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.28]); Thu, 23 Mar 2017 20:46:20 +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/51] 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: 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 Reviewed-by: Dr. David Alan Gilbert Reviewed-by: Peter Xu --- migration/ram.c | 21 +++++---------------- 1 file changed, 5 insertions(+), 16 deletions(-) diff --git a/migration/ram.c b/migration/ram.c index c398ff9..3292eb0 100644 --- a/migration/ram.c +++ b/migration/ram.c @@ -180,23 +180,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; @@ -229,7 +219,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; @@ -527,7 +517,7 @@ static int save_xbzrle_page(RAMState *rs, QEMUFile *f, = 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); @@ -2003,6 +1993,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 @@ -2033,8 +2024,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 Fri May 3 08:55:07 2024 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 1490302378984929.7366216735609; Thu, 23 Mar 2017 13:52:58 -0700 (PDT) Received: from localhost ([::1]:58573 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1cr9j7-00053w-M6 for importer@patchew.org; Thu, 23 Mar 2017 16:52:57 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:45550) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1cr9ck-0007zZ-Uc for qemu-devel@nongnu.org; Thu, 23 Mar 2017 16:46:24 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1cr9cj-0000Pv-Rq for qemu-devel@nongnu.org; Thu, 23 Mar 2017 16:46:22 -0400 Received: from mx1.redhat.com ([209.132.183.28]:38758) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1cr9cj-0000OT-Je for qemu-devel@nongnu.org; Thu, 23 Mar 2017 16:46:21 -0400 Received: from smtp.corp.redhat.com (int-mx02.intmail.prod.int.phx2.redhat.com [10.5.11.12]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 9507F4E341 for ; Thu, 23 Mar 2017 20:46:21 +0000 (UTC) Received: from secure.mitica (ovpn-116-230.ams2.redhat.com [10.36.116.230]) by smtp.corp.redhat.com (Postfix) with ESMTP id 9DD3153; Thu, 23 Mar 2017 20:46:20 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mx1.redhat.com 9507F4E341 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 9507F4E341 From: Juan Quintela To: qemu-devel@nongnu.org Date: Thu, 23 Mar 2017 21:45:15 +0100 Message-Id: <20170323204544.12015-23-quintela@redhat.com> In-Reply-To: <20170323204544.12015-1-quintela@redhat.com> References: <20170323204544.12015-1-quintela@redhat.com> X-Scanned-By: MIMEDefang 2.79 on 10.5.11.12 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.38]); Thu, 23 Mar 2017 20:46:21 +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/51] 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: 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: Peter Xu --- migration/ram.c | 32 ++++++++++++++++++-------------- 1 file changed, 18 insertions(+), 14 deletions(-) diff --git a/migration/ram.c b/migration/ram.c index 3292eb0..c6ba92c 100644 --- a/migration/ram.c +++ b/migration/ram.c @@ -182,6 +182,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 @@ -222,8 +224,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 { @@ -581,7 +587,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; @@ -590,7 +596,7 @@ static inline bool migration_bitmap_clear_dirty(ram_add= r_t addr) ret =3D test_and_clear_bit(nr, bitmap); =20 if (ret) { - migration_dirty_pages--; + rs->migration_dirty_pages--; } return ret; } @@ -600,8 +606,9 @@ static void migration_bitmap_sync_range(RAMState *rs, r= am_addr_t start, { unsigned long *bitmap; bitmap =3D atomic_rcu_read(&migration_bitmap_rcu)->bmap; - migration_dirty_pages +=3D cpu_physical_memory_sync_dirty_bitmap(bitma= p, - start, length, &rs->num_dirty_pages_period); + rs->migration_dirty_pages +=3D + cpu_physical_memory_sync_dirty_bitmap(bitmap, start, length, + &rs->num_dirty_pages_period); } =20 static void migration_bitmap_sync_init(RAMState *rs) @@ -1302,7 +1309,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, @@ -1452,11 +1459,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; @@ -1530,6 +1532,7 @@ static void ram_state_reset(RAMState *rs) =20 void migration_bitmap_extend(ram_addr_t old, ram_addr_t new) { + RAMState *rs =3D &ram_state; /* called in qemu main thread, so there is * no writing race against this migration_bitmap */ @@ -1555,7 +1558,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; + rs->migration_dirty_pages +=3D new - old; call_rcu(old_bitmap, migration_bitmap_free, rcu); } } @@ -1728,6 +1731,7 @@ static void postcopy_chunk_hostpages_pass(MigrationSt= ate *ms, bool unsent_pass, RAMBlock *block, PostcopyDiscardState *pds) { + RAMState *rs =3D &ram_state; unsigned long *bitmap; unsigned long *unsentmap; unsigned int host_ratio =3D block->page_size / TARGET_PAGE_SIZE; @@ -1825,7 +1829,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); + rs->migration_dirty_pages +=3D !test_and_set_bit(page, bit= map); } } =20 @@ -2051,7 +2055,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 Fri May 3 08:55:07 2024 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 1490302913946845.7861566387816; Thu, 23 Mar 2017 14:01:53 -0700 (PDT) Received: from localhost ([::1]:58619 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1cr9rk-0004r7-Kw for importer@patchew.org; Thu, 23 Mar 2017 17:01:52 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:45602) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1cr9cp-000839-GX for qemu-devel@nongnu.org; Thu, 23 Mar 2017 16:46:28 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1cr9cm-0000RO-DZ for qemu-devel@nongnu.org; Thu, 23 Mar 2017 16:46:27 -0400 Received: from mx1.redhat.com ([209.132.183.28]:36434) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1cr9cm-0000Ql-7g for qemu-devel@nongnu.org; Thu, 23 Mar 2017 16:46:24 -0400 Received: from smtp.corp.redhat.com (int-mx02.intmail.prod.int.phx2.redhat.com [10.5.11.12]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 3721061D33 for ; Thu, 23 Mar 2017 20:46:24 +0000 (UTC) Received: from secure.mitica (ovpn-116-230.ams2.redhat.com [10.36.116.230]) by smtp.corp.redhat.com (Postfix) with ESMTP id E7BC97FCC7; Thu, 23 Mar 2017 20:46:21 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mx1.redhat.com 3721061D33 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 3721061D33 From: Juan Quintela To: qemu-devel@nongnu.org Date: Thu, 23 Mar 2017 21:45:16 +0100 Message-Id: <20170323204544.12015-24-quintela@redhat.com> In-Reply-To: <20170323204544.12015-1-quintela@redhat.com> References: <20170323204544.12015-1-quintela@redhat.com> X-Scanned-By: MIMEDefang 2.79 on 10.5.11.12 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.39]); Thu, 23 Mar 2017 20:46:24 +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/51] 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: 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 Reviewed-by: Peter Xu --- migration/ram.c | 25 +++---------------------- 1 file changed, 3 insertions(+), 22 deletions(-) diff --git a/migration/ram.c b/migration/ram.c index c6ba92c..a890179 100644 --- a/migration/ram.c +++ b/migration/ram.c @@ -611,15 +611,6 @@ static void migration_bitmap_sync_range(RAMState *rs, = ram_addr_t start, &rs->num_dirty_pages_period); } =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; -} - /** * ram_pagesize_summary: calculate all the pagesizes of a VM * @@ -1984,21 +1975,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()) { @@ -2088,7 +2069,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 Fri May 3 08:55:07 2024 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 1490302979765321.3375187534323; Thu, 23 Mar 2017 14:02:59 -0700 (PDT) Received: from localhost ([::1]:58622 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1cr9so-0005qm-C1 for importer@patchew.org; Thu, 23 Mar 2017 17:02:58 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:45601) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1cr9cp-000838-Gp for qemu-devel@nongnu.org; Thu, 23 Mar 2017 16:46:28 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1cr9cn-0000SL-QR for qemu-devel@nongnu.org; Thu, 23 Mar 2017 16:46:27 -0400 Received: from mx1.redhat.com ([209.132.183.28]:47304) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1cr9cn-0000S0-HW for qemu-devel@nongnu.org; Thu, 23 Mar 2017 16:46:25 -0400 Received: from smtp.corp.redhat.com (int-mx02.intmail.prod.int.phx2.redhat.com [10.5.11.12]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 88DA1C009A13 for ; Thu, 23 Mar 2017 20:46:25 +0000 (UTC) Received: from secure.mitica (ovpn-116-230.ams2.redhat.com [10.36.116.230]) by smtp.corp.redhat.com (Postfix) with ESMTP id 89DE77FCC7; Thu, 23 Mar 2017 20:46:24 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mx1.redhat.com 88DA1C009A13 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 88DA1C009A13 From: Juan Quintela To: qemu-devel@nongnu.org Date: Thu, 23 Mar 2017 21:45:17 +0100 Message-Id: <20170323204544.12015-25-quintela@redhat.com> In-Reply-To: <20170323204544.12015-1-quintela@redhat.com> References: <20170323204544.12015-1-quintela@redhat.com> X-Scanned-By: MIMEDefang 2.79 on 10.5.11.12 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.32]); Thu, 23 Mar 2017 20:46:25 +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/51] 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: 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: Peter Xu --- migration/ram.c | 15 ++++++++------- 1 file changed, 8 insertions(+), 7 deletions(-) diff --git a/migration/ram.c b/migration/ram.c index a890179..ae2b89f 100644 --- a/migration/ram.c +++ b/migration/ram.c @@ -184,6 +184,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 @@ -229,8 +231,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 */ @@ -652,13 +652,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->num_dirty_pages_period); =20 @@ -1524,6 +1524,7 @@ static void ram_state_reset(RAMState *rs) void migration_bitmap_extend(ram_addr_t old, ram_addr_t new) { RAMState *rs =3D &ram_state; + /* called in qemu main thread, so there is * no writing race against this migration_bitmap */ @@ -1537,7 +1538,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(&rs->bitmap_mutex); bitmap_copy(bitmap->bmap, old_bitmap->bmap, old); bitmap_set(bitmap->bmap, old, new - old); =20 @@ -1548,7 +1549,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(&rs->bitmap_mutex); rs->migration_dirty_pages +=3D new - old; call_rcu(old_bitmap, migration_bitmap_free, rcu); } @@ -1980,7 +1981,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 Fri May 3 08:55:07 2024 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 1490303137812445.49283241819035; Thu, 23 Mar 2017 14:05:37 -0700 (PDT) Received: from localhost ([::1]:58636 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1cr9vM-00087g-Be for importer@patchew.org; Thu, 23 Mar 2017 17:05:36 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:45630) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1cr9cq-00084A-Jm for qemu-devel@nongnu.org; Thu, 23 Mar 2017 16:46:30 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1cr9cp-0000Se-4O for qemu-devel@nongnu.org; Thu, 23 Mar 2017 16:46:28 -0400 Received: from mx1.redhat.com ([209.132.183.28]:35006) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1cr9co-0000SS-Se for qemu-devel@nongnu.org; Thu, 23 Mar 2017 16:46:27 -0400 Received: from smtp.corp.redhat.com (int-mx02.intmail.prod.int.phx2.redhat.com [10.5.11.12]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id D414B7F3E1 for ; Thu, 23 Mar 2017 20:46:26 +0000 (UTC) Received: from secure.mitica (ovpn-116-230.ams2.redhat.com [10.36.116.230]) by smtp.corp.redhat.com (Postfix) with ESMTP id D377B53; Thu, 23 Mar 2017 20:46:25 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mx1.redhat.com D414B7F3E1 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 D414B7F3E1 From: Juan Quintela To: qemu-devel@nongnu.org Date: Thu, 23 Mar 2017 21:45:18 +0100 Message-Id: <20170323204544.12015-26-quintela@redhat.com> In-Reply-To: <20170323204544.12015-1-quintela@redhat.com> References: <20170323204544.12015-1-quintela@redhat.com> X-Scanned-By: MIMEDefang 2.79 on 10.5.11.12 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.25]); Thu, 23 Mar 2017 20:46:27 +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/51] 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: 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 Reviewed-by: Peter Xu --- migration/ram.c | 86 +++++++++++++++++++++++++++++++----------------------= ---- 1 file changed, 47 insertions(+), 39 deletions(-) diff --git a/migration/ram.c b/migration/ram.c index ae2b89f..090084b 100644 --- a/migration/ram.c +++ b/migration/ram.c @@ -138,6 +138,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 */ @@ -186,6 +199,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 @@ -242,18 +257,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; @@ -576,7 +579,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 { @@ -591,7 +594,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 @@ -605,7 +608,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, &rs->num_dirty_pages_period); @@ -1148,14 +1151,14 @@ static bool get_queued_page(RAMState *rs, Migration= State *ms, */ 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, @@ -1314,7 +1317,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); } @@ -1478,7 +1481,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); @@ -1487,11 +1490,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); @@ -1528,9 +1533,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 (rs->ram_bitmap) { + struct RAMBitmap *old_bitmap =3D rs->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 @@ -1548,7 +1553,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(&rs->ram_bitmap, bitmap); qemu_mutex_unlock(&rs->bitmap_mutex); rs->migration_dirty_pages +=3D new - old; call_rcu(old_bitmap, migration_bitmap_free, rcu); @@ -1563,13 +1568,13 @@ void migration_bitmap_extend(ram_addr_t old, ram_ad= dr_t new) void ram_debug_dump_bitmap(unsigned long *todump, bool expected) { int64_t ram_pages =3D last_ram_offset() >> TARGET_PAGE_BITS; - + RAMState *rs =3D &ram_state; int64_t cur; int64_t linelen =3D 128; char linebuf[129]; =20 if (!todump) { - todump =3D atomic_rcu_read(&migration_bitmap_rcu)->bmap; + todump =3D atomic_rcu_read(&rs->ram_bitmap)->bmap; } =20 for (cur =3D 0; cur < ram_pages; cur +=3D linelen) { @@ -1598,8 +1603,9 @@ void ram_debug_dump_bitmap(unsigned long *todump, boo= l expected) =20 void ram_postcopy_migrated_memory_release(MigrationState *ms) { + RAMState *rs =3D &ram_state; struct RAMBlock *block; - unsigned long *bitmap =3D atomic_rcu_read(&migration_bitmap_rcu)->bmap; + unsigned long *bitmap =3D atomic_rcu_read(&rs->ram_bitmap)->bmap; =20 QLIST_FOREACH_RCU(block, &ram_list.blocks, next) { unsigned long first =3D block->offset >> TARGET_PAGE_BITS; @@ -1634,11 +1640,12 @@ static int postcopy_send_discard_bm_ram(MigrationSt= ate *ms, unsigned long start, unsigned long length) { + RAMState *rs =3D &ram_state; unsigned long end =3D start + length; /* one after the end */ unsigned long current; unsigned long *unsentmap; =20 - unsentmap =3D atomic_rcu_read(&migration_bitmap_rcu)->unsentmap; + unsentmap =3D atomic_rcu_read(&rs->ram_bitmap)->unsentmap; for (current =3D start; current < end; ) { unsigned long one =3D find_next_bit(unsentmap, end, current); =20 @@ -1737,8 +1744,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(&rs->ram_bitmap)->bmap; + unsentmap =3D atomic_rcu_read(&rs->ram_bitmap)->unsentmap; =20 if (unsent_pass) { /* Find a sent page */ @@ -1896,15 +1903,16 @@ static int postcopy_chunk_hostpages(MigrationState = *ms) */ int ram_postcopy_send_discard_bitmap(MigrationState *ms) { + RAMState *rs =3D &ram_state; int ret; unsigned long *bitmap, *unsentmap; =20 rcu_read_lock(); =20 /* This should be our last sync, the src is now paused */ - migration_bitmap_sync(&ram_state); + migration_bitmap_sync(rs); =20 - unsentmap =3D atomic_rcu_read(&migration_bitmap_rcu)->unsentmap; + unsentmap =3D atomic_rcu_read(&rs->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 @@ -1925,7 +1933,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(&rs->ram_bitmap)->bmap; bitmap_or(unsentmap, unsentmap, bitmap, last_ram_offset() >> TARGET_PAGE_BITS); =20 @@ -2020,16 +2028,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 Fri May 3 08:55:07 2024 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 1490302513982757.4347017358642; Thu, 23 Mar 2017 13:55:13 -0700 (PDT) Received: from localhost ([::1]:58581 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1cr9lI-0007C1-KE for importer@patchew.org; Thu, 23 Mar 2017 16:55:12 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:45643) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1cr9cr-000853-Gj for qemu-devel@nongnu.org; Thu, 23 Mar 2017 16:46:30 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1cr9cq-0000TG-FZ for qemu-devel@nongnu.org; Thu, 23 Mar 2017 16:46:29 -0400 Received: from mx1.redhat.com ([209.132.183.28]:39972) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1cr9cq-0000Sm-6i for qemu-devel@nongnu.org; Thu, 23 Mar 2017 16:46:28 -0400 Received: from smtp.corp.redhat.com (int-mx02.intmail.prod.int.phx2.redhat.com [10.5.11.12]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 2518E3710D9 for ; Thu, 23 Mar 2017 20:46:28 +0000 (UTC) Received: from secure.mitica (ovpn-116-230.ams2.redhat.com [10.36.116.230]) by smtp.corp.redhat.com (Postfix) with ESMTP id 2EC9553; Thu, 23 Mar 2017 20:46:27 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mx1.redhat.com 2518E3710D9 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 2518E3710D9 From: Juan Quintela To: qemu-devel@nongnu.org Date: Thu, 23 Mar 2017 21:45:19 +0100 Message-Id: <20170323204544.12015-27-quintela@redhat.com> In-Reply-To: <20170323204544.12015-1-quintela@redhat.com> References: <20170323204544.12015-1-quintela@redhat.com> X-Scanned-By: MIMEDefang 2.79 on 10.5.11.12 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.29]); Thu, 23 Mar 2017 20:46: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 26/51] 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: 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: Peter Xu --- migration/ram.c | 35 +++++++++++++++++------------------ 1 file changed, 17 insertions(+), 18 deletions(-) diff --git a/migration/ram.c b/migration/ram.c index 090084b..872ea23 100644 --- a/migration/ram.c +++ b/migration/ram.c @@ -197,6 +197,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 */ @@ -246,6 +248,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 */ @@ -870,9 +877,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 @@ -893,7 +898,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); } @@ -989,7 +994,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= */ @@ -1065,7 +1070,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; } } @@ -1448,7 +1453,7 @@ void acct_update_position(QEMUFile *f, size_t size, b= ool zero) rs->zero_pages +=3D pages; } else { rs->norm_pages +=3D pages; - bytes_transferred +=3D size; + rs->bytes_transferred +=3D size; qemu_update_position(f, size); } } @@ -1458,11 +1463,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; @@ -2025,7 +2025,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); @@ -2137,7 +2136,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; @@ -2159,7 +2158,7 @@ static int ram_save_iterate(QEMUFile *f, void *opaque) } i++; } - flush_compressed_data(f); + flush_compressed_data(rs, f); rcu_read_unlock(); =20 /* @@ -2169,7 +2168,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) { @@ -2208,14 +2207,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 Fri May 3 08:55:08 2024 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 1490302653105543.9493932374924; Thu, 23 Mar 2017 13:57:33 -0700 (PDT) Received: from localhost ([::1]:58596 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1cr9nX-0000rg-No for importer@patchew.org; Thu, 23 Mar 2017 16:57:31 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:45683) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1cr9ct-000879-HA for qemu-devel@nongnu.org; Thu, 23 Mar 2017 16:46:33 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1cr9cr-0000Tg-N9 for qemu-devel@nongnu.org; Thu, 23 Mar 2017 16:46:31 -0400 Received: from mx1.redhat.com ([209.132.183.28]:59916) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1cr9cr-0000TQ-Eq for qemu-devel@nongnu.org; Thu, 23 Mar 2017 16:46:29 -0400 Received: from smtp.corp.redhat.com (int-mx02.intmail.prod.int.phx2.redhat.com [10.5.11.12]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 6FB6164A55 for ; Thu, 23 Mar 2017 20:46:29 +0000 (UTC) Received: from secure.mitica (ovpn-116-230.ams2.redhat.com [10.36.116.230]) by smtp.corp.redhat.com (Postfix) with ESMTP id 7684853; Thu, 23 Mar 2017 20:46:28 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mx1.redhat.com 6FB6164A55 Authentication-Results: ext-mx02.extmail.prod.ext.phx2.redhat.com; dmarc=none (p=none dis=none) header.from=redhat.com Authentication-Results: ext-mx02.extmail.prod.ext.phx2.redhat.com; spf=pass smtp.mailfrom=quintela@redhat.com DKIM-Filter: OpenDKIM Filter v2.11.0 mx1.redhat.com 6FB6164A55 From: Juan Quintela To: qemu-devel@nongnu.org Date: Thu, 23 Mar 2017 21:45:20 +0100 Message-Id: <20170323204544.12015-28-quintela@redhat.com> In-Reply-To: <20170323204544.12015-1-quintela@redhat.com> References: <20170323204544.12015-1-quintela@redhat.com> X-Scanned-By: MIMEDefang 2.79 on 10.5.11.12 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.26]); Thu, 23 Mar 2017 20:46: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 27/51] 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: 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: Juan Quintela Reviewed-by: Peter Xu --- migration/ram.c | 75 +++++++++++++++++++++--------------------------------= ---- 1 file changed, 27 insertions(+), 48 deletions(-) diff --git a/migration/ram.c b/migration/ram.c index 872ea23..3ae00e2 100644 --- a/migration/ram.c +++ b/migration/ram.c @@ -494,12 +494,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(RAMState *rs, QEMUFile *f, 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; @@ -555,7 +553,7 @@ static int save_xbzrle_page(RAMState *rs, QEMUFile *f, = 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; } @@ -727,20 +725,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_COMPRESS); qemu_put_byte(f, 0); - *bytes_transferred +=3D 1; + rs->bytes_transferred +=3D 1; pages =3D 1; } =20 @@ -771,11 +767,9 @@ static void ram_release_pages(MigrationState *ms, cons= t char *rbname, * @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; @@ -793,7 +787,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 @@ -813,7 +807,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 @@ -823,7 +817,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(rs, f, &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 @@ -835,7 +829,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, @@ -844,7 +838,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++; } @@ -912,8 +906,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 @@ -930,7 +923,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; } } @@ -956,12 +949,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; @@ -975,7 +966,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) { @@ -995,7 +986,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 | @@ -1003,7 +994,7 @@ static int ram_save_compressed_page(RAMState *rs, Migr= ationState *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 { @@ -1016,10 +1007,9 @@ static int ram_save_compressed_page(RAMState *rs, Mi= grationState *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); } @@ -1296,13 +1286,11 @@ err: * @f: QEMUFile where to send the data * @pss: data about the page we want to send * @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_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; @@ -1311,12 +1299,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) { @@ -1354,13 +1339,11 @@ static int ram_save_target_page(RAMState *rs, Migra= tionState *ms, QEMUFile *f, * @f: QEMUFile where to send the data * @pss: data about the page we want to send * @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; @@ -1368,7 +1351,7 @@ static int ram_save_host_page(RAMState *rs, Migration= State *ms, QEMUFile *f, =20 do { tmppages =3D ram_save_target_page(rs, ms, f, pss, last_stage, - bytes_transferred, dirty_ram_abs); + dirty_ram_abs); if (tmppages < 0) { return tmppages; } @@ -1393,14 +1376,12 @@ static int ram_save_host_page(RAMState *rs, Migrati= onState *ms, QEMUFile *f, * @rs: current 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(); @@ -1432,8 +1413,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, + pages =3D ram_save_host_page(rs, ms, f, &pss, last_stage, dirty_ram_abs); } } while (!pages && again); @@ -2136,7 +2116,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; @@ -2206,8 +2186,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 Fri May 3 08:55:08 2024 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 1490303067523102.32609868755571; Thu, 23 Mar 2017 14:04:27 -0700 (PDT) Received: from localhost ([::1]:58627 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1cr9uC-00079c-UG for importer@patchew.org; Thu, 23 Mar 2017 17:04:24 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:45685) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1cr9ct-00087K-OF for qemu-devel@nongnu.org; Thu, 23 Mar 2017 16:46:32 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1cr9cs-0000U4-UO for qemu-devel@nongnu.org; Thu, 23 Mar 2017 16:46:31 -0400 Received: from mx1.redhat.com ([209.132.183.28]:47396) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1cr9cs-0000Ts-OW for qemu-devel@nongnu.org; Thu, 23 Mar 2017 16:46:30 -0400 Received: from smtp.corp.redhat.com (int-mx02.intmail.prod.int.phx2.redhat.com [10.5.11.12]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id B8F8AC208065 for ; Thu, 23 Mar 2017 20:46:30 +0000 (UTC) Received: from secure.mitica (ovpn-116-230.ams2.redhat.com [10.36.116.230]) by smtp.corp.redhat.com (Postfix) with ESMTP id BF93253; Thu, 23 Mar 2017 20:46:29 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mx1.redhat.com B8F8AC208065 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 B8F8AC208065 From: Juan Quintela To: qemu-devel@nongnu.org Date: Thu, 23 Mar 2017 21:45:21 +0100 Message-Id: <20170323204544.12015-29-quintela@redhat.com> In-Reply-To: <20170323204544.12015-1-quintela@redhat.com> References: <20170323204544.12015-1-quintela@redhat.com> X-Scanned-By: MIMEDefang 2.79 on 10.5.11.12 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.32]); Thu, 23 Mar 2017 20:46:30 +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/51] 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: 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 Reviewed-by: Dr. David Alan Gilbert Reviewed-by: Peter Xu --- migration/ram.c | 19 +++++++------------ 1 file changed, 7 insertions(+), 12 deletions(-) diff --git a/migration/ram.c b/migration/ram.c index 3ae00e2..dd5a453 100644 --- a/migration/ram.c +++ b/migration/ram.c @@ -243,16 +243,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 */ @@ -1438,11 +1438,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; @@ -2210,7 +2205,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) { @@ -2219,7 +2214,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 Fri May 3 08:55:08 2024 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 149030328306838.529743838386025; Thu, 23 Mar 2017 14:08:03 -0700 (PDT) Received: from localhost ([::1]:58644 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1cr9xh-0001w5-NY for importer@patchew.org; Thu, 23 Mar 2017 17:08:01 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:45704) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1cr9cv-00089L-Im for qemu-devel@nongnu.org; Thu, 23 Mar 2017 16:46:36 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1cr9cu-0000UV-AA for qemu-devel@nongnu.org; Thu, 23 Mar 2017 16:46:33 -0400 Received: from mx1.redhat.com ([209.132.183.28]:40080) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1cr9cu-0000UC-1r for qemu-devel@nongnu.org; Thu, 23 Mar 2017 16:46:32 -0400 Received: from smtp.corp.redhat.com (int-mx02.intmail.prod.int.phx2.redhat.com [10.5.11.12]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 1089C15567 for ; Thu, 23 Mar 2017 20:46:32 +0000 (UTC) Received: from secure.mitica (ovpn-116-230.ams2.redhat.com [10.36.116.230]) by smtp.corp.redhat.com (Postfix) with ESMTP id 165CB53; Thu, 23 Mar 2017 20:46:30 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mx1.redhat.com 1089C15567 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 1089C15567 From: Juan Quintela To: qemu-devel@nongnu.org Date: Thu, 23 Mar 2017 21:45:22 +0100 Message-Id: <20170323204544.12015-30-quintela@redhat.com> In-Reply-To: <20170323204544.12015-1-quintela@redhat.com> References: <20170323204544.12015-1-quintela@redhat.com> X-Scanned-By: MIMEDefang 2.79 on 10.5.11.12 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.29]); Thu, 23 Mar 2017 20:46:32 +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/51] 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: 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 Reviewed-by: Peter Xu --- include/migration/migration.h | 2 -- migration/migration.c | 1 - migration/ram.c | 7 +++++-- 3 files changed, 5 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 e532430..b220941 100644 --- a/migration/migration.c +++ b/migration/migration.c @@ -1118,7 +1118,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 dd5a453..325a0f3 100644 --- a/migration/ram.c +++ b/migration/ram.c @@ -203,6 +203,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 @@ -1224,12 +1226,13 @@ int ram_save_queue_pages(MigrationState *ms, const = char *rbname, ram_addr_t start, ram_addr_t len) { RAMBlock *ramblock; + RAMState *rs =3D &ram_state; =20 ms->postcopy_requests++; rcu_read_lock(); if (!rbname) { /* Reuse last RAMBlock */ - ramblock =3D ms->last_req_rb; + ramblock =3D rs->last_req_rb; =20 if (!ramblock) { /* @@ -1247,7 +1250,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; + rs->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 Fri May 3 08:55:08 2024 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 1490302792456377.9984858683554; Thu, 23 Mar 2017 13:59:52 -0700 (PDT) Received: from localhost ([::1]:58605 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1cr9pn-00035x-5G for importer@patchew.org; Thu, 23 Mar 2017 16:59:51 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:45741) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1cr9cy-0008CE-Ou for qemu-devel@nongnu.org; Thu, 23 Mar 2017 16:46:39 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1cr9cv-0000Uo-LN for qemu-devel@nongnu.org; Thu, 23 Mar 2017 16:46:36 -0400 Received: from mx1.redhat.com ([209.132.183.28]:45422) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1cr9cv-0000Uc-C2 for qemu-devel@nongnu.org; Thu, 23 Mar 2017 16:46:33 -0400 Received: from smtp.corp.redhat.com (int-mx02.intmail.prod.int.phx2.redhat.com [10.5.11.12]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 5886CC0467F1 for ; Thu, 23 Mar 2017 20:46:33 +0000 (UTC) Received: from secure.mitica (ovpn-116-230.ams2.redhat.com [10.36.116.230]) by smtp.corp.redhat.com (Postfix) with ESMTP id 608007FCC7; Thu, 23 Mar 2017 20:46:32 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mx1.redhat.com 5886CC0467F1 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 5886CC0467F1 From: Juan Quintela To: qemu-devel@nongnu.org Date: Thu, 23 Mar 2017 21:45:23 +0100 Message-Id: <20170323204544.12015-31-quintela@redhat.com> In-Reply-To: <20170323204544.12015-1-quintela@redhat.com> References: <20170323204544.12015-1-quintela@redhat.com> X-Scanned-By: MIMEDefang 2.79 on 10.5.11.12 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.31]); Thu, 23 Mar 2017 20:46: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 30/51] ram: Move src_page_req* 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: 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 are the last postcopy fields still at MigrationState. Once there Move MigrationSrcPageRequest to ram.c and remove MigrationState parameters where appropiate. Signed-off-by: Juan Quintela Reviewed-by: Peter Xu --- include/migration/migration.h | 17 +----------- migration/migration.c | 5 +--- migration/ram.c | 62 ++++++++++++++++++++++++++-------------= ---- 3 files changed, 40 insertions(+), 44 deletions(-) diff --git a/include/migration/migration.h b/include/migration/migration.h index e032fb0..8a6caa3 100644 --- a/include/migration/migration.h +++ b/include/migration/migration.h @@ -128,18 +128,6 @@ struct MigrationIncomingState { MigrationIncomingState *migration_incoming_get_current(void); void migration_incoming_state_destroy(void); =20 -/* - * An outstanding page request, on the source, having been received - * and queued - */ -struct MigrationSrcPageRequest { - RAMBlock *rb; - hwaddr offset; - hwaddr len; - - QSIMPLEQ_ENTRY(MigrationSrcPageRequest) next_req; -}; - struct MigrationState { size_t bytes_xfer; @@ -186,9 +174,6 @@ struct MigrationState /* Flag set once the migration thread called bdrv_inactivate_all */ bool block_inactive; =20 - /* Queue of outstanding page requests from the destination */ - QemuMutex src_page_req_mutex; - QSIMPLEQ_HEAD(src_page_requests, MigrationSrcPageRequest) src_page_req= uests; /* The semaphore is used to notify COLO thread that failover is finish= ed */ QemuSemaphore colo_exit_sem; =20 @@ -371,7 +356,7 @@ void savevm_skip_configuration(void); int global_state_store(void); void global_state_store_running(void); =20 -void flush_page_queue(MigrationState *ms); +void flush_page_queue(void); int ram_save_queue_pages(MigrationState *ms, const char *rbname, ram_addr_t start, ram_addr_t len); uint64_t ram_pagesize_summary(void); diff --git a/migration/migration.c b/migration/migration.c index b220941..58c1587 100644 --- a/migration/migration.c +++ b/migration/migration.c @@ -109,7 +109,6 @@ MigrationState *migrate_get_current(void) }; =20 if (!once) { - qemu_mutex_init(¤t_migration.src_page_req_mutex); current_migration.parameters.tls_creds =3D g_strdup(""); current_migration.parameters.tls_hostname =3D g_strdup(""); once =3D true; @@ -949,7 +948,7 @@ static void migrate_fd_cleanup(void *opaque) qemu_bh_delete(s->cleanup_bh); s->cleanup_bh =3D NULL; =20 - flush_page_queue(s); + flush_page_queue(); =20 if (s->to_dst_file) { trace_migrate_fd_cleanup(); @@ -1123,8 +1122,6 @@ MigrationState *migrate_init(const MigrationParams *p= arams) =20 migrate_set_state(&s->state, MIGRATION_STATUS_NONE, MIGRATION_STATUS_S= ETUP); =20 - QSIMPLEQ_INIT(&s->src_page_requests); - s->total_time =3D qemu_clock_get_ms(QEMU_CLOCK_REALTIME); return s; } diff --git a/migration/ram.c b/migration/ram.c index 325a0f3..601370c 100644 --- a/migration/ram.c +++ b/migration/ram.c @@ -151,6 +151,18 @@ struct RAMBitmap { }; typedef struct RAMBitmap RAMBitmap; =20 +/* + * An outstanding page request, on the source, having been received + * and queued + */ +struct RAMSrcPageRequest { + RAMBlock *rb; + hwaddr offset; + hwaddr len; + + QSIMPLEQ_ENTRY(RAMSrcPageRequest) next_req; +}; + /* State of RAM for migration */ struct RAMState { /* Last block that we have visited searching for dirty pages */ @@ -205,6 +217,9 @@ struct RAMState { RAMBitmap *ram_bitmap; /* The RAMBlock used in the last src_page_request */ RAMBlock *last_req_rb; + /* Queue of outstanding page requests from the destination */ + QemuMutex src_page_req_mutex; + QSIMPLEQ_HEAD(src_page_requests, RAMSrcPageRequest) src_page_requests; }; typedef struct RAMState RAMState; =20 @@ -1084,20 +1099,20 @@ static bool find_dirty_block(RAMState *rs, QEMUFile= *f, PageSearchStatus *pss, * * Returns the block of the page (or NULL if none available) * - * @ms: current migration state + * @rs: current RAM state * @offset: used to return the offset within the RAMBlock * @ram_addr_abs: pointer into which to store the address of the dirty page * within the global ram_addr space */ -static RAMBlock *unqueue_page(MigrationState *ms, ram_addr_t *offset, +static RAMBlock *unqueue_page(RAMState *rs, ram_addr_t *offset, ram_addr_t *ram_addr_abs) { RAMBlock *block =3D NULL; =20 - qemu_mutex_lock(&ms->src_page_req_mutex); - if (!QSIMPLEQ_EMPTY(&ms->src_page_requests)) { - struct MigrationSrcPageRequest *entry =3D - QSIMPLEQ_FIRST(&ms->src_page_requests); + qemu_mutex_lock(&rs->src_page_req_mutex); + if (!QSIMPLEQ_EMPTY(&rs->src_page_requests)) { + struct RAMSrcPageRequest *entry =3D + QSIMPLEQ_FIRST(&rs->src_page_requests); block =3D entry->rb; *offset =3D entry->offset; *ram_addr_abs =3D (entry->offset + entry->rb->offset) & @@ -1108,11 +1123,11 @@ static RAMBlock *unqueue_page(MigrationState *ms, r= am_addr_t *offset, entry->offset +=3D TARGET_PAGE_SIZE; } else { memory_region_unref(block->mr); - QSIMPLEQ_REMOVE_HEAD(&ms->src_page_requests, next_req); + QSIMPLEQ_REMOVE_HEAD(&rs->src_page_requests, next_req); g_free(entry); } } - qemu_mutex_unlock(&ms->src_page_req_mutex); + qemu_mutex_unlock(&rs->src_page_req_mutex); =20 return block; } @@ -1125,13 +1140,11 @@ static RAMBlock *unqueue_page(MigrationState *ms, r= am_addr_t *offset, * Returns if a queued page is found * * @rs: current RAM state - * @ms: current migration state * @pss: data about the state of the current dirty page scan * @ram_addr_abs: pointer into which to store the address of the dirty page * within the global ram_addr space */ -static bool get_queued_page(RAMState *rs, MigrationState *ms, - PageSearchStatus *pss, +static bool get_queued_page(RAMState *rs, PageSearchStatus *pss, ram_addr_t *ram_addr_abs) { RAMBlock *block; @@ -1139,7 +1152,7 @@ static bool get_queued_page(RAMState *rs, MigrationSt= ate *ms, bool dirty; =20 do { - block =3D unqueue_page(ms, &offset, ram_addr_abs); + block =3D unqueue_page(rs, &offset, ram_addr_abs); /* * We're sending this page, and since it's postcopy nothing else * will dirty it, and we must make sure it doesn't get sent again @@ -1191,19 +1204,18 @@ static bool get_queued_page(RAMState *rs, Migration= State *ms, * * It should be empty at the end anyway, but in error cases there may * xbe some left. - * - * @ms: current migration state */ -void flush_page_queue(MigrationState *ms) +void flush_page_queue(void) { - struct MigrationSrcPageRequest *mspr, *next_mspr; + struct RAMSrcPageRequest *mspr, *next_mspr; + RAMState *rs =3D &ram_state; /* This queue generally should be empty - but in the case of a failed * migration might have some droppings in. */ rcu_read_lock(); - QSIMPLEQ_FOREACH_SAFE(mspr, &ms->src_page_requests, next_req, next_msp= r) { + QSIMPLEQ_FOREACH_SAFE(mspr, &rs->src_page_requests, next_req, next_msp= r) { memory_region_unref(mspr->rb->mr); - QSIMPLEQ_REMOVE_HEAD(&ms->src_page_requests, next_req); + QSIMPLEQ_REMOVE_HEAD(&rs->src_page_requests, next_req); g_free(mspr); } rcu_read_unlock(); @@ -1260,16 +1272,16 @@ int ram_save_queue_pages(MigrationState *ms, const = char *rbname, goto err; } =20 - struct MigrationSrcPageRequest *new_entry =3D - g_malloc0(sizeof(struct MigrationSrcPageRequest)); + struct RAMSrcPageRequest *new_entry =3D + g_malloc0(sizeof(struct RAMSrcPageRequest)); new_entry->rb =3D ramblock; new_entry->offset =3D start; new_entry->len =3D len; =20 memory_region_ref(ramblock->mr); - qemu_mutex_lock(&ms->src_page_req_mutex); - QSIMPLEQ_INSERT_TAIL(&ms->src_page_requests, new_entry, next_req); - qemu_mutex_unlock(&ms->src_page_req_mutex); + qemu_mutex_lock(&rs->src_page_req_mutex); + QSIMPLEQ_INSERT_TAIL(&rs->src_page_requests, new_entry, next_req); + qemu_mutex_unlock(&rs->src_page_req_mutex); rcu_read_unlock(); =20 return 0; @@ -1408,7 +1420,7 @@ static int ram_find_and_save_block(RAMState *rs, QEMU= File *f, bool last_stage) =20 do { again =3D true; - found =3D get_queued_page(rs, ms, &pss, &dirty_ram_abs); + found =3D get_queued_page(rs, &pss, &dirty_ram_abs); =20 if (!found) { /* priority queue empty, so just search for something dirty */ @@ -1968,6 +1980,8 @@ static int ram_state_init(RAMState *rs) =20 memset(rs, 0, sizeof(*rs)); qemu_mutex_init(&rs->bitmap_mutex); + qemu_mutex_init(&rs->src_page_req_mutex); + QSIMPLEQ_INIT(&rs->src_page_requests); =20 if (migrate_use_xbzrle()) { XBZRLE_cache_lock(); --=20 2.9.3 From nobody Fri May 3 08:55:08 2024 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 1490302940234321.6632379232718; Thu, 23 Mar 2017 14:02:20 -0700 (PDT) Received: from localhost ([::1]:58621 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1cr9s9-0005FZ-7h for importer@patchew.org; Thu, 23 Mar 2017 17:02:17 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:45739) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1cr9cy-0008CB-O0 for qemu-devel@nongnu.org; Thu, 23 Mar 2017 16:46:39 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1cr9cw-0000VD-Tc for qemu-devel@nongnu.org; Thu, 23 Mar 2017 16:46:36 -0400 Received: from mx1.redhat.com ([209.132.183.28]:47458) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1cr9cw-0000Uw-LU for qemu-devel@nongnu.org; Thu, 23 Mar 2017 16:46:34 -0400 Received: from smtp.corp.redhat.com (int-mx02.intmail.prod.int.phx2.redhat.com [10.5.11.12]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 9FDCFC208063 for ; Thu, 23 Mar 2017 20:46:34 +0000 (UTC) Received: from secure.mitica (ovpn-116-230.ams2.redhat.com [10.36.116.230]) by smtp.corp.redhat.com (Postfix) with ESMTP id A89F753; Thu, 23 Mar 2017 20:46:33 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mx1.redhat.com 9FDCFC208063 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 9FDCFC208063 From: Juan Quintela To: qemu-devel@nongnu.org Date: Thu, 23 Mar 2017 21:45:24 +0100 Message-Id: <20170323204544.12015-32-quintela@redhat.com> In-Reply-To: <20170323204544.12015-1-quintela@redhat.com> References: <20170323204544.12015-1-quintela@redhat.com> X-Scanned-By: MIMEDefang 2.79 on 10.5.11.12 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.32]); Thu, 23 Mar 2017 20:46: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 31/51] 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: 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 Reviewed-by: Peter Xu --- 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 8a6caa3..768fa72 100644 --- a/include/migration/migration.h +++ b/include/migration/migration.h @@ -159,7 +159,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 @@ -255,6 +254,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 58c1587..983c3d9 100644 --- a/migration/migration.c +++ b/migration/migration.c @@ -648,7 +648,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) { @@ -1112,7 +1112,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 601370c..98095ea 100644 --- a/migration/ram.c +++ b/migration/ram.c @@ -270,6 +270,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 */ @@ -726,7 +731,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 Fri May 3 08:55:08 2024 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 1490303232825193.43109950460462; Thu, 23 Mar 2017 14:07:12 -0700 (PDT) Received: from localhost ([::1]:58641 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1cr9wt-0000x6-Ee for importer@patchew.org; Thu, 23 Mar 2017 17:07:11 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:45744) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1cr9cz-0008CZ-0m for qemu-devel@nongnu.org; Thu, 23 Mar 2017 16:46:39 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1cr9cy-0000VS-4N for qemu-devel@nongnu.org; Thu, 23 Mar 2017 16:46:37 -0400 Received: from mx1.redhat.com ([209.132.183.28]:39814) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1cr9cx-0000VJ-Ua for qemu-devel@nongnu.org; Thu, 23 Mar 2017 16:46:36 -0400 Received: from smtp.corp.redhat.com (int-mx02.intmail.prod.int.phx2.redhat.com [10.5.11.12]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id EA69F83F47 for ; Thu, 23 Mar 2017 20:46:35 +0000 (UTC) Received: from secure.mitica (ovpn-116-230.ams2.redhat.com [10.36.116.230]) by smtp.corp.redhat.com (Postfix) with ESMTP id F1E4753; Thu, 23 Mar 2017 20:46:34 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mx1.redhat.com EA69F83F47 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 EA69F83F47 From: Juan Quintela To: qemu-devel@nongnu.org Date: Thu, 23 Mar 2017 21:45:25 +0100 Message-Id: <20170323204544.12015-33-quintela@redhat.com> In-Reply-To: <20170323204544.12015-1-quintela@redhat.com> References: <20170323204544.12015-1-quintela@redhat.com> X-Scanned-By: MIMEDefang 2.79 on 10.5.11.12 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.27]); Thu, 23 Mar 2017 20:46: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 32/51] 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: 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: Juan Quintela Reviewed-by: Peter Xu --- include/migration/migration.h | 1 - migration/migration.c | 6 +++--- migration/ram.c | 1 - 3 files changed, 3 insertions(+), 5 deletions(-) diff --git a/include/migration/migration.h b/include/migration/migration.h index 768fa72..0d5d5fc 100644 --- a/include/migration/migration.h +++ b/include/migration/migration.h @@ -155,7 +155,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 983c3d9..4af934b 100644 --- a/migration/migration.c +++ b/migration/migration.c @@ -1110,7 +1110,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; @@ -2000,8 +1999,9 @@ 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 << 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 98095ea..c66c308 100644 --- a/migration/ram.c +++ b/migration/ram.c @@ -727,7 +727,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 Fri May 3 08:55:08 2024 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 1490303216633392.83936551977774; Thu, 23 Mar 2017 14:06:56 -0700 (PDT) Received: from localhost ([::1]:58640 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1cr9wd-0000jO-AY for importer@patchew.org; Thu, 23 Mar 2017 17:06:55 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:45777) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1cr9d0-0008DA-L1 for qemu-devel@nongnu.org; Thu, 23 Mar 2017 16:46:40 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1cr9cz-0000WQ-G4 for qemu-devel@nongnu.org; Thu, 23 Mar 2017 16:46:38 -0400 Received: from mx1.redhat.com ([209.132.183.28]:36782) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1cr9cz-0000Vg-7u for qemu-devel@nongnu.org; Thu, 23 Mar 2017 16:46:37 -0400 Received: from smtp.corp.redhat.com (int-mx02.intmail.prod.int.phx2.redhat.com [10.5.11.12]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 407C2624CF for ; Thu, 23 Mar 2017 20:46:37 +0000 (UTC) Received: from secure.mitica (ovpn-116-230.ams2.redhat.com [10.36.116.230]) by smtp.corp.redhat.com (Postfix) with ESMTP id 48ABA53; Thu, 23 Mar 2017 20:46:36 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mx1.redhat.com 407C2624CF 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 407C2624CF From: Juan Quintela To: qemu-devel@nongnu.org Date: Thu, 23 Mar 2017 21:45:26 +0100 Message-Id: <20170323204544.12015-34-quintela@redhat.com> In-Reply-To: <20170323204544.12015-1-quintela@redhat.com> References: <20170323204544.12015-1-quintela@redhat.com> X-Scanned-By: MIMEDefang 2.79 on 10.5.11.12 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.39]); Thu, 23 Mar 2017 20:46: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 33/51] 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: 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: Juan Quintela Reviewed-by: Peter Xu --- 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 0d5d5fc..ffa7944 100644 --- a/include/migration/migration.h +++ b/include/migration/migration.h @@ -154,7 +154,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; @@ -254,6 +253,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 4af934b..d2d9b91 100644 --- a/migration/migration.c +++ b/migration/migration.c @@ -653,7 +653,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 @@ -1109,7 +1109,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; @@ -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_pages_rate && transferred_bytes > 10000) { - s->expected_downtime =3D s->dirty_pages_rate * + if (ram_dirty_pages_rate() && transferred_bytes > 10000) { + s->expected_downtime =3D ram_dirty_pages_rate() * (1ul << qemu_target_page_bits()) / bandwidth; } =20 diff --git a/migration/ram.c b/migration/ram.c index c66c308..6cb1435 100644 --- a/migration/ram.c +++ b/migration/ram.c @@ -211,6 +211,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 */ @@ -275,6 +277,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 */ @@ -665,7 +672,6 @@ uint64_t ram_pagesize_summary(void) static void migration_bitmap_sync(RAMState *rs) { RAMBlock *block; - MigrationState *s =3D migrate_get_current(); int64_t end_time; int64_t bytes_xfer_now; =20 @@ -704,7 +710,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)) { @@ -725,7 +731,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 Fri May 3 08:55:08 2024 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 149030309565180.56895300712438; Thu, 23 Mar 2017 14:04:55 -0700 (PDT) Received: from localhost ([::1]:58629 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1cr9ug-0007VJ-Fp for importer@patchew.org; Thu, 23 Mar 2017 17:04:54 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:45803) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1cr9d2-0008E8-0g for qemu-devel@nongnu.org; Thu, 23 Mar 2017 16:46:41 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1cr9d0-0000XZ-Qe for qemu-devel@nongnu.org; Thu, 23 Mar 2017 16:46:40 -0400 Received: from mx1.redhat.com ([209.132.183.28]:37936) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1cr9d0-0000Wa-IZ for qemu-devel@nongnu.org; Thu, 23 Mar 2017 16:46:38 -0400 Received: from smtp.corp.redhat.com (int-mx02.intmail.prod.int.phx2.redhat.com [10.5.11.12]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 8AEDA80474 for ; Thu, 23 Mar 2017 20:46:38 +0000 (UTC) Received: from secure.mitica (ovpn-116-230.ams2.redhat.com [10.36.116.230]) by smtp.corp.redhat.com (Postfix) with ESMTP id 91CF453; Thu, 23 Mar 2017 20:46:37 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mx1.redhat.com 8AEDA80474 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 8AEDA80474 From: Juan Quintela To: qemu-devel@nongnu.org Date: Thu, 23 Mar 2017 21:45:27 +0100 Message-Id: <20170323204544.12015-35-quintela@redhat.com> In-Reply-To: <20170323204544.12015-1-quintela@redhat.com> References: <20170323204544.12015-1-quintela@redhat.com> X-Scanned-By: MIMEDefang 2.79 on 10.5.11.12 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.28]); Thu, 23 Mar 2017 20:46:38 +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 34/51] 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: 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: Peter Xu --- include/migration/migration.h | 6 ++---- migration/migration.c | 5 ++--- migration/ram.c | 13 +++++++++---- 3 files changed, 13 insertions(+), 11 deletions(-) diff --git a/include/migration/migration.h b/include/migration/migration.h index ffa7944..e88bbaf 100644 --- a/include/migration/migration.h +++ b/include/migration/migration.h @@ -157,8 +157,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; @@ -254,6 +252,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); @@ -356,8 +355,7 @@ int global_state_store(void); void global_state_store_running(void); =20 void flush_page_queue(void); -int ram_save_queue_pages(MigrationState *ms, const char *rbname, - ram_addr_t start, ram_addr_t len); +int ram_save_queue_pages(const char *rbname, ram_addr_t start, ram_addr_t = len); uint64_t ram_pagesize_summary(void); =20 PostcopyState postcopy_state_get(void); diff --git a/migration/migration.c b/migration/migration.c index d2d9b91..ad4ea03 100644 --- a/migration/migration.c +++ b/migration/migration.c @@ -649,7 +649,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(); @@ -1112,7 +1112,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; @@ -1472,7 +1471,7 @@ static void migrate_handle_rp_req_pages(MigrationStat= e *ms, const char* rbname, return; } =20 - if (ram_save_queue_pages(ms, rbname, start, len)) { + if (ram_save_queue_pages(rbname, start, len)) { mark_source_rp_bad(ms); } } diff --git a/migration/ram.c b/migration/ram.c index 6cb1435..c0d6841 100644 --- a/migration/ram.c +++ b/migration/ram.c @@ -213,6 +213,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 */ @@ -282,6 +284,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 */ @@ -1237,19 +1244,17 @@ void flush_page_queue(void) * * Returns zero on success or negative on error * - * @ms: current migration state * @rbname: Name of the RAMBLock of the request. NULL means the * same that last one. * @start: starting address from the start of the RAMBlock * @len: length (in bytes) to send */ -int ram_save_queue_pages(MigrationState *ms, const char *rbname, - ram_addr_t start, ram_addr_t len) +int ram_save_queue_pages(const char *rbname, ram_addr_t start, ram_addr_t = len) { RAMBlock *ramblock; RAMState *rs =3D &ram_state; =20 - ms->postcopy_requests++; + rs->postcopy_requests++; rcu_read_lock(); if (!rbname) { /* Reuse last RAMBlock */ --=20 2.9.3 From nobody Fri May 3 08:55:08 2024 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 1490303240844596.6701844867924; Thu, 23 Mar 2017 14:07:20 -0700 (PDT) Received: from localhost ([::1]:58642 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1cr9x1-000181-Hh for importer@patchew.org; Thu, 23 Mar 2017 17:07:19 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:45824) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1cr9d3-0008FG-8K for qemu-devel@nongnu.org; Thu, 23 Mar 2017 16:46:42 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1cr9d2-0000YH-3P for qemu-devel@nongnu.org; Thu, 23 Mar 2017 16:46:41 -0400 Received: from mx1.redhat.com ([209.132.183.28]:39038) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1cr9d1-0000Y3-R5 for qemu-devel@nongnu.org; Thu, 23 Mar 2017 16:46:40 -0400 Received: from smtp.corp.redhat.com (int-mx02.intmail.prod.int.phx2.redhat.com [10.5.11.12]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id D18344E4C8 for ; Thu, 23 Mar 2017 20:46:39 +0000 (UTC) Received: from secure.mitica (ovpn-116-230.ams2.redhat.com [10.36.116.230]) by smtp.corp.redhat.com (Postfix) with ESMTP id DBCCA53; Thu, 23 Mar 2017 20:46:38 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mx1.redhat.com D18344E4C8 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 D18344E4C8 From: Juan Quintela To: qemu-devel@nongnu.org Date: Thu, 23 Mar 2017 21:45:28 +0100 Message-Id: <20170323204544.12015-36-quintela@redhat.com> In-Reply-To: <20170323204544.12015-1-quintela@redhat.com> References: <20170323204544.12015-1-quintela@redhat.com> X-Scanned-By: MIMEDefang 2.79 on 10.5.11.12 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.38]); Thu, 23 Mar 2017 20:46: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 35/51] ram: Add QEMUFile 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: 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 | 17 ++++++++++------- 1 file changed, 10 insertions(+), 7 deletions(-) diff --git a/migration/ram.c b/migration/ram.c index c0d6841..7667e73 100644 --- a/migration/ram.c +++ b/migration/ram.c @@ -165,6 +165,8 @@ struct RAMSrcPageRequest { =20 /* State of RAM for migration */ struct RAMState { + /* QEMUFile used for this migration */ + QEMUFile *f; /* Last block that we have visited searching for dirty pages */ RAMBlock *last_seen_block; /* Last block from where we have sent data */ @@ -524,14 +526,13 @@ static void xbzrle_cache_zero_page(RAMState *rs, ram_= addr_t current_addr) * -1 means that xbzrle would be longer than normal * * @rs: current RAM state - * @f: QEMUFile where to send the data * @current_data: contents of the page * @current_addr: addr of the page * @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 */ -static int save_xbzrle_page(RAMState *rs, QEMUFile *f, uint8_t **current_d= ata, +static int save_xbzrle_page(RAMState *rs, uint8_t **current_data, ram_addr_t current_addr, RAMBlock *block, ram_addr_t offset, bool last_stage) { @@ -582,10 +583,11 @@ static int save_xbzrle_page(RAMState *rs, QEMUFile *f= , uint8_t **current_data, } =20 /* Send XBZRLE based compressed page */ - bytes_xbzrle =3D save_page_header(f, block, offset | RAM_SAVE_FLAG_XBZ= RLE); - qemu_put_byte(f, ENCODING_FLAG_XBZRLE); - qemu_put_be16(f, encoded_len); - qemu_put_buffer(f, XBZRLE.encoded_buf, encoded_len); + bytes_xbzrle =3D save_page_header(rs->f, block, + offset | RAM_SAVE_FLAG_XBZRLE); + qemu_put_byte(rs->f, ENCODING_FLAG_XBZRLE); + qemu_put_be16(rs->f, encoded_len); + qemu_put_buffer(rs->f, XBZRLE.encoded_buf, encoded_len); bytes_xbzrle +=3D encoded_len + 1 + 2; rs->xbzrle_pages++; rs->xbzrle_bytes +=3D bytes_xbzrle; @@ -849,7 +851,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(rs, f, &p, current_addr, block, + pages =3D save_xbzrle_page(rs, &p, current_addr, block, offset, last_stage); if (!last_stage) { /* Can't send this cached data async, since the cache page @@ -2087,6 +2089,7 @@ static int ram_save_setup(QEMUFile *f, void *opaque) return -1; } } + rs->f =3D f; =20 rcu_read_lock(); =20 --=20 2.9.3 From nobody Fri May 3 08:55:08 2024 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 149030342575753.37325695242646; Thu, 23 Mar 2017 14:10:25 -0700 (PDT) Received: from localhost ([::1]:58656 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1crA00-0003zS-9z for importer@patchew.org; Thu, 23 Mar 2017 17:10:24 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:45858) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1cr9d5-0008Hi-JM for qemu-devel@nongnu.org; Thu, 23 Mar 2017 16:46:47 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1cr9d3-0000al-Dz for qemu-devel@nongnu.org; Thu, 23 Mar 2017 16:46:43 -0400 Received: from mx1.redhat.com ([209.132.183.28]:40226) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1cr9d3-0000ZI-5Q for qemu-devel@nongnu.org; Thu, 23 Mar 2017 16:46:41 -0400 Received: from smtp.corp.redhat.com (int-mx02.intmail.prod.int.phx2.redhat.com [10.5.11.12]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 29A2F437F7C for ; Thu, 23 Mar 2017 20:46:41 +0000 (UTC) Received: from secure.mitica (ovpn-116-230.ams2.redhat.com [10.36.116.230]) by smtp.corp.redhat.com (Postfix) with ESMTP id 30FD553; Thu, 23 Mar 2017 20:46:40 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mx1.redhat.com 29A2F437F7C 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 29A2F437F7C From: Juan Quintela To: qemu-devel@nongnu.org Date: Thu, 23 Mar 2017 21:45:29 +0100 Message-Id: <20170323204544.12015-37-quintela@redhat.com> In-Reply-To: <20170323204544.12015-1-quintela@redhat.com> References: <20170323204544.12015-1-quintela@redhat.com> X-Scanned-By: MIMEDefang 2.79 on 10.5.11.12 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.29]); Thu, 23 Mar 2017 20:46:41 +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 36/51] ram: Move QEMUFile 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: 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 receive the file from save_live operations and we don't use it until 3 or 4 levels of calls down. Signed-off-by: Juan Quintela Reviewed-by: Dr. David Alan Gilbert --- migration/ram.c | 84 +++++++++++++++++++++++++----------------------------= ---- 1 file changed, 37 insertions(+), 47 deletions(-) diff --git a/migration/ram.c b/migration/ram.c index 7667e73..6a39704 100644 --- a/migration/ram.c +++ b/migration/ram.c @@ -756,21 +756,20 @@ static void migration_bitmap_sync(RAMState *rs) * Returns the number of pages written. * * @rs: current RAM state - * @f: QEMUFile where to send the data * @block: block that contains the page we want to send * @offset: offset inside the block for the page * @p: pointer to the page */ -static int save_zero_page(RAMState *rs, QEMUFile *f, RAMBlock *block, - ram_addr_t offset, uint8_t *p) +static int save_zero_page(RAMState *rs, RAMBlock *block, ram_addr_t offset, + uint8_t *p) { int pages =3D -1; =20 if (is_zero_range(p, TARGET_PAGE_SIZE)) { rs->zero_pages++; rs->bytes_transferred +=3D - save_page_header(f, block, offset | RAM_SAVE_FLAG_COMPRESS); - qemu_put_byte(f, 0); + save_page_header(rs->f, block, offset | RAM_SAVE_FLAG_COMPRESS= ); + qemu_put_byte(rs->f, 0); rs->bytes_transferred +=3D 1; pages =3D 1; } @@ -798,12 +797,11 @@ static void ram_release_pages(MigrationState *ms, con= st char *rbname, * * @rs: current RAM state * @ms: current migration state - * @f: QEMUFile where to send the data * @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 */ -static int ram_save_page(RAMState *rs, MigrationState *ms, QEMUFile *f, +static int ram_save_page(RAMState *rs, MigrationState *ms, PageSearchStatus *pss, bool last_stage) { int pages =3D -1; @@ -819,7 +817,7 @@ static int ram_save_page(RAMState *rs, MigrationState *= ms, QEMUFile *f, =20 /* In doubt sent page as normal */ bytes_xmit =3D 0; - ret =3D ram_control_save_page(f, block->offset, + ret =3D ram_control_save_page(rs->f, block->offset, offset, TARGET_PAGE_SIZE, &bytes_xmit); if (bytes_xmit) { rs->bytes_transferred +=3D bytes_xmit; @@ -842,7 +840,7 @@ static int ram_save_page(RAMState *rs, MigrationState *= ms, QEMUFile *f, } } } else { - pages =3D save_zero_page(rs, f, block, offset, p); + pages =3D save_zero_page(rs, block, offset, p); if (pages > 0) { /* Must let xbzrle know, otherwise a previous (now 0'd) cached * page would be stale @@ -864,14 +862,14 @@ static int ram_save_page(RAMState *rs, MigrationState= *ms, QEMUFile *f, =20 /* XBZRLE overflow or normal page */ if (pages =3D=3D -1) { - rs->bytes_transferred +=3D save_page_header(f, block, + rs->bytes_transferred +=3D save_page_header(rs->f, block, offset | RAM_SAVE_FLAG_PAGE= ); if (send_async) { - qemu_put_buffer_async(f, p, TARGET_PAGE_SIZE, + qemu_put_buffer_async(rs->f, p, TARGET_PAGE_SIZE, migrate_release_ram() & migration_in_postcopy(ms)); } else { - qemu_put_buffer(f, p, TARGET_PAGE_SIZE); + qemu_put_buffer(rs->f, p, TARGET_PAGE_SIZE); } rs->bytes_transferred +=3D TARGET_PAGE_SIZE; pages =3D 1; @@ -906,7 +904,7 @@ static int do_compress_ram_page(QEMUFile *f, RAMBlock *= block, return bytes_sent; } =20 -static void flush_compressed_data(RAMState *rs, QEMUFile *f) +static void flush_compressed_data(RAMState *rs) { int idx, len, thread_count; =20 @@ -926,7 +924,7 @@ static void flush_compressed_data(RAMState *rs, QEMUFil= e *f) for (idx =3D 0; idx < thread_count; idx++) { qemu_mutex_lock(&comp_param[idx].mutex); if (!comp_param[idx].quit) { - len =3D qemu_put_qemu_file(f, comp_param[idx].file); + len =3D qemu_put_qemu_file(rs->f, comp_param[idx].file); rs->bytes_transferred +=3D len; } qemu_mutex_unlock(&comp_param[idx].mutex); @@ -940,8 +938,8 @@ static inline void set_compress_params(CompressParam *p= aram, RAMBlock *block, param->offset =3D offset; } =20 -static int compress_page_with_multi_thread(RAMState *rs, QEMUFile *f, - RAMBlock *block, ram_addr_t off= set) +static int compress_page_with_multi_thread(RAMState *rs, RAMBlock *block, + ram_addr_t offset) { int idx, thread_count, bytes_xmit =3D -1, pages =3D -1; =20 @@ -951,7 +949,7 @@ static int compress_page_with_multi_thread(RAMState *rs= , QEMUFile *f, for (idx =3D 0; idx < thread_count; idx++) { if (comp_param[idx].done) { comp_param[idx].done =3D false; - bytes_xmit =3D qemu_put_qemu_file(f, comp_param[idx].file); + bytes_xmit =3D qemu_put_qemu_file(rs->f, comp_param[idx].f= ile); qemu_mutex_lock(&comp_param[idx].mutex); set_compress_params(&comp_param[idx], block, offset); qemu_cond_signal(&comp_param[idx].cond); @@ -980,13 +978,11 @@ static int compress_page_with_multi_thread(RAMState *= rs, QEMUFile *f, * * @rs: current RAM state * @ms: current migration state - * @f: QEMUFile where to send the data * @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 */ static int ram_save_compressed_page(RAMState *rs, MigrationState *ms, - QEMUFile *f, PageSearchStatus *pss, bool last_stage) { int pages =3D -1; @@ -998,7 +994,7 @@ static int ram_save_compressed_page(RAMState *rs, Migra= tionState *ms, =20 p =3D block->host + offset; =20 - ret =3D ram_control_save_page(f, block->offset, + ret =3D ram_control_save_page(rs->f, block->offset, offset, TARGET_PAGE_SIZE, &bytes_xmit); if (bytes_xmit) { rs->bytes_transferred +=3D bytes_xmit; @@ -1020,20 +1016,20 @@ static int ram_save_compressed_page(RAMState *rs, M= igrationState *ms, * is used to avoid resending the block name. */ if (block !=3D rs->last_sent_block) { - flush_compressed_data(rs, f); - pages =3D save_zero_page(rs, f, block, offset, p); + flush_compressed_data(rs); + pages =3D save_zero_page(rs, 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 | + bytes_xmit =3D save_page_header(rs->f, block, offset | RAM_SAVE_FLAG_COMPRESS_PAGE); - blen =3D qemu_put_compression_data(f, p, TARGET_PAGE_SIZE, + blen =3D qemu_put_compression_data(rs->f, p, TARGET_PAGE_S= IZE, migrate_compress_level()); if (blen > 0) { rs->bytes_transferred +=3D bytes_xmit + blen; rs->norm_pages++; pages =3D 1; } else { - qemu_file_set_error(f, blen); + qemu_file_set_error(rs->f, blen); error_report("compressed data failed!"); } } @@ -1042,9 +1038,9 @@ static int ram_save_compressed_page(RAMState *rs, Mig= rationState *ms, } } else { offset |=3D RAM_SAVE_FLAG_CONTINUE; - pages =3D save_zero_page(rs, f, block, offset, p); + pages =3D save_zero_page(rs, block, offset, p); if (pages =3D=3D -1) { - pages =3D compress_page_with_multi_thread(rs, f, block, of= fset); + pages =3D compress_page_with_multi_thread(rs, block, offse= t); } else { ram_release_pages(ms, block->idstr, pss->offset, pages); } @@ -1061,13 +1057,12 @@ static int ram_save_compressed_page(RAMState *rs, M= igrationState *ms, * Returns if a page is found * * @rs: current RAM state - * @f: QEMUFile where to send the data * @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(RAMState *rs, QEMUFile *f, PageSearchStatus *= pss, +static bool find_dirty_block(RAMState *rs, PageSearchStatus *pss, bool *again, ram_addr_t *ram_addr_abs) { pss->offset =3D migration_bitmap_find_dirty(rs, pss->block, pss->offse= t, @@ -1095,7 +1090,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(rs, f); + flush_compressed_data(rs); compression_switch =3D false; } } @@ -1314,12 +1309,11 @@ err: * * @rs: current RAM state * @ms: current migration state - * @f: QEMUFile where to send the data * @pss: data about the page we want to send * @last_stage: if we are at the completion stage * @dirty_ram_abs: address of the start of the dirty page in ram_addr_t sp= ace */ -static int ram_save_target_page(RAMState *rs, MigrationState *ms, QEMUFile= *f, +static int ram_save_target_page(RAMState *rs, MigrationState *ms, PageSearchStatus *pss, bool last_stage, ram_addr_t dirty_ram_abs) @@ -1330,9 +1324,9 @@ static int ram_save_target_page(RAMState *rs, Migrati= onState *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); + res =3D ram_save_compressed_page(rs, ms, pss, last_stage); } else { - res =3D ram_save_page(rs, ms, f, pss, last_stage); + res =3D ram_save_page(rs, ms, pss, last_stage); } =20 if (res < 0) { @@ -1367,12 +1361,11 @@ static int ram_save_target_page(RAMState *rs, Migra= tionState *ms, QEMUFile *f, * * @rs: current RAM state * @ms: current migration state - * @f: QEMUFile where to send the data * @pss: data about the page we want to send * @last_stage: if we are at the completion stage * @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, +static int ram_save_host_page(RAMState *rs, MigrationState *ms, PageSearchStatus *pss, bool last_stage, ram_addr_t dirty_ram_abs) @@ -1381,8 +1374,7 @@ static int ram_save_host_page(RAMState *rs, Migration= State *ms, QEMUFile *f, size_t pagesize =3D qemu_ram_pagesize(pss->block); =20 do { - tmppages =3D ram_save_target_page(rs, ms, f, pss, last_stage, - dirty_ram_abs); + tmppages =3D ram_save_target_page(rs, ms, pss, last_stage, dirty_r= am_abs); if (tmppages < 0) { return tmppages; } @@ -1405,14 +1397,13 @@ static int ram_save_host_page(RAMState *rs, Migrati= onState *ms, QEMUFile *f, * Returns the number of pages written where zero means no dirty pages * * @rs: current RAM state - * @f: QEMUFile where to send the data * @last_stage: if we are at the completion stage * * 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) +static int ram_find_and_save_block(RAMState *rs, bool last_stage) { PageSearchStatus pss; MigrationState *ms =3D migrate_get_current(); @@ -1440,12 +1431,11 @@ static int ram_find_and_save_block(RAMState *rs, QE= MUFile *f, bool last_stage) =20 if (!found) { /* priority queue empty, so just search for something dirty */ - found =3D find_dirty_block(rs, f, &pss, &again, &dirty_ram_abs= ); + found =3D find_dirty_block(rs, &pss, &again, &dirty_ram_abs); } =20 if (found) { - pages =3D ram_save_host_page(rs, ms, f, &pss, last_stage, - dirty_ram_abs); + pages =3D ram_save_host_page(rs, ms, &pss, last_stage, dirty_r= am_abs); } } while (!pages && again); =20 @@ -2145,7 +2135,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); + pages =3D ram_find_and_save_block(rs, false); /* no more pages to sent */ if (pages =3D=3D 0) { done =3D 1; @@ -2167,7 +2157,7 @@ static int ram_save_iterate(QEMUFile *f, void *opaque) } i++; } - flush_compressed_data(rs, f); + flush_compressed_data(rs); rcu_read_unlock(); =20 /* @@ -2215,14 +2205,14 @@ static int ram_save_complete(QEMUFile *f, void *opa= que) while (true) { int pages; =20 - pages =3D ram_find_and_save_block(rs, f, !migration_in_colo_state(= )); + pages =3D ram_find_and_save_block(rs, !migration_in_colo_state()); /* no more blocks to sent */ if (pages =3D=3D 0) { break; } } =20 - flush_compressed_data(rs, f); + flush_compressed_data(rs); ram_control_after_iterate(f, RAM_CONTROL_FINISH); =20 rcu_read_unlock(); --=20 2.9.3 From nobody Fri May 3 08:55:08 2024 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 1490303381482697.0754692031272; Thu, 23 Mar 2017 14:09:41 -0700 (PDT) Received: from localhost ([::1]:58652 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1cr9zI-0003O7-06 for importer@patchew.org; Thu, 23 Mar 2017 17:09:40 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:45884) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1cr9d7-0008Jn-Rd for qemu-devel@nongnu.org; Thu, 23 Mar 2017 16:46:47 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1cr9d4-0000bD-PF for qemu-devel@nongnu.org; Thu, 23 Mar 2017 16:46:45 -0400 Received: from mx1.redhat.com ([209.132.183.28]:35346) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1cr9d4-0000b0-Jw for qemu-devel@nongnu.org; Thu, 23 Mar 2017 16:46:42 -0400 Received: from smtp.corp.redhat.com (int-mx02.intmail.prod.int.phx2.redhat.com [10.5.11.12]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 767227AEA4 for ; Thu, 23 Mar 2017 20:46:42 +0000 (UTC) Received: from secure.mitica (ovpn-116-230.ams2.redhat.com [10.36.116.230]) by smtp.corp.redhat.com (Postfix) with ESMTP id 80A1A53; Thu, 23 Mar 2017 20:46:41 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mx1.redhat.com 767227AEA4 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 767227AEA4 From: Juan Quintela To: qemu-devel@nongnu.org Date: Thu, 23 Mar 2017 21:45:30 +0100 Message-Id: <20170323204544.12015-38-quintela@redhat.com> In-Reply-To: <20170323204544.12015-1-quintela@redhat.com> References: <20170323204544.12015-1-quintela@redhat.com> X-Scanned-By: MIMEDefang 2.79 on 10.5.11.12 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.25]); Thu, 23 Mar 2017 20:46: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 37/51] ram: Move compression_switch 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: 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" Rename it to preffer_xbzrle that is a more descriptive name. Signed-off-by: Juan Quintela --- migration/ram.c | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/migration/ram.c b/migration/ram.c index 6a39704..591cf89 100644 --- a/migration/ram.c +++ b/migration/ram.c @@ -217,6 +217,9 @@ struct RAMState { uint64_t dirty_pages_rate; /* Count of requests incoming from destination */ uint64_t postcopy_requests; + /* Should we move to xbzrle after the 1st round + of compression */ + bool preffer_xbzrle; /* protects modification of the bitmap */ QemuMutex bitmap_mutex; /* Ram Bitmap protected by RCU */ @@ -335,7 +338,6 @@ static QemuCond comp_done_cond; /* The empty QEMUFileOps will be used by file in CompressParam */ static const QEMUFileOps empty_ops =3D { }; =20 -static bool compression_switch; static DecompressParam *decomp_param; static QemuThread *decompress_threads; static QemuMutex decomp_done_lock; @@ -419,7 +421,6 @@ void migrate_compress_threads_create(void) if (!migrate_use_compression()) { return; } - compression_switch =3D true; thread_count =3D migrate_compress_threads(); compress_threads =3D g_new0(QemuThread, thread_count); comp_param =3D g_new0(CompressParam, thread_count); @@ -1091,7 +1092,7 @@ static bool find_dirty_block(RAMState *rs, PageSearch= Status *pss, * point. In theory, xbzrle can do better than compression. */ flush_compressed_data(rs); - compression_switch =3D false; + rs->preffer_xbzrle =3D true; } } /* Didn't find anything this time, but try again on the new block = */ @@ -1323,7 +1324,7 @@ static int ram_save_target_page(RAMState *rs, Migrati= onState *ms, /* Check the pages is dirty and if it is send it */ if (migration_bitmap_clear_dirty(rs, dirty_ram_abs)) { unsigned long *unsentmap; - if (compression_switch && migrate_use_compression()) { + if (!rs->preffer_xbzrle && migrate_use_compression()) { res =3D ram_save_compressed_page(rs, ms, pss, last_stage); } else { res =3D ram_save_page(rs, ms, pss, last_stage); --=20 2.9.3 From nobody Fri May 3 08:55:08 2024 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 1490303568308823.5633586890997; Thu, 23 Mar 2017 14:12:48 -0700 (PDT) Received: from localhost ([::1]:58668 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1crA2J-00063h-0J for importer@patchew.org; Thu, 23 Mar 2017 17:12:47 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:45887) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1cr9d7-0008Jo-SE for qemu-devel@nongnu.org; Thu, 23 Mar 2017 16:46:47 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1cr9d6-0000bj-0r for qemu-devel@nongnu.org; Thu, 23 Mar 2017 16:46:45 -0400 Received: from mx1.redhat.com ([209.132.183.28]:60198) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1cr9d5-0000bM-PA for qemu-devel@nongnu.org; Thu, 23 Mar 2017 16:46:43 -0400 Received: from smtp.corp.redhat.com (int-mx02.intmail.prod.int.phx2.redhat.com [10.5.11.12]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id C36077E9CB for ; Thu, 23 Mar 2017 20:46:43 +0000 (UTC) Received: from secure.mitica (ovpn-116-230.ams2.redhat.com [10.36.116.230]) by smtp.corp.redhat.com (Postfix) with ESMTP id C885553; Thu, 23 Mar 2017 20:46:42 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mx1.redhat.com C36077E9CB Authentication-Results: ext-mx02.extmail.prod.ext.phx2.redhat.com; dmarc=none (p=none dis=none) header.from=redhat.com Authentication-Results: ext-mx02.extmail.prod.ext.phx2.redhat.com; spf=pass smtp.mailfrom=quintela@redhat.com DKIM-Filter: OpenDKIM Filter v2.11.0 mx1.redhat.com C36077E9CB From: Juan Quintela To: qemu-devel@nongnu.org Date: Thu, 23 Mar 2017 21:45:31 +0100 Message-Id: <20170323204544.12015-39-quintela@redhat.com> In-Reply-To: <20170323204544.12015-1-quintela@redhat.com> References: <20170323204544.12015-1-quintela@redhat.com> X-Scanned-By: MIMEDefang 2.79 on 10.5.11.12 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.26]); Thu, 23 Mar 2017 20:46: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 38/51] migration: Remove MigrationState from migration_in_postcopy 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: 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 call for the migrate_get_current() in more that half of the uses, so call that inside. Signed-off-by: Juan Quintela Reviewed-by: Dr. David Alan Gilbert Reviewed-by: Peter Xu --- include/migration/migration.h | 2 +- migration/migration.c | 6 ++++-- migration/ram.c | 22 ++++++++++------------ migration/savevm.c | 4 ++-- 4 files changed, 17 insertions(+), 17 deletions(-) diff --git a/include/migration/migration.h b/include/migration/migration.h index e88bbaf..90849a5 100644 --- a/include/migration/migration.h +++ b/include/migration/migration.h @@ -238,7 +238,7 @@ bool migration_is_idle(MigrationState *s); bool migration_has_finished(MigrationState *); bool migration_has_failed(MigrationState *); /* True if outgoing migration has entered postcopy phase */ -bool migration_in_postcopy(MigrationState *); +bool migration_in_postcopy(void); /* ...and after the device transmission */ bool migration_in_postcopy_after_devices(MigrationState *); MigrationState *migrate_get_current(void); diff --git a/migration/migration.c b/migration/migration.c index ad4ea03..3f99ab3 100644 --- a/migration/migration.c +++ b/migration/migration.c @@ -1054,14 +1054,16 @@ bool migration_has_failed(MigrationState *s) s->state =3D=3D MIGRATION_STATUS_FAILED); } =20 -bool migration_in_postcopy(MigrationState *s) +bool migration_in_postcopy(void) { + MigrationState *s =3D migrate_get_current(); + return (s->state =3D=3D MIGRATION_STATUS_POSTCOPY_ACTIVE); } =20 bool migration_in_postcopy_after_devices(MigrationState *s) { - return migration_in_postcopy(s) && s->postcopy_after_devices; + return migration_in_postcopy() && s->postcopy_after_devices; } =20 bool migration_is_idle(MigrationState *s) diff --git a/migration/ram.c b/migration/ram.c index 591cf89..cb5f06f 100644 --- a/migration/ram.c +++ b/migration/ram.c @@ -778,10 +778,9 @@ static int save_zero_page(RAMState *rs, RAMBlock *bloc= k, ram_addr_t offset, return pages; } =20 -static void ram_release_pages(MigrationState *ms, const char *rbname, - uint64_t offset, int pages) +static void ram_release_pages(const char *rbname, uint64_t offset, int pag= es) { - if (!migrate_release_ram() || !migration_in_postcopy(ms)) { + if (!migrate_release_ram() || !migration_in_postcopy()) { return; } =20 @@ -847,9 +846,9 @@ static int ram_save_page(RAMState *rs, MigrationState *= ms, * page would be stale */ xbzrle_cache_zero_page(rs, current_addr); - ram_release_pages(ms, block->idstr, pss->offset, pages); + ram_release_pages(block->idstr, pss->offset, pages); } else if (!rs->ram_bulk_stage && - !migration_in_postcopy(ms) && migrate_use_xbzrle()) { + !migration_in_postcopy() && migrate_use_xbzrle()) { pages =3D save_xbzrle_page(rs, &p, current_addr, block, offset, last_stage); if (!last_stage) { @@ -868,7 +867,7 @@ static int ram_save_page(RAMState *rs, MigrationState *= ms, if (send_async) { qemu_put_buffer_async(rs->f, p, TARGET_PAGE_SIZE, migrate_release_ram() & - migration_in_postcopy(ms)); + migration_in_postcopy()); } else { qemu_put_buffer(rs->f, p, TARGET_PAGE_SIZE); } @@ -898,8 +897,7 @@ static int do_compress_ram_page(QEMUFile *f, RAMBlock *= block, error_report("compressed data failed!"); } else { bytes_sent +=3D blen; - ram_release_pages(migrate_get_current(), block->idstr, - offset & TARGET_PAGE_MASK, 1); + ram_release_pages(block->idstr, offset & TARGET_PAGE_MASK, 1); } =20 return bytes_sent; @@ -1035,7 +1033,7 @@ static int ram_save_compressed_page(RAMState *rs, Mig= rationState *ms, } } if (pages > 0) { - ram_release_pages(ms, block->idstr, pss->offset, pages); + ram_release_pages(block->idstr, pss->offset, pages); } } else { offset |=3D RAM_SAVE_FLAG_CONTINUE; @@ -1043,7 +1041,7 @@ static int ram_save_compressed_page(RAMState *rs, Mig= rationState *ms, if (pages =3D=3D -1) { pages =3D compress_page_with_multi_thread(rs, block, offse= t); } else { - ram_release_pages(ms, block->idstr, pss->offset, pages); + ram_release_pages(block->idstr, pss->offset, pages); } } } @@ -2194,7 +2192,7 @@ static int ram_save_complete(QEMUFile *f, void *opaqu= e) =20 rcu_read_lock(); =20 - if (!migration_in_postcopy(migrate_get_current())) { + if (!migration_in_postcopy()) { migration_bitmap_sync(rs); } =20 @@ -2232,7 +2230,7 @@ static void ram_save_pending(QEMUFile *f, void *opaqu= e, uint64_t max_size, =20 remaining_size =3D rs->migration_dirty_pages * TARGET_PAGE_SIZE; =20 - if (!migration_in_postcopy(migrate_get_current()) && + if (!migration_in_postcopy() && remaining_size < max_size) { qemu_mutex_lock_iothread(); rcu_read_lock(); diff --git a/migration/savevm.c b/migration/savevm.c index 3b19a4a..853a81a 100644 --- a/migration/savevm.c +++ b/migration/savevm.c @@ -1062,7 +1062,7 @@ int qemu_savevm_state_iterate(QEMUFile *f, bool postc= opy) static bool should_send_vmdesc(void) { MachineState *machine =3D MACHINE(qdev_get_machine()); - bool in_postcopy =3D migration_in_postcopy(migrate_get_current()); + bool in_postcopy =3D migration_in_postcopy(); return !machine->suppress_vmdesc && !in_postcopy; } =20 @@ -1111,7 +1111,7 @@ void qemu_savevm_state_complete_precopy(QEMUFile *f, = bool iterable_only) int vmdesc_len; SaveStateEntry *se; int ret; - bool in_postcopy =3D migration_in_postcopy(migrate_get_current()); + bool in_postcopy =3D migration_in_postcopy(); =20 trace_savevm_state_complete_precopy(); =20 --=20 2.9.3 From nobody Fri May 3 08:55:08 2024 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 1490303357836378.3744521295024; Thu, 23 Mar 2017 14:09:17 -0700 (PDT) Received: from localhost ([::1]:58651 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1cr9yu-000341-Er for importer@patchew.org; Thu, 23 Mar 2017 17:09:16 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:45896) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1cr9d8-0008Jp-FV for qemu-devel@nongnu.org; Thu, 23 Mar 2017 16:46:47 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1cr9d7-0000c0-D4 for qemu-devel@nongnu.org; Thu, 23 Mar 2017 16:46:46 -0400 Received: from mx1.redhat.com ([209.132.183.28]:47636) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1cr9d7-0000bs-4O for qemu-devel@nongnu.org; Thu, 23 Mar 2017 16:46:45 -0400 Received: from smtp.corp.redhat.com (int-mx02.intmail.prod.int.phx2.redhat.com [10.5.11.12]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 21721C05AA48 for ; Thu, 23 Mar 2017 20:46:45 +0000 (UTC) Received: from secure.mitica (ovpn-116-230.ams2.redhat.com [10.36.116.230]) by smtp.corp.redhat.com (Postfix) with ESMTP id 22A4953; Thu, 23 Mar 2017 20:46:43 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mx1.redhat.com 21721C05AA48 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 21721C05AA48 From: Juan Quintela To: qemu-devel@nongnu.org Date: Thu, 23 Mar 2017 21:45:32 +0100 Message-Id: <20170323204544.12015-40-quintela@redhat.com> In-Reply-To: <20170323204544.12015-1-quintela@redhat.com> References: <20170323204544.12015-1-quintela@redhat.com> X-Scanned-By: MIMEDefang 2.79 on 10.5.11.12 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.32]); Thu, 23 Mar 2017 20:46:45 +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 39/51] ram: We don't need MigrationState parameter anymore 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: 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" Remove it from callers and callees. Signed-off-by: Juan Quintela Reviewed-by: Dr. David Alan Gilbert Reviewed-by: Peter Xu --- migration/ram.c | 27 ++++++++++----------------- 1 file changed, 10 insertions(+), 17 deletions(-) diff --git a/migration/ram.c b/migration/ram.c index cb5f06f..064b2c0 100644 --- a/migration/ram.c +++ b/migration/ram.c @@ -796,13 +796,11 @@ static void ram_release_pages(const char *rbname, uin= t64_t offset, int pages) * if xbzrle noticed the page was the same. * * @rs: current RAM state - * @ms: current migration state * @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 */ -static int ram_save_page(RAMState *rs, MigrationState *ms, - PageSearchStatus *pss, bool last_stage) +static int ram_save_page(RAMState *rs, PageSearchStatus *pss, bool last_st= age) { int pages =3D -1; uint64_t bytes_xmit; @@ -976,13 +974,12 @@ static int compress_page_with_multi_thread(RAMState *= rs, RAMBlock *block, * Returns the number of pages written. * * @rs: current RAM state - * @ms: current migration state * @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 */ -static int ram_save_compressed_page(RAMState *rs, MigrationState *ms, - PageSearchStatus *pss, bool last_stage) +static int ram_save_compressed_page(RAMState *rs, PageSearchStatus *pss, + bool last_stage) { int pages =3D -1; uint64_t bytes_xmit =3D 0; @@ -1312,10 +1309,8 @@ err: * @last_stage: if we are at the completion stage * @dirty_ram_abs: address of the start of the dirty page in ram_addr_t sp= ace */ -static int ram_save_target_page(RAMState *rs, MigrationState *ms, - PageSearchStatus *pss, - bool last_stage, - ram_addr_t dirty_ram_abs) +static int ram_save_target_page(RAMState *rs, PageSearchStatus *pss, + bool last_stage, ram_addr_t dirty_ram_abs) { int res =3D 0; =20 @@ -1323,9 +1318,9 @@ static int ram_save_target_page(RAMState *rs, Migrati= onState *ms, if (migration_bitmap_clear_dirty(rs, dirty_ram_abs)) { unsigned long *unsentmap; if (!rs->preffer_xbzrle && migrate_use_compression()) { - res =3D ram_save_compressed_page(rs, ms, pss, last_stage); + res =3D ram_save_compressed_page(rs, pss, last_stage); } else { - res =3D ram_save_page(rs, ms, pss, last_stage); + res =3D ram_save_page(rs, pss, last_stage); } =20 if (res < 0) { @@ -1364,8 +1359,7 @@ static int ram_save_target_page(RAMState *rs, Migrati= onState *ms, * @last_stage: if we are at the completion stage * @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, - PageSearchStatus *pss, +static int ram_save_host_page(RAMState *rs, PageSearchStatus *pss, bool last_stage, ram_addr_t dirty_ram_abs) { @@ -1373,7 +1367,7 @@ static int ram_save_host_page(RAMState *rs, Migration= State *ms, size_t pagesize =3D qemu_ram_pagesize(pss->block); =20 do { - tmppages =3D ram_save_target_page(rs, ms, pss, last_stage, dirty_r= am_abs); + tmppages =3D ram_save_target_page(rs, pss, last_stage, dirty_ram_a= bs); if (tmppages < 0) { return tmppages; } @@ -1405,7 +1399,6 @@ static int ram_save_host_page(RAMState *rs, Migration= State *ms, static int ram_find_and_save_block(RAMState *rs, bool last_stage) { PageSearchStatus pss; - MigrationState *ms =3D migrate_get_current(); int pages =3D 0; bool again, found; ram_addr_t dirty_ram_abs; /* Address of the start of the dirty page in @@ -1434,7 +1427,7 @@ static int ram_find_and_save_block(RAMState *rs, bool= last_stage) } =20 if (found) { - pages =3D ram_save_host_page(rs, ms, &pss, last_stage, dirty_r= am_abs); + pages =3D ram_save_host_page(rs, &pss, last_stage, dirty_ram_a= bs); } } while (!pages && again); =20 --=20 2.9.3 From nobody Fri May 3 08:55:08 2024 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 1490303431214695.6225472437469; Thu, 23 Mar 2017 14:10:31 -0700 (PDT) Received: from localhost ([::1]:58661 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1crA05-00047d-S0 for importer@patchew.org; Thu, 23 Mar 2017 17:10:29 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:45918) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1cr9d9-0008KO-Pg for qemu-devel@nongnu.org; Thu, 23 Mar 2017 16:46:48 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1cr9d8-0000d0-MU for qemu-devel@nongnu.org; Thu, 23 Mar 2017 16:46:47 -0400 Received: from mx1.redhat.com ([209.132.183.28]:40304) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1cr9d8-0000cK-EM for qemu-devel@nongnu.org; Thu, 23 Mar 2017 16:46:46 -0400 Received: from smtp.corp.redhat.com (int-mx02.intmail.prod.int.phx2.redhat.com [10.5.11.12]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 6953D437F52 for ; Thu, 23 Mar 2017 20:46:46 +0000 (UTC) Received: from secure.mitica (ovpn-116-230.ams2.redhat.com [10.36.116.230]) by smtp.corp.redhat.com (Postfix) with ESMTP id 7419D53; Thu, 23 Mar 2017 20:46:45 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mx1.redhat.com 6953D437F52 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 6953D437F52 From: Juan Quintela To: qemu-devel@nongnu.org Date: Thu, 23 Mar 2017 21:45:33 +0100 Message-Id: <20170323204544.12015-41-quintela@redhat.com> In-Reply-To: <20170323204544.12015-1-quintela@redhat.com> References: <20170323204544.12015-1-quintela@redhat.com> X-Scanned-By: MIMEDefang 2.79 on 10.5.11.12 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.29]); Thu, 23 Mar 2017 20:46: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 40/51] ram: Rename qemu_target_page_bits() to qemu_target_page_size() 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: 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 used as a size in all cases except one. Signed-off-by: Juan Quintela Reviewed-by: Dr. David Alan Gilbert --- exec.c | 4 ++-- include/sysemu/sysemu.h | 2 +- migration/migration.c | 4 ++-- migration/postcopy-ram.c | 8 ++++---- migration/savevm.c | 8 ++++---- 5 files changed, 13 insertions(+), 13 deletions(-) diff --git a/exec.c b/exec.c index e57a8a2..9a4c385 100644 --- a/exec.c +++ b/exec.c @@ -3349,9 +3349,9 @@ int cpu_memory_rw_debug(CPUState *cpu, target_ulong a= ddr, * Allows code that needs to deal with migration bitmaps etc to still be b= uilt * target independent. */ -size_t qemu_target_page_bits(void) +size_t qemu_target_page_size(void) { - return TARGET_PAGE_BITS; + return TARGET_PAGE_SIZE; } =20 #endif diff --git a/include/sysemu/sysemu.h b/include/sysemu/sysemu.h index 576c7ce..16175f7 100644 --- a/include/sysemu/sysemu.h +++ b/include/sysemu/sysemu.h @@ -67,7 +67,7 @@ int qemu_reset_requested_get(void); void qemu_system_killed(int signal, pid_t pid); void qemu_system_reset(bool report); void qemu_system_guest_panicked(GuestPanicInformation *info); -size_t qemu_target_page_bits(void); +size_t qemu_target_page_size(void); =20 void qemu_add_exit_notifier(Notifier *notify); void qemu_remove_exit_notifier(Notifier *notify); diff --git a/migration/migration.c b/migration/migration.c index 3f99ab3..92c3c6b 100644 --- a/migration/migration.c +++ b/migration/migration.c @@ -646,7 +646,7 @@ static void populate_ram_info(MigrationInfo *info, Migr= ationState *s) info->ram->skipped =3D 0; info->ram->normal =3D norm_mig_pages_transferred(); info->ram->normal_bytes =3D norm_mig_pages_transferred() * - (1ul << qemu_target_page_bits()); + qemu_target_page_size(); info->ram->mbps =3D s->mbps; info->ram->dirty_sync_count =3D ram_dirty_sync_count(); info->ram->postcopy_requests =3D ram_postcopy_requests(); @@ -2001,7 +2001,7 @@ static void *migration_thread(void *opaque) 10000 is a small enough number for our purposes */ if (ram_dirty_pages_rate() && transferred_bytes > 10000) { s->expected_downtime =3D ram_dirty_pages_rate() * - (1ul << qemu_target_page_bits()) / bandwidth; + qemu_target_page_size() / bandwidth; } =20 qemu_file_reset_rate_limit(s->to_dst_file); diff --git a/migration/postcopy-ram.c b/migration/postcopy-ram.c index dc80dbb..8756364 100644 --- a/migration/postcopy-ram.c +++ b/migration/postcopy-ram.c @@ -123,7 +123,7 @@ bool postcopy_ram_supported_by_host(void) struct uffdio_range range_struct; uint64_t feature_mask; =20 - if ((1ul << qemu_target_page_bits()) > pagesize) { + if (qemu_target_page_size() > pagesize) { error_report("Target page size bigger than host page size"); goto out; } @@ -745,10 +745,10 @@ PostcopyDiscardState *postcopy_discard_send_init(Migr= ationState *ms, void postcopy_discard_send_range(MigrationState *ms, PostcopyDiscardState = *pds, unsigned long start, unsigned long length) { - size_t tp_bits =3D qemu_target_page_bits(); + size_t tp_size =3D qemu_target_page_size(); /* Convert to byte offsets within the RAM block */ - pds->start_list[pds->cur_entry] =3D (start - pds->offset) << tp_bits; - pds->length_list[pds->cur_entry] =3D length << tp_bits; + pds->start_list[pds->cur_entry] =3D (start - pds->offset) * tp_size; + pds->length_list[pds->cur_entry] =3D length * tp_size; trace_postcopy_discard_send_range(pds->ramblock_name, start, length); pds->cur_entry++; pds->nsentwords++; diff --git a/migration/savevm.c b/migration/savevm.c index 853a81a..bbf055d 100644 --- a/migration/savevm.c +++ b/migration/savevm.c @@ -871,7 +871,7 @@ void qemu_savevm_send_postcopy_advise(QEMUFile *f) { uint64_t tmp[2]; tmp[0] =3D cpu_to_be64(ram_pagesize_summary()); - tmp[1] =3D cpu_to_be64(1ul << qemu_target_page_bits()); + tmp[1] =3D cpu_to_be64(qemu_target_page_size()); =20 trace_qemu_savevm_send_postcopy_advise(); qemu_savevm_command_send(f, MIG_CMD_POSTCOPY_ADVISE, 16, (uint8_t *)tm= p); @@ -1390,13 +1390,13 @@ static int loadvm_postcopy_handle_advise(MigrationI= ncomingState *mis) } =20 remote_tps =3D qemu_get_be64(mis->from_src_file); - if (remote_tps !=3D (1ul << qemu_target_page_bits())) { + if (remote_tps !=3D qemu_target_page_size()) { /* * Again, some differences could be dealt with, but for now keep it * simple. */ - error_report("Postcopy needs matching target page sizes (s=3D%d d= =3D%d)", - (int)remote_tps, 1 << qemu_target_page_bits()); + error_report("Postcopy needs matching target page sizes (s=3D%d d= =3D%zd)", + (int)remote_tps, qemu_target_page_size()); return -1; } =20 --=20 2.9.3 From nobody Fri May 3 08:55:08 2024 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 1490303707689879.8410878277557; Thu, 23 Mar 2017 14:15:07 -0700 (PDT) Received: from localhost ([::1]:58677 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1crA4X-0008PJ-U3 for importer@patchew.org; Thu, 23 Mar 2017 17:15:05 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:45951) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1cr9dB-0008M3-Dc for qemu-devel@nongnu.org; Thu, 23 Mar 2017 16:46:50 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1cr9dA-0000em-C0 for qemu-devel@nongnu.org; Thu, 23 Mar 2017 16:46:49 -0400 Received: from mx1.redhat.com ([209.132.183.28]:39964) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1cr9dA-0000eB-5P for qemu-devel@nongnu.org; Thu, 23 Mar 2017 16:46:48 -0400 Received: from smtp.corp.redhat.com (int-mx02.intmail.prod.int.phx2.redhat.com [10.5.11.12]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 2332481F03; Thu, 23 Mar 2017 20:46:48 +0000 (UTC) Received: from secure.mitica (ovpn-116-230.ams2.redhat.com [10.36.116.230]) by smtp.corp.redhat.com (Postfix) with ESMTP id BCF1053; Thu, 23 Mar 2017 20:46:46 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mx1.redhat.com 2332481F03 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 2332481F03 From: Juan Quintela To: qemu-devel@nongnu.org Date: Thu, 23 Mar 2017 21:45:34 +0100 Message-Id: <20170323204544.12015-42-quintela@redhat.com> In-Reply-To: <20170323204544.12015-1-quintela@redhat.com> References: <20170323204544.12015-1-quintela@redhat.com> X-Scanned-By: MIMEDefang 2.79 on 10.5.11.12 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.27]); Thu, 23 Mar 2017 20:46: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 41/51] Add page-size to output in 'info migrate' 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: Chao Fan , dgilbert@redhat.com, Li Zhijian 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" From: Chao Fan The number of dirty pages outputed in 'pages' in the command 'info migrate', so add page-size to calculate the number of dirty pages in bytes. Signed-off-by: Chao Fan Signed-off-by: Li Zhijian Signed-off-by: Juan Quintela Reviewed-by: Eric Blake --- hmp.c | 3 +++ migration/migration.c | 1 + qapi-schema.json | 5 ++++- 3 files changed, 8 insertions(+), 1 deletion(-) diff --git a/hmp.c b/hmp.c index edb8970..be75e71 100644 --- a/hmp.c +++ b/hmp.c @@ -215,6 +215,9 @@ void hmp_info_migrate(Monitor *mon, const QDict *qdict) info->ram->normal_bytes >> 10); monitor_printf(mon, "dirty sync count: %" PRIu64 "\n", info->ram->dirty_sync_count); + monitor_printf(mon, "page size: %" PRIu64 " kbytes\n", + info->ram->page_size >> 10); + if (info->ram->dirty_pages_rate) { monitor_printf(mon, "dirty pages rate: %" PRIu64 " pages\n", info->ram->dirty_pages_rate); diff --git a/migration/migration.c b/migration/migration.c index 92c3c6b..fc19ba7 100644 --- a/migration/migration.c +++ b/migration/migration.c @@ -650,6 +650,7 @@ static void populate_ram_info(MigrationInfo *info, Migr= ationState *s) info->ram->mbps =3D s->mbps; info->ram->dirty_sync_count =3D ram_dirty_sync_count(); info->ram->postcopy_requests =3D ram_postcopy_requests(); + info->ram->page_size =3D qemu_target_page_size(); =20 if (s->state !=3D MIGRATION_STATUS_COMPLETED) { info->ram->remaining =3D ram_bytes_remaining(); diff --git a/qapi-schema.json b/qapi-schema.json index 68a4327..c7ec62c 100644 --- a/qapi-schema.json +++ b/qapi-schema.json @@ -598,6 +598,9 @@ # @postcopy-requests: The number of page requests received from the destin= ation # (since 2.7) # +# @page-size: The number of bytes per page for the various page-based +# statistics (since 2.10) +# # Since: 0.14.0 ## { 'struct': 'MigrationStats', @@ -605,7 +608,7 @@ 'duplicate': 'int', 'skipped': 'int', 'normal': 'int', 'normal-bytes': 'int', 'dirty-pages-rate' : 'int', 'mbps' : 'number', 'dirty-sync-count' : 'int', - 'postcopy-requests' : 'int' } } + 'postcopy-requests' : 'int', 'page-size' : 'int' } } =20 ## # @XBZRLECacheStats: --=20 2.9.3 From nobody Fri May 3 08:55:08 2024 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 1490303519785166.0449862953135; Thu, 23 Mar 2017 14:11:59 -0700 (PDT) Received: from localhost ([::1]:58666 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1crA1W-0005MB-EP for importer@patchew.org; Thu, 23 Mar 2017 17:11:58 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:45971) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1cr9dC-0008Nj-QF for qemu-devel@nongnu.org; Thu, 23 Mar 2017 16:46:51 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1cr9dB-0000g7-P4 for qemu-devel@nongnu.org; Thu, 23 Mar 2017 16:46:50 -0400 Received: from mx1.redhat.com ([209.132.183.28]:39988) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1cr9dB-0000fp-J6 for qemu-devel@nongnu.org; Thu, 23 Mar 2017 16:46:49 -0400 Received: from smtp.corp.redhat.com (int-mx02.intmail.prod.int.phx2.redhat.com [10.5.11.12]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 9588883F47 for ; Thu, 23 Mar 2017 20:46:49 +0000 (UTC) Received: from secure.mitica (ovpn-116-230.ams2.redhat.com [10.36.116.230]) by smtp.corp.redhat.com (Postfix) with ESMTP id 7388753; Thu, 23 Mar 2017 20:46:48 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mx1.redhat.com 9588883F47 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 9588883F47 From: Juan Quintela To: qemu-devel@nongnu.org Date: Thu, 23 Mar 2017 21:45:35 +0100 Message-Id: <20170323204544.12015-43-quintela@redhat.com> In-Reply-To: <20170323204544.12015-1-quintela@redhat.com> References: <20170323204544.12015-1-quintela@redhat.com> X-Scanned-By: MIMEDefang 2.79 on 10.5.11.12 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.27]); Thu, 23 Mar 2017 20:46: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 42/51] ram: Pass RAMBlock to bitmap_sync 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: 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 change the meaning of start to be the offset from the beggining of the block. Signed-off-by: Juan Quintela --- include/exec/ram_addr.h | 2 ++ migration/ram.c | 8 ++++---- 2 files changed, 6 insertions(+), 4 deletions(-) diff --git a/include/exec/ram_addr.h b/include/exec/ram_addr.h index b05dc84..d50c970 100644 --- a/include/exec/ram_addr.h +++ b/include/exec/ram_addr.h @@ -354,11 +354,13 @@ static inline void cpu_physical_memory_clear_dirty_ra= nge(ram_addr_t start, =20 static inline uint64_t cpu_physical_memory_sync_dirty_bitmap(unsigned long *dest, + RAMBlock *rb, ram_addr_t start, ram_addr_t length, int64_t *real_dirty_pages) { ram_addr_t addr; + start =3D rb->offset + start; unsigned long page =3D BIT_WORD(start >> TARGET_PAGE_BITS); uint64_t num_dirty =3D 0; =20 diff --git a/migration/ram.c b/migration/ram.c index 064b2c0..9772fd8 100644 --- a/migration/ram.c +++ b/migration/ram.c @@ -648,13 +648,13 @@ static inline bool migration_bitmap_clear_dirty(RAMSt= ate *rs, ram_addr_t addr) return ret; } =20 -static void migration_bitmap_sync_range(RAMState *rs, ram_addr_t start, - ram_addr_t length) +static void migration_bitmap_sync_range(RAMState *rs, RAMBlock *rb, + ram_addr_t start, ram_addr_t lengt= h) { unsigned long *bitmap; bitmap =3D atomic_rcu_read(&rs->ram_bitmap)->bmap; rs->migration_dirty_pages +=3D - cpu_physical_memory_sync_dirty_bitmap(bitmap, start, length, + cpu_physical_memory_sync_dirty_bitmap(bitmap, rb, start, length, &rs->num_dirty_pages_period); } =20 @@ -701,7 +701,7 @@ static void migration_bitmap_sync(RAMState *rs) 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); + migration_bitmap_sync_range(rs, block, 0, block->used_length); } rcu_read_unlock(); qemu_mutex_unlock(&rs->bitmap_mutex); --=20 2.9.3 From nobody Fri May 3 08:55:08 2024 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 1490303574185910.2160884867313; Thu, 23 Mar 2017 14:12:54 -0700 (PDT) Received: from localhost ([::1]:58669 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1crA2O-00068z-U6 for importer@patchew.org; Thu, 23 Mar 2017 17:12:53 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:46005) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1cr9dG-0008UB-7l for qemu-devel@nongnu.org; Thu, 23 Mar 2017 16:46:55 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1cr9dD-0000gW-53 for qemu-devel@nongnu.org; Thu, 23 Mar 2017 16:46:54 -0400 Received: from mx1.redhat.com ([209.132.183.28]:40020) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1cr9dC-0000gI-T6 for qemu-devel@nongnu.org; Thu, 23 Mar 2017 16:46:51 -0400 Received: from smtp.corp.redhat.com (int-mx02.intmail.prod.int.phx2.redhat.com [10.5.11.12]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id E0A2D80F9D for ; Thu, 23 Mar 2017 20:46:50 +0000 (UTC) Received: from secure.mitica (ovpn-116-230.ams2.redhat.com [10.36.116.230]) by smtp.corp.redhat.com (Postfix) with ESMTP id E945453; Thu, 23 Mar 2017 20:46:49 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mx1.redhat.com E0A2D80F9D 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 E0A2D80F9D From: Juan Quintela To: qemu-devel@nongnu.org Date: Thu, 23 Mar 2017 21:45:36 +0100 Message-Id: <20170323204544.12015-44-quintela@redhat.com> In-Reply-To: <20170323204544.12015-1-quintela@redhat.com> References: <20170323204544.12015-1-quintela@redhat.com> X-Scanned-By: MIMEDefang 2.79 on 10.5.11.12 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.27]); Thu, 23 Mar 2017 20:46: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 43/51] ram: ram_discard_range() don't use the mis 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: 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: Peter Xu --- include/migration/migration.h | 3 +-- migration/postcopy-ram.c | 6 ++---- migration/ram.c | 9 +++------ migration/savevm.c | 3 +-- 4 files changed, 7 insertions(+), 14 deletions(-) diff --git a/include/migration/migration.h b/include/migration/migration.h index 90849a5..39a8e7e 100644 --- a/include/migration/migration.h +++ b/include/migration/migration.h @@ -270,8 +270,7 @@ void ram_debug_dump_bitmap(unsigned long *todump, bool = expected); /* For outgoing discard bitmap */ int ram_postcopy_send_discard_bitmap(MigrationState *ms); /* For incoming postcopy discard */ -int ram_discard_range(MigrationIncomingState *mis, const char *block_name, - uint64_t start, size_t length); +int ram_discard_range(const char *block_name, uint64_t start, size_t lengt= h); int ram_postcopy_incoming_init(MigrationIncomingState *mis); void ram_postcopy_migrated_memory_release(MigrationState *ms); =20 diff --git a/migration/postcopy-ram.c b/migration/postcopy-ram.c index 8756364..85fd8d7 100644 --- a/migration/postcopy-ram.c +++ b/migration/postcopy-ram.c @@ -213,8 +213,6 @@ out: static int init_range(const char *block_name, void *host_addr, ram_addr_t offset, ram_addr_t length, void *opaque) { - MigrationIncomingState *mis =3D opaque; - trace_postcopy_init_range(block_name, host_addr, offset, length); =20 /* @@ -223,7 +221,7 @@ static int init_range(const char *block_name, void *hos= t_addr, * - we're going to get the copy from the source anyway. * (Precopy will just overwrite this data, so doesn't need the discard) */ - if (ram_discard_range(mis, block_name, 0, length)) { + if (ram_discard_range(block_name, 0, length)) { return -1; } =20 @@ -271,7 +269,7 @@ static int cleanup_range(const char *block_name, void *= host_addr, */ int postcopy_ram_incoming_init(MigrationIncomingState *mis, size_t ram_pag= es) { - if (qemu_ram_foreach_block(init_range, mis)) { + if (qemu_ram_foreach_block(init_range, NULL)) { return -1; } =20 diff --git a/migration/ram.c b/migration/ram.c index 9772fd8..83c749c 100644 --- a/migration/ram.c +++ b/migration/ram.c @@ -784,7 +784,7 @@ static void ram_release_pages(const char *rbname, uint6= 4_t offset, int pages) return; } =20 - ram_discard_range(NULL, rbname, offset, pages << TARGET_PAGE_BITS); + ram_discard_range(rbname, offset, pages << TARGET_PAGE_BITS); } =20 /** @@ -1602,7 +1602,7 @@ void ram_postcopy_migrated_memory_release(MigrationSt= ate *ms) =20 while (run_start < range) { unsigned long run_end =3D find_next_bit(bitmap, range, run_sta= rt + 1); - ram_discard_range(NULL, block->idstr, run_start << TARGET_PAGE= _BITS, + ram_discard_range(block->idstr, run_start << TARGET_PAGE_BITS, (run_end - run_start) << TARGET_PAGE_BITS); run_start =3D find_next_zero_bit(bitmap, range, run_end + 1); } @@ -1942,15 +1942,12 @@ int ram_postcopy_send_discard_bitmap(MigrationState= *ms) * * Returns zero on success * - * @mis: current migration incoming state * @rbname: name of the RAMBLock of the request. NULL means the * same that last one. * @start: RAMBlock starting page * @length: RAMBlock size */ -int ram_discard_range(MigrationIncomingState *mis, - const char *rbname, - uint64_t start, size_t length) +int ram_discard_range(const char *rbname, uint64_t start, size_t length) { int ret =3D -1; =20 diff --git a/migration/savevm.c b/migration/savevm.c index bbf055d..7cf387f 100644 --- a/migration/savevm.c +++ b/migration/savevm.c @@ -1479,8 +1479,7 @@ static int loadvm_postcopy_ram_handle_discard(Migrati= onIncomingState *mis, block_length =3D qemu_get_be64(mis->from_src_file); =20 len -=3D 16; - int ret =3D ram_discard_range(mis, ramid, start_addr, - block_length); + int ret =3D ram_discard_range(ramid, start_addr, block_length); if (ret) { return ret; } --=20 2.9.3 From nobody Fri May 3 08:55:08 2024 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 1490303661360368.5998518288444; Thu, 23 Mar 2017 14:14:21 -0700 (PDT) Received: from localhost ([::1]:58675 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1crA3n-0007dT-Tx for importer@patchew.org; Thu, 23 Mar 2017 17:14:20 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:46004) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1cr9dG-0008U8-7M for qemu-devel@nongnu.org; Thu, 23 Mar 2017 16:46:57 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1cr9dE-0000hz-Jw for qemu-devel@nongnu.org; Thu, 23 Mar 2017 16:46:54 -0400 Received: from mx1.redhat.com ([209.132.183.28]:37044) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1cr9dE-0000hW-Ay for qemu-devel@nongnu.org; Thu, 23 Mar 2017 16:46:52 -0400 Received: from smtp.corp.redhat.com (int-mx02.intmail.prod.int.phx2.redhat.com [10.5.11.12]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 520D1624A4 for ; Thu, 23 Mar 2017 20:46:52 +0000 (UTC) Received: from secure.mitica (ovpn-116-230.ams2.redhat.com [10.36.116.230]) by smtp.corp.redhat.com (Postfix) with ESMTP id 4207453; Thu, 23 Mar 2017 20:46:51 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mx1.redhat.com 520D1624A4 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 520D1624A4 From: Juan Quintela To: qemu-devel@nongnu.org Date: Thu, 23 Mar 2017 21:45:37 +0100 Message-Id: <20170323204544.12015-45-quintela@redhat.com> In-Reply-To: <20170323204544.12015-1-quintela@redhat.com> References: <20170323204544.12015-1-quintela@redhat.com> X-Scanned-By: MIMEDefang 2.79 on 10.5.11.12 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.39]); Thu, 23 Mar 2017 20:46: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 44/51] ram: reorganize last_sent_block 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: 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 were setting it far away of when we changed it. Now everything is done inside save_page_header. Once there, reorganize code to pass RAMState. Signed-off-by: Juan Quintela Reviewed-by: Dr. David Alan Gilbert Reviewed-by: Peter Xu --- migration/ram.c | 36 +++++++++++++++--------------------- 1 file changed, 15 insertions(+), 21 deletions(-) diff --git a/migration/ram.c b/migration/ram.c index 83c749c..6cd77b5 100644 --- a/migration/ram.c +++ b/migration/ram.c @@ -453,18 +453,22 @@ void migrate_compress_threads_create(void) * @offset: offset inside the block for the page * in the lower bits, it contains flags */ -static size_t save_page_header(QEMUFile *f, RAMBlock *block, ram_addr_t of= fset) +static size_t save_page_header(RAMState *rs, RAMBlock *block, ram_addr_t o= ffset) { size_t size, len; =20 - qemu_put_be64(f, offset); + if (block =3D=3D rs->last_sent_block) { + offset |=3D RAM_SAVE_FLAG_CONTINUE; + } + qemu_put_be64(rs->f, offset); size =3D 8; =20 if (!(offset & RAM_SAVE_FLAG_CONTINUE)) { len =3D strlen(block->idstr); - qemu_put_byte(f, len); - qemu_put_buffer(f, (uint8_t *)block->idstr, len); + qemu_put_byte(rs->f, len); + qemu_put_buffer(rs->f, (uint8_t *)block->idstr, len); size +=3D 1 + len; + rs->last_sent_block =3D block; } return size; } @@ -584,7 +588,7 @@ static int save_xbzrle_page(RAMState *rs, uint8_t **cur= rent_data, } =20 /* Send XBZRLE based compressed page */ - bytes_xbzrle =3D save_page_header(rs->f, block, + bytes_xbzrle =3D save_page_header(rs, block, offset | RAM_SAVE_FLAG_XBZRLE); qemu_put_byte(rs->f, ENCODING_FLAG_XBZRLE); qemu_put_be16(rs->f, encoded_len); @@ -769,7 +773,7 @@ static int save_zero_page(RAMState *rs, RAMBlock *block= , ram_addr_t offset, if (is_zero_range(p, TARGET_PAGE_SIZE)) { rs->zero_pages++; rs->bytes_transferred +=3D - save_page_header(rs->f, block, offset | RAM_SAVE_FLAG_COMPRESS= ); + save_page_header(rs, block, offset | RAM_SAVE_FLAG_COMPRESS); qemu_put_byte(rs->f, 0); rs->bytes_transferred +=3D 1; pages =3D 1; @@ -826,9 +830,6 @@ static int ram_save_page(RAMState *rs, PageSearchStatus= *pss, bool last_stage) =20 current_addr =3D block->offset + offset; =20 - if (block =3D=3D rs->last_sent_block) { - offset |=3D RAM_SAVE_FLAG_CONTINUE; - } if (ret !=3D RAM_SAVE_CONTROL_NOT_SUPP) { if (ret !=3D RAM_SAVE_CONTROL_DELAYED) { if (bytes_xmit > 0) { @@ -860,8 +861,8 @@ static int ram_save_page(RAMState *rs, PageSearchStatus= *pss, bool last_stage) =20 /* XBZRLE overflow or normal page */ if (pages =3D=3D -1) { - rs->bytes_transferred +=3D save_page_header(rs->f, block, - offset | RAM_SAVE_FLAG_PAGE= ); + rs->bytes_transferred +=3D save_page_header(rs, block, + offset | RAM_SAVE_FLAG_P= AGE); if (send_async) { qemu_put_buffer_async(rs->f, p, TARGET_PAGE_SIZE, migrate_release_ram() & @@ -882,10 +883,11 @@ static int ram_save_page(RAMState *rs, PageSearchStat= us *pss, bool last_stage) static int do_compress_ram_page(QEMUFile *f, RAMBlock *block, ram_addr_t offset) { + RAMState *rs =3D &ram_state; int bytes_sent, blen; uint8_t *p =3D block->host + (offset & TARGET_PAGE_MASK); =20 - bytes_sent =3D save_page_header(f, block, offset | + bytes_sent =3D save_page_header(rs, block, offset | RAM_SAVE_FLAG_COMPRESS_PAGE); blen =3D qemu_put_compression_data(f, p, TARGET_PAGE_SIZE, migrate_compress_level()); @@ -1016,7 +1018,7 @@ static int ram_save_compressed_page(RAMState *rs, Pag= eSearchStatus *pss, pages =3D save_zero_page(rs, 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(rs->f, block, offset | + bytes_xmit =3D save_page_header(rs, block, offset | RAM_SAVE_FLAG_COMPRESS_PAGE); blen =3D qemu_put_compression_data(rs->f, p, TARGET_PAGE_S= IZE, migrate_compress_level()); @@ -1033,7 +1035,6 @@ static int ram_save_compressed_page(RAMState *rs, Pag= eSearchStatus *pss, ram_release_pages(block->idstr, pss->offset, pages); } } else { - offset |=3D RAM_SAVE_FLAG_CONTINUE; pages =3D save_zero_page(rs, block, offset, p); if (pages =3D=3D -1) { pages =3D compress_page_with_multi_thread(rs, block, offse= t); @@ -1330,13 +1331,6 @@ static int ram_save_target_page(RAMState *rs, PageSe= archStatus *pss, if (unsentmap) { clear_bit(dirty_ram_abs >> TARGET_PAGE_BITS, unsentmap); } - /* Only update last_sent_block if a block was actually sent; xbzrle - * might have decided the page was identical so didn't bother writ= ing - * to the stream. - */ - if (res > 0) { - rs->last_sent_block =3D pss->block; - } } =20 return res; --=20 2.9.3 From nobody Fri May 3 08:55:08 2024 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 149030371340823.5622406351913; Thu, 23 Mar 2017 14:15:13 -0700 (PDT) Received: from localhost ([::1]:58678 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1crA4e-0008Vl-3w for importer@patchew.org; Thu, 23 Mar 2017 17:15:12 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:46021) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1cr9dH-000058-Hq for qemu-devel@nongnu.org; Thu, 23 Mar 2017 16:46:57 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1cr9dG-0000iD-4T for qemu-devel@nongnu.org; Thu, 23 Mar 2017 16:46:55 -0400 Received: from mx1.redhat.com ([209.132.183.28]:37074) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1cr9dF-0000i7-Rw for qemu-devel@nongnu.org; Thu, 23 Mar 2017 16:46:54 -0400 Received: from smtp.corp.redhat.com (int-mx02.intmail.prod.int.phx2.redhat.com [10.5.11.12]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id D159861E7C for ; Thu, 23 Mar 2017 20:46:53 +0000 (UTC) Received: from secure.mitica (ovpn-116-230.ams2.redhat.com [10.36.116.230]) by smtp.corp.redhat.com (Postfix) with ESMTP id 9824A53; Thu, 23 Mar 2017 20:46:52 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mx1.redhat.com D159861E7C 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 D159861E7C From: Juan Quintela To: qemu-devel@nongnu.org Date: Thu, 23 Mar 2017 21:45:38 +0100 Message-Id: <20170323204544.12015-46-quintela@redhat.com> In-Reply-To: <20170323204544.12015-1-quintela@redhat.com> References: <20170323204544.12015-1-quintela@redhat.com> X-Scanned-By: MIMEDefang 2.79 on 10.5.11.12 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.39]); Thu, 23 Mar 2017 20:46:53 +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 45/51] ram: Use page number instead of an address for the bitmap operations 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: 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 use an unsigned long for the page number. Notice that our bitmaps already got that for the index, so we have that limit. Signed-off-by: Juan Quintela --- migration/ram.c | 76 ++++++++++++++++++++++++++---------------------------= ---- 1 file changed, 34 insertions(+), 42 deletions(-) diff --git a/migration/ram.c b/migration/ram.c index 6cd77b5..b1a031e 100644 --- a/migration/ram.c +++ b/migration/ram.c @@ -611,13 +611,12 @@ static int save_xbzrle_page(RAMState *rs, uint8_t **c= urrent_data, * @rs: current RAM state * @rb: RAMBlock where to search for dirty pages * @start: starting address (typically so we can continue from previous pa= ge) - * @ram_addr_abs: pointer into which to store the address of the dirty page - * within the global ram_addr space + * @page: pointer into where to store the dirty page */ static inline ram_addr_t migration_bitmap_find_dirty(RAMState *rs, RAMBlock *rb, ram_addr_t start, - ram_addr_t *ram_addr_abs) + unsigned long *page) { unsigned long base =3D rb->offset >> TARGET_PAGE_BITS; unsigned long nr =3D base + (start >> TARGET_PAGE_BITS); @@ -634,17 +633,17 @@ ram_addr_t migration_bitmap_find_dirty(RAMState *rs, = RAMBlock *rb, next =3D find_next_bit(bitmap, size, nr); } =20 - *ram_addr_abs =3D next << TARGET_PAGE_BITS; + *page =3D next; return (next - base) << TARGET_PAGE_BITS; } =20 -static inline bool migration_bitmap_clear_dirty(RAMState *rs, ram_addr_t a= ddr) +static inline bool migration_bitmap_clear_dirty(RAMState *rs, + unsigned long page) { bool ret; - int nr =3D addr >> TARGET_PAGE_BITS; unsigned long *bitmap =3D atomic_rcu_read(&rs->ram_bitmap)->bmap; =20 - ret =3D test_and_clear_bit(nr, bitmap); + ret =3D test_and_clear_bit(page, bitmap); =20 if (ret) { rs->migration_dirty_pages--; @@ -1056,14 +1055,13 @@ static int ram_save_compressed_page(RAMState *rs, P= ageSearchStatus *pss, * @rs: current RAM state * @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 + * @page: pointer into where to store the dirty page */ static bool find_dirty_block(RAMState *rs, PageSearchStatus *pss, - bool *again, ram_addr_t *ram_addr_abs) + bool *again, unsigned long *page) { pss->offset =3D migration_bitmap_find_dirty(rs, pss->block, pss->offse= t, - ram_addr_abs); + page); if (pss->complete_round && pss->block =3D=3D rs->last_seen_block && pss->offset >=3D rs->last_offset) { /* @@ -1111,11 +1109,10 @@ static bool find_dirty_block(RAMState *rs, PageSear= chStatus *pss, * * @rs: current RAM state * @offset: used to return the offset within the RAMBlock - * @ram_addr_abs: pointer into which to store the address of the dirty page - * within the global ram_addr space + * @page: pointer into where to store the dirty page */ static RAMBlock *unqueue_page(RAMState *rs, ram_addr_t *offset, - ram_addr_t *ram_addr_abs) + unsigned long *page) { RAMBlock *block =3D NULL; =20 @@ -1125,8 +1122,7 @@ static RAMBlock *unqueue_page(RAMState *rs, ram_addr_= t *offset, QSIMPLEQ_FIRST(&rs->src_page_requests); block =3D entry->rb; *offset =3D entry->offset; - *ram_addr_abs =3D (entry->offset + entry->rb->offset) & - TARGET_PAGE_MASK; + *page =3D (entry->offset + entry->rb->offset) >> TARGET_PAGE_BITS; =20 if (entry->len > TARGET_PAGE_SIZE) { entry->len -=3D TARGET_PAGE_SIZE; @@ -1151,18 +1147,17 @@ static RAMBlock *unqueue_page(RAMState *rs, ram_add= r_t *offset, * * @rs: current RAM state * @pss: data about the state of the current dirty page scan - * @ram_addr_abs: pointer into which to store the address of the dirty page - * within the global ram_addr space + * @page: pointer into where to store the dirty page */ static bool get_queued_page(RAMState *rs, PageSearchStatus *pss, - ram_addr_t *ram_addr_abs) + unsigned long *page) { RAMBlock *block; ram_addr_t offset; bool dirty; =20 do { - block =3D unqueue_page(rs, &offset, ram_addr_abs); + block =3D unqueue_page(rs, &offset, page); /* * We're sending this page, and since it's postcopy nothing else * will dirty it, and we must make sure it doesn't get sent again @@ -1172,17 +1167,15 @@ static bool get_queued_page(RAMState *rs, PageSearc= hStatus *pss, if (block) { unsigned long *bitmap; bitmap =3D atomic_rcu_read(&rs->ram_bitmap)->bmap; - dirty =3D test_bit(*ram_addr_abs >> TARGET_PAGE_BITS, bitmap); + dirty =3D test_bit(*page, 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(&rs->ram_bitmap)->unsentmap)); + trace_get_queued_page_not_dirty(block->idstr, (uint64_t)of= fset, + *page, + test_bit(*page, + atomic_rcu_read(&rs->ram_bitmap)->unsentmap)); } else { - trace_get_queued_page(block->idstr, - (uint64_t)offset, - (uint64_t)*ram_addr_abs); + trace_get_queued_page(block->idstr, (uint64_t)offset, + *page); } } =20 @@ -1308,15 +1301,15 @@ err: * @ms: current migration state * @pss: data about the page we want to send * @last_stage: if we are at the completion stage - * @dirty_ram_abs: address of the start of the dirty page in ram_addr_t sp= ace + * @page: page number of the dirty page */ static int ram_save_target_page(RAMState *rs, PageSearchStatus *pss, - bool last_stage, ram_addr_t dirty_ram_abs) + bool last_stage, unsigned long page) { int res =3D 0; =20 /* Check the pages is dirty and if it is send it */ - if (migration_bitmap_clear_dirty(rs, dirty_ram_abs)) { + if (migration_bitmap_clear_dirty(rs, page)) { unsigned long *unsentmap; if (!rs->preffer_xbzrle && migrate_use_compression()) { res =3D ram_save_compressed_page(rs, pss, last_stage); @@ -1329,7 +1322,7 @@ static int ram_save_target_page(RAMState *rs, PageSea= rchStatus *pss, } unsentmap =3D atomic_rcu_read(&rs->ram_bitmap)->unsentmap; if (unsentmap) { - clear_bit(dirty_ram_abs >> TARGET_PAGE_BITS, unsentmap); + clear_bit(page, unsentmap); } } =20 @@ -1351,24 +1344,24 @@ static int ram_save_target_page(RAMState *rs, PageS= earchStatus *pss, * @ms: current migration state * @pss: data about the page we want to send * @last_stage: if we are at the completion stage - * @dirty_ram_abs: Address of the start of the dirty page in ram_addr_t sp= ace + * @page: Page number of the dirty page */ static int ram_save_host_page(RAMState *rs, PageSearchStatus *pss, bool last_stage, - ram_addr_t dirty_ram_abs) + unsigned long page) { int tmppages, pages =3D 0; size_t pagesize =3D qemu_ram_pagesize(pss->block); =20 do { - tmppages =3D ram_save_target_page(rs, pss, last_stage, dirty_ram_a= bs); + tmppages =3D ram_save_target_page(rs, pss, last_stage, page); if (tmppages < 0) { return tmppages; } =20 pages +=3D tmppages; pss->offset +=3D TARGET_PAGE_SIZE; - dirty_ram_abs +=3D TARGET_PAGE_SIZE; + page++; } while (pss->offset & (pagesize - 1)); =20 /* The offset we leave with is the last one we looked at */ @@ -1395,8 +1388,7 @@ static int ram_find_and_save_block(RAMState *rs, bool= last_stage) PageSearchStatus pss; int pages =3D 0; bool again, found; - ram_addr_t dirty_ram_abs; /* Address of the start of the dirty page in - ram_addr_t space */ + unsigned long page; /* Page number of the dirty page */ =20 /* No dirty page as there is zero RAM */ if (!ram_bytes_total()) { @@ -1413,15 +1405,15 @@ static int ram_find_and_save_block(RAMState *rs, bo= ol last_stage) =20 do { again =3D true; - found =3D get_queued_page(rs, &pss, &dirty_ram_abs); + found =3D get_queued_page(rs, &pss, &page); =20 if (!found) { /* priority queue empty, so just search for something dirty */ - found =3D find_dirty_block(rs, &pss, &again, &dirty_ram_abs); + found =3D find_dirty_block(rs, &pss, &again, &page); } =20 if (found) { - pages =3D ram_save_host_page(rs, &pss, last_stage, dirty_ram_a= bs); + pages =3D ram_save_host_page(rs, &pss, last_stage, page); } } while (!pages && again); =20 --=20 2.9.3 From nobody Fri May 3 08:55:08 2024 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 1490303852888830.7107470177156; Thu, 23 Mar 2017 14:17:32 -0700 (PDT) Received: from localhost ([::1]:58691 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1crA6t-00021z-H3 for importer@patchew.org; Thu, 23 Mar 2017 17:17:31 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:46027) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1cr9dI-00005A-2m for qemu-devel@nongnu.org; Thu, 23 Mar 2017 16:46:57 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1cr9dH-0000iW-Ba for qemu-devel@nongnu.org; Thu, 23 Mar 2017 16:46:56 -0400 Received: from mx1.redhat.com ([209.132.183.28]:35578) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1cr9dH-0000iP-5p for qemu-devel@nongnu.org; Thu, 23 Mar 2017 16:46:55 -0400 Received: from smtp.corp.redhat.com (int-mx02.intmail.prod.int.phx2.redhat.com [10.5.11.12]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 2B56881F07 for ; Thu, 23 Mar 2017 20:46:55 +0000 (UTC) Received: from secure.mitica (ovpn-116-230.ams2.redhat.com [10.36.116.230]) by smtp.corp.redhat.com (Postfix) with ESMTP id 2E0F953; Thu, 23 Mar 2017 20:46:54 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mx1.redhat.com 2B56881F07 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 2B56881F07 From: Juan Quintela To: qemu-devel@nongnu.org Date: Thu, 23 Mar 2017 21:45:39 +0100 Message-Id: <20170323204544.12015-47-quintela@redhat.com> In-Reply-To: <20170323204544.12015-1-quintela@redhat.com> References: <20170323204544.12015-1-quintela@redhat.com> X-Scanned-By: MIMEDefang 2.79 on 10.5.11.12 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.25]); Thu, 23 Mar 2017 20:46: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 46/51] ram: Remember last_page instead of last_offset 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: 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 b1a031e..57b776b 100644 --- a/migration/ram.c +++ b/migration/ram.c @@ -171,8 +171,8 @@ struct RAMState { RAMBlock *last_seen_block; /* Last block from where we have sent data */ RAMBlock *last_sent_block; - /* Last offset we have sent data from */ - ram_addr_t last_offset; + /* Last dirty page we have sent */ + ram_addr_t last_page; /* last ram version we have seen */ uint32_t last_version; /* We are in the first round */ @@ -1063,7 +1063,7 @@ static bool find_dirty_block(RAMState *rs, PageSearch= Status *pss, pss->offset =3D migration_bitmap_find_dirty(rs, pss->block, pss->offse= t, page); if (pss->complete_round && pss->block =3D=3D rs->last_seen_block && - pss->offset >=3D rs->last_offset) { + pss->offset >=3D rs->last_page) { /* * We've been once around the RAM and haven't found anything. * Give up. @@ -1396,7 +1396,7 @@ static int ram_find_and_save_block(RAMState *rs, bool= last_stage) } =20 pss.block =3D rs->last_seen_block; - pss.offset =3D rs->last_offset; + pss.offset =3D rs->last_page << TARGET_PAGE_BITS; pss.complete_round =3D false; =20 if (!pss.block) { @@ -1418,7 +1418,7 @@ static int ram_find_and_save_block(RAMState *rs, bool= last_stage) } while (!pages && again); =20 rs->last_seen_block =3D pss.block; - rs->last_offset =3D pss.offset; + rs->last_page =3D pss.offset >> TARGET_PAGE_BITS; =20 return pages; } @@ -1493,7 +1493,7 @@ static void ram_state_reset(RAMState *rs) { rs->last_seen_block =3D NULL; rs->last_sent_block =3D NULL; - rs->last_offset =3D 0; + rs->last_page =3D 0; rs->last_version =3D ram_list.version; rs->ram_bulk_stage =3D true; } @@ -1838,7 +1838,7 @@ static int postcopy_chunk_hostpages(MigrationState *m= s) /* Easiest way to make sure we don't resume in the middle of a host-pa= ge */ rs->last_seen_block =3D NULL; rs->last_sent_block =3D NULL; - rs->last_offset =3D 0; + rs->last_page =3D 0; =20 QLIST_FOREACH_RCU(block, &ram_list.blocks, next) { unsigned long first =3D block->offset >> TARGET_PAGE_BITS; --=20 2.9.3 From nobody Fri May 3 08:55:08 2024 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 1490303980650574.556382408907; Thu, 23 Mar 2017 14:19:40 -0700 (PDT) Received: from localhost ([::1]:58705 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1crA8w-0003qv-Uz for importer@patchew.org; Thu, 23 Mar 2017 17:19:39 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:46042) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1cr9dJ-00006F-SR for qemu-devel@nongnu.org; Thu, 23 Mar 2017 16:46:59 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1cr9dI-0000it-OY for qemu-devel@nongnu.org; Thu, 23 Mar 2017 16:46:57 -0400 Received: from mx1.redhat.com ([209.132.183.28]:60438) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1cr9dI-0000ih-GM for qemu-devel@nongnu.org; Thu, 23 Mar 2017 16:46:56 -0400 Received: from smtp.corp.redhat.com (int-mx02.intmail.prod.int.phx2.redhat.com [10.5.11.12]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 7817481F07 for ; Thu, 23 Mar 2017 20:46:56 +0000 (UTC) Received: from secure.mitica (ovpn-116-230.ams2.redhat.com [10.36.116.230]) by smtp.corp.redhat.com (Postfix) with ESMTP id 7E33353; Thu, 23 Mar 2017 20:46:55 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mx1.redhat.com 7817481F07 Authentication-Results: ext-mx02.extmail.prod.ext.phx2.redhat.com; dmarc=none (p=none dis=none) header.from=redhat.com Authentication-Results: ext-mx02.extmail.prod.ext.phx2.redhat.com; spf=pass smtp.mailfrom=quintela@redhat.com DKIM-Filter: OpenDKIM Filter v2.11.0 mx1.redhat.com 7817481F07 From: Juan Quintela To: qemu-devel@nongnu.org Date: Thu, 23 Mar 2017 21:45:40 +0100 Message-Id: <20170323204544.12015-48-quintela@redhat.com> In-Reply-To: <20170323204544.12015-1-quintela@redhat.com> References: <20170323204544.12015-1-quintela@redhat.com> X-Scanned-By: MIMEDefang 2.79 on 10.5.11.12 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.26]); Thu, 23 Mar 2017 20:46:56 +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 47/51] ram: Change offset field in PageSearchStatus to page 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: 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 are moving everything to work on pages, not addresses. Signed-off-by: Juan Quintela Reviewed-by: Dr. David Alan Gilbert --- migration/ram.c | 50 +++++++++++++++++++++++++------------------------- 1 file changed, 25 insertions(+), 25 deletions(-) diff --git a/migration/ram.c b/migration/ram.c index 57b776b..ef3b428 100644 --- a/migration/ram.c +++ b/migration/ram.c @@ -298,8 +298,8 @@ uint64_t ram_postcopy_requests(void) struct PageSearchStatus { /* Current block being searched */ RAMBlock *block; - /* Current offset to search from */ - ram_addr_t offset; + /* Current page to search from */ + unsigned long page; /* Set once we wrap around */ bool complete_round; }; @@ -610,16 +610,16 @@ static int save_xbzrle_page(RAMState *rs, uint8_t **c= urrent_data, * * @rs: current RAM state * @rb: RAMBlock where to search for dirty pages - * @start: starting address (typically so we can continue from previous pa= ge) + * @start: page where we start the search * @page: pointer into where to store the dirty page */ static inline -ram_addr_t migration_bitmap_find_dirty(RAMState *rs, RAMBlock *rb, - ram_addr_t start, - unsigned long *page) +unsigned long migration_bitmap_find_dirty(RAMState *rs, RAMBlock *rb, + unsigned long start, + unsigned long *page) { unsigned long base =3D rb->offset >> TARGET_PAGE_BITS; - unsigned long nr =3D base + (start >> TARGET_PAGE_BITS); + unsigned long nr =3D base + start; uint64_t rb_size =3D rb->used_length; unsigned long size =3D base + (rb_size >> TARGET_PAGE_BITS); unsigned long *bitmap; @@ -634,7 +634,7 @@ ram_addr_t migration_bitmap_find_dirty(RAMState *rs, RA= MBlock *rb, } =20 *page =3D next; - return (next - base) << TARGET_PAGE_BITS; + return next - base; } =20 static inline bool migration_bitmap_clear_dirty(RAMState *rs, @@ -812,7 +812,7 @@ static int ram_save_page(RAMState *rs, PageSearchStatus= *pss, bool last_stage) int ret; bool send_async =3D true; RAMBlock *block =3D pss->block; - ram_addr_t offset =3D pss->offset; + ram_addr_t offset =3D pss->page << TARGET_PAGE_BITS; =20 p =3D block->host + offset; =20 @@ -844,7 +844,7 @@ static int ram_save_page(RAMState *rs, PageSearchStatus= *pss, bool last_stage) * page would be stale */ xbzrle_cache_zero_page(rs, current_addr); - ram_release_pages(block->idstr, pss->offset, pages); + ram_release_pages(block->idstr, offset, pages); } else if (!rs->ram_bulk_stage && !migration_in_postcopy() && migrate_use_xbzrle()) { pages =3D save_xbzrle_page(rs, &p, current_addr, block, @@ -987,7 +987,7 @@ static int ram_save_compressed_page(RAMState *rs, PageS= earchStatus *pss, uint8_t *p; int ret, blen; RAMBlock *block =3D pss->block; - ram_addr_t offset =3D pss->offset; + ram_addr_t offset =3D pss->page << TARGET_PAGE_BITS; =20 p =3D block->host + offset; =20 @@ -1031,14 +1031,14 @@ static int ram_save_compressed_page(RAMState *rs, P= ageSearchStatus *pss, } } if (pages > 0) { - ram_release_pages(block->idstr, pss->offset, pages); + ram_release_pages(block->idstr, offset, pages); } } else { pages =3D save_zero_page(rs, block, offset, p); if (pages =3D=3D -1) { pages =3D compress_page_with_multi_thread(rs, block, offse= t); } else { - ram_release_pages(block->idstr, pss->offset, pages); + ram_release_pages(block->idstr, offset, pages); } } } @@ -1060,10 +1060,9 @@ static int ram_save_compressed_page(RAMState *rs, Pa= geSearchStatus *pss, static bool find_dirty_block(RAMState *rs, PageSearchStatus *pss, bool *again, unsigned long *page) { - pss->offset =3D migration_bitmap_find_dirty(rs, pss->block, pss->offse= t, - page); + pss->page =3D migration_bitmap_find_dirty(rs, pss->block, pss->page, p= age); if (pss->complete_round && pss->block =3D=3D rs->last_seen_block && - pss->offset >=3D rs->last_page) { + pss->page >=3D rs->last_page) { /* * We've been once around the RAM and haven't found anything. * Give up. @@ -1071,9 +1070,9 @@ static bool find_dirty_block(RAMState *rs, PageSearch= Status *pss, *again =3D false; return false; } - if (pss->offset >=3D pss->block->used_length) { + if ((pss->page << TARGET_PAGE_BITS) >=3D pss->block->used_length) { /* Didn't find anything in this RAM Block */ - pss->offset =3D 0; + pss->page =3D 0; pss->block =3D QLIST_NEXT_RCU(pss->block, next); if (!pss->block) { /* Hit the end of the list */ @@ -1196,7 +1195,7 @@ static bool get_queued_page(RAMState *rs, PageSearchS= tatus *pss, * it just requested. */ pss->block =3D block; - pss->offset =3D offset; + pss->page =3D offset >> TARGET_PAGE_BITS; } =20 return !!block; @@ -1351,7 +1350,8 @@ static int ram_save_host_page(RAMState *rs, PageSearc= hStatus *pss, unsigned long page) { int tmppages, pages =3D 0; - size_t pagesize =3D qemu_ram_pagesize(pss->block); + size_t pagesize_bits =3D + qemu_ram_pagesize(pss->block) >> TARGET_PAGE_BITS; =20 do { tmppages =3D ram_save_target_page(rs, pss, last_stage, page); @@ -1360,12 +1360,12 @@ static int ram_save_host_page(RAMState *rs, PageSea= rchStatus *pss, } =20 pages +=3D tmppages; - pss->offset +=3D TARGET_PAGE_SIZE; + pss->page++; page++; - } while (pss->offset & (pagesize - 1)); + } while (pss->page & (pagesize_bits - 1)); =20 /* The offset we leave with is the last one we looked at */ - pss->offset -=3D TARGET_PAGE_SIZE; + pss->page--; return pages; } =20 @@ -1396,7 +1396,7 @@ static int ram_find_and_save_block(RAMState *rs, bool= last_stage) } =20 pss.block =3D rs->last_seen_block; - pss.offset =3D rs->last_page << TARGET_PAGE_BITS; + pss.page =3D rs->last_page; pss.complete_round =3D false; =20 if (!pss.block) { @@ -1418,7 +1418,7 @@ static int ram_find_and_save_block(RAMState *rs, bool= last_stage) } while (!pages && again); =20 rs->last_seen_block =3D pss.block; - rs->last_page =3D pss.offset >> TARGET_PAGE_BITS; + rs->last_page =3D pss.page; =20 return pages; } --=20 2.9.3 From nobody Fri May 3 08:55:08 2024 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 1490303861621940.7269823080384; Thu, 23 Mar 2017 14:17:41 -0700 (PDT) Received: from localhost ([::1]:58692 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1crA72-00027C-BG for importer@patchew.org; Thu, 23 Mar 2017 17:17:40 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:46056) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1cr9dL-0000B9-V7 for qemu-devel@nongnu.org; Thu, 23 Mar 2017 16:47:03 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1cr9dK-0000jJ-Is for qemu-devel@nongnu.org; Thu, 23 Mar 2017 16:46:59 -0400 Received: from mx1.redhat.com ([209.132.183.28]:45748) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1cr9dK-0000j5-9r for qemu-devel@nongnu.org; Thu, 23 Mar 2017 16:46:58 -0400 Received: from smtp.corp.redhat.com (int-mx02.intmail.prod.int.phx2.redhat.com [10.5.11.12]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 44F54C04B31F for ; Thu, 23 Mar 2017 20:46:58 +0000 (UTC) Received: from secure.mitica (ovpn-116-230.ams2.redhat.com [10.36.116.230]) by smtp.corp.redhat.com (Postfix) with ESMTP id C8EE253; Thu, 23 Mar 2017 20:46:56 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mx1.redhat.com 44F54C04B31F 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 44F54C04B31F From: Juan Quintela To: qemu-devel@nongnu.org Date: Thu, 23 Mar 2017 21:45:41 +0100 Message-Id: <20170323204544.12015-49-quintela@redhat.com> In-Reply-To: <20170323204544.12015-1-quintela@redhat.com> References: <20170323204544.12015-1-quintela@redhat.com> X-Scanned-By: MIMEDefang 2.79 on 10.5.11.12 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.31]); Thu, 23 Mar 2017 20:46: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 48/51] ram: Use ramblock and page offset instead of absolute offset 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: 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 removes the needto pass also the absolute offset. Signed-off-by: Juan Quintela --- migration/ram.c | 56 ++++++++++++++++++++++------------------------= ---- migration/trace-events | 2 +- 2 files changed, 26 insertions(+), 32 deletions(-) diff --git a/migration/ram.c b/migration/ram.c index ef3b428..3f283ba 100644 --- a/migration/ram.c +++ b/migration/ram.c @@ -611,12 +611,10 @@ static int save_xbzrle_page(RAMState *rs, uint8_t **c= urrent_data, * @rs: current RAM state * @rb: RAMBlock where to search for dirty pages * @start: page where we start the search - * @page: pointer into where to store the dirty page */ static inline unsigned long migration_bitmap_find_dirty(RAMState *rs, RAMBlock *rb, - unsigned long start, - unsigned long *page) + unsigned long start) { unsigned long base =3D rb->offset >> TARGET_PAGE_BITS; unsigned long nr =3D base + start; @@ -633,17 +631,18 @@ unsigned long migration_bitmap_find_dirty(RAMState *r= s, RAMBlock *rb, next =3D find_next_bit(bitmap, size, nr); } =20 - *page =3D next; return next - base; } =20 static inline bool migration_bitmap_clear_dirty(RAMState *rs, + RAMBlock *rb, unsigned long page) { bool ret; unsigned long *bitmap =3D atomic_rcu_read(&rs->ram_bitmap)->bmap; + unsigned long nr =3D (rb->offset >> TARGET_PAGE_BITS) + page; =20 - ret =3D test_and_clear_bit(page, bitmap); + ret =3D test_and_clear_bit(nr, bitmap); =20 if (ret) { rs->migration_dirty_pages--; @@ -1057,10 +1056,9 @@ static int ram_save_compressed_page(RAMState *rs, Pa= geSearchStatus *pss, * @again: set to false if the search has scanned the whole of RAM * @page: pointer into where to store the dirty page */ -static bool find_dirty_block(RAMState *rs, PageSearchStatus *pss, - bool *again, unsigned long *page) +static bool find_dirty_block(RAMState *rs, PageSearchStatus *pss, bool *ag= ain) { - pss->page =3D migration_bitmap_find_dirty(rs, pss->block, pss->page, p= age); + pss->page =3D migration_bitmap_find_dirty(rs, pss->block, pss->page); if (pss->complete_round && pss->block =3D=3D rs->last_seen_block && pss->page >=3D rs->last_page) { /* @@ -1110,8 +1108,7 @@ static bool find_dirty_block(RAMState *rs, PageSearch= Status *pss, * @offset: used to return the offset within the RAMBlock * @page: pointer into where to store the dirty page */ -static RAMBlock *unqueue_page(RAMState *rs, ram_addr_t *offset, - unsigned long *page) +static RAMBlock *unqueue_page(RAMState *rs, ram_addr_t *offset) { RAMBlock *block =3D NULL; =20 @@ -1121,7 +1118,6 @@ static RAMBlock *unqueue_page(RAMState *rs, ram_addr_= t *offset, QSIMPLEQ_FIRST(&rs->src_page_requests); block =3D entry->rb; *offset =3D entry->offset; - *page =3D (entry->offset + entry->rb->offset) >> TARGET_PAGE_BITS; =20 if (entry->len > TARGET_PAGE_SIZE) { entry->len -=3D TARGET_PAGE_SIZE; @@ -1148,15 +1144,14 @@ static RAMBlock *unqueue_page(RAMState *rs, ram_add= r_t *offset, * @pss: data about the state of the current dirty page scan * @page: pointer into where to store the dirty page */ -static bool get_queued_page(RAMState *rs, PageSearchStatus *pss, - unsigned long *page) +static bool get_queued_page(RAMState *rs, PageSearchStatus *pss) { RAMBlock *block; ram_addr_t offset; bool dirty; =20 do { - block =3D unqueue_page(rs, &offset, page); + block =3D unqueue_page(rs, &offset); /* * We're sending this page, and since it's postcopy nothing else * will dirty it, and we must make sure it doesn't get sent again @@ -1165,16 +1160,18 @@ static bool get_queued_page(RAMState *rs, PageSearc= hStatus *pss, */ if (block) { unsigned long *bitmap; + unsigned long page; + bitmap =3D atomic_rcu_read(&rs->ram_bitmap)->bmap; - dirty =3D test_bit(*page, bitmap); + page =3D (block->offset + offset) >> TARGET_PAGE_BITS; + dirty =3D test_bit(page, bitmap); if (!dirty) { trace_get_queued_page_not_dirty(block->idstr, (uint64_t)of= fset, - *page, - test_bit(*page, + page, + test_bit(page, atomic_rcu_read(&rs->ram_bitmap)->unsentmap)); } else { - trace_get_queued_page(block->idstr, (uint64_t)offset, - *page); + trace_get_queued_page(block->idstr, (uint64_t)offset, page= ); } } =20 @@ -1300,16 +1297,17 @@ err: * @ms: current migration state * @pss: data about the page we want to send * @last_stage: if we are at the completion stage - * @page: page number of the dirty page */ static int ram_save_target_page(RAMState *rs, PageSearchStatus *pss, - bool last_stage, unsigned long page) + bool last_stage) { int res =3D 0; =20 /* Check the pages is dirty and if it is send it */ - if (migration_bitmap_clear_dirty(rs, page)) { + if (migration_bitmap_clear_dirty(rs, pss->block, pss->page)) { unsigned long *unsentmap; + unsigned long page =3D + (pss->block->offset >> TARGET_PAGE_BITS) + pss->page; if (!rs->preffer_xbzrle && migrate_use_compression()) { res =3D ram_save_compressed_page(rs, pss, last_stage); } else { @@ -1343,25 +1341,22 @@ static int ram_save_target_page(RAMState *rs, PageS= earchStatus *pss, * @ms: current migration state * @pss: data about the page we want to send * @last_stage: if we are at the completion stage - * @page: Page number of the dirty page */ static int ram_save_host_page(RAMState *rs, PageSearchStatus *pss, - bool last_stage, - unsigned long page) + bool last_stage) { int tmppages, pages =3D 0; size_t pagesize_bits =3D qemu_ram_pagesize(pss->block) >> TARGET_PAGE_BITS; =20 do { - tmppages =3D ram_save_target_page(rs, pss, last_stage, page); + tmppages =3D ram_save_target_page(rs, pss, last_stage); if (tmppages < 0) { return tmppages; } =20 pages +=3D tmppages; pss->page++; - page++; } while (pss->page & (pagesize_bits - 1)); =20 /* The offset we leave with is the last one we looked at */ @@ -1388,7 +1383,6 @@ static int ram_find_and_save_block(RAMState *rs, bool= last_stage) PageSearchStatus pss; int pages =3D 0; bool again, found; - unsigned long page; /* Page number of the dirty page */ =20 /* No dirty page as there is zero RAM */ if (!ram_bytes_total()) { @@ -1405,15 +1399,15 @@ static int ram_find_and_save_block(RAMState *rs, bo= ol last_stage) =20 do { again =3D true; - found =3D get_queued_page(rs, &pss, &page); + found =3D get_queued_page(rs, &pss); =20 if (!found) { /* priority queue empty, so just search for something dirty */ - found =3D find_dirty_block(rs, &pss, &again, &page); + found =3D find_dirty_block(rs, &pss, &again); } =20 if (found) { - pages =3D ram_save_host_page(rs, &pss, last_stage, page); + pages =3D ram_save_host_page(rs, &pss, last_stage); } } while (!pages && again); =20 diff --git a/migration/trace-events b/migration/trace-events index 7372ce2..0a3f033 100644 --- a/migration/trace-events +++ b/migration/trace-events @@ -63,7 +63,7 @@ put_qtailq_end(const char *name, const char *reason) "%s = %s" qemu_file_fclose(void) "" =20 # migration/ram.c -get_queued_page(const char *block_name, uint64_t tmp_offset, uint64_t ram_= addr) "%s/%" PRIx64 " ram_addr=3D%" PRIx64 +get_queued_page(const char *block_name, uint64_t tmp_offset, unsigned long= page) "%s/%" PRIx64 " page=3D%lu" get_queued_page_not_dirty(const char *block_name, uint64_t tmp_offset, uin= t64_t ram_addr, int sent) "%s/%" PRIx64 " ram_addr=3D%" PRIx64 " (sent=3D%d= )" migration_bitmap_sync_start(void) "" migration_bitmap_sync_end(uint64_t dirty_pages) "dirty_pages %" PRIu64 --=20 2.9.3 From nobody Fri May 3 08:55:08 2024 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 1490303501962741.1570696562723; Thu, 23 Mar 2017 14:11:41 -0700 (PDT) Received: from localhost ([::1]:58665 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1crA1E-00057O-DP for importer@patchew.org; Thu, 23 Mar 2017 17:11:40 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:46091) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1cr9dP-0000Ei-5b for qemu-devel@nongnu.org; Thu, 23 Mar 2017 16:47:04 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1cr9dM-0000kY-8m for qemu-devel@nongnu.org; Thu, 23 Mar 2017 16:47:03 -0400 Received: from mx1.redhat.com ([209.132.183.28]:35640) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1cr9dM-0000jw-0q for qemu-devel@nongnu.org; Thu, 23 Mar 2017 16:47:00 -0400 Received: from smtp.corp.redhat.com (int-mx02.intmail.prod.int.phx2.redhat.com [10.5.11.12]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id F37F67AE9A for ; Thu, 23 Mar 2017 20:46:59 +0000 (UTC) Received: from secure.mitica (ovpn-116-230.ams2.redhat.com [10.36.116.230]) by smtp.corp.redhat.com (Postfix) with ESMTP id 99EBD77ECB; Thu, 23 Mar 2017 20:46:58 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mx1.redhat.com F37F67AE9A 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 F37F67AE9A From: Juan Quintela To: qemu-devel@nongnu.org Date: Thu, 23 Mar 2017 21:45:42 +0100 Message-Id: <20170323204544.12015-50-quintela@redhat.com> In-Reply-To: <20170323204544.12015-1-quintela@redhat.com> References: <20170323204544.12015-1-quintela@redhat.com> X-Scanned-By: MIMEDefang 2.79 on 10.5.11.12 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.25]); Thu, 23 Mar 2017 20:47: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 49/51] ram: rename last_ram_offset() last_ram_pages() 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: 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 always use it as pages anyways. Signed-off-by: Juan Quintela Reviewed-by: Dr. David Alan Gilbert --- exec.c | 6 +++--- include/exec/ram_addr.h | 2 +- migration/ram.c | 11 +++++------ 3 files changed, 9 insertions(+), 10 deletions(-) diff --git a/exec.c b/exec.c index 9a4c385..2cae288 100644 --- a/exec.c +++ b/exec.c @@ -1528,7 +1528,7 @@ static ram_addr_t find_ram_offset(ram_addr_t size) return offset; } =20 -ram_addr_t last_ram_offset(void) +unsigned long last_ram_page(void) { RAMBlock *block; ram_addr_t last =3D 0; @@ -1538,7 +1538,7 @@ ram_addr_t last_ram_offset(void) last =3D MAX(last, block->offset + block->max_length); } rcu_read_unlock(); - return last; + return last >> TARGET_PAGE_BITS; } =20 static void qemu_ram_setup_dump(void *addr, ram_addr_t size) @@ -1727,7 +1727,7 @@ static void ram_block_add(RAMBlock *new_block, Error = **errp) ram_addr_t old_ram_size, new_ram_size; Error *err =3D NULL; =20 - old_ram_size =3D last_ram_offset() >> TARGET_PAGE_BITS; + old_ram_size =3D last_ram_page(); =20 qemu_mutex_lock_ramlist(); new_block->offset =3D find_ram_offset(new_block->max_length); diff --git a/include/exec/ram_addr.h b/include/exec/ram_addr.h index d50c970..bbbfc7d 100644 --- a/include/exec/ram_addr.h +++ b/include/exec/ram_addr.h @@ -53,7 +53,7 @@ static inline void *ramblock_ptr(RAMBlock *block, ram_add= r_t offset) } =20 long qemu_getrampagesize(void); -ram_addr_t last_ram_offset(void); +unsigned long last_ram_page(void); RAMBlock *qemu_ram_alloc_from_file(ram_addr_t size, MemoryRegion *mr, bool share, const char *mem_path, Error **errp); diff --git a/migration/ram.c b/migration/ram.c index 3f283ba..1be9a6b 100644 --- a/migration/ram.c +++ b/migration/ram.c @@ -1535,7 +1535,7 @@ void migration_bitmap_extend(ram_addr_t old, ram_addr= _t new) */ void ram_debug_dump_bitmap(unsigned long *todump, bool expected) { - int64_t ram_pages =3D last_ram_offset() >> TARGET_PAGE_BITS; + unsigned long ram_pages =3D last_ram_page(); RAMState *rs =3D &ram_state; int64_t cur; int64_t linelen =3D 128; @@ -1902,8 +1902,7 @@ int ram_postcopy_send_discard_bitmap(MigrationState *= ms) * Update the unsentmap to be unsentmap =3D unsentmap | dirty */ bitmap =3D atomic_rcu_read(&rs->ram_bitmap)->bmap; - bitmap_or(unsentmap, unsentmap, bitmap, - last_ram_offset() >> TARGET_PAGE_BITS); + bitmap_or(unsentmap, unsentmap, bitmap, last_ram_page()); =20 =20 trace_ram_postcopy_send_discard_bitmap(); @@ -1951,7 +1950,7 @@ err: =20 static int ram_state_init(RAMState *rs) { - int64_t ram_bitmap_pages; /* Size of bitmap in pages, including gaps */ + unsigned long ram_bitmap_pages; =20 memset(rs, 0, sizeof(*rs)); qemu_mutex_init(&rs->bitmap_mutex); @@ -1997,7 +1996,7 @@ static int ram_state_init(RAMState *rs) 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; + ram_bitmap_pages =3D last_ram_page(); rs->ram_bitmap->bmap =3D bitmap_new(ram_bitmap_pages); bitmap_set(rs->ram_bitmap->bmap, 0, ram_bitmap_pages); =20 @@ -2458,7 +2457,7 @@ static void decompress_data_with_multi_threads(QEMUFi= le *f, */ int ram_postcopy_incoming_init(MigrationIncomingState *mis) { - size_t ram_pages =3D last_ram_offset() >> TARGET_PAGE_BITS; + unsigned long ram_pages =3D last_ram_page(); =20 return postcopy_ram_incoming_init(mis, ram_pages); } --=20 2.9.3 From nobody Fri May 3 08:55:08 2024 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 1490304091189455.1520998583868; Thu, 23 Mar 2017 14:21:31 -0700 (PDT) Received: from localhost ([::1]:58719 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1crAAj-0005gz-JS for importer@patchew.org; Thu, 23 Mar 2017 17:21:29 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:46092) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1cr9dP-0000Ej-5Z for qemu-devel@nongnu.org; Thu, 23 Mar 2017 16:47:08 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1cr9dN-0000l0-Pf for qemu-devel@nongnu.org; Thu, 23 Mar 2017 16:47:03 -0400 Received: from mx1.redhat.com ([209.132.183.28]:48100) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1cr9dN-0000kq-Ip for qemu-devel@nongnu.org; Thu, 23 Mar 2017 16:47:01 -0400 Received: from smtp.corp.redhat.com (int-mx02.intmail.prod.int.phx2.redhat.com [10.5.11.12]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 861233DBC9 for ; Thu, 23 Mar 2017 20:47:01 +0000 (UTC) Received: from secure.mitica (ovpn-116-230.ams2.redhat.com [10.36.116.230]) by smtp.corp.redhat.com (Postfix) with ESMTP id 5263077ECB; Thu, 23 Mar 2017 20:47:00 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mx1.redhat.com 861233DBC9 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 861233DBC9 From: Juan Quintela To: qemu-devel@nongnu.org Date: Thu, 23 Mar 2017 21:45:43 +0100 Message-Id: <20170323204544.12015-51-quintela@redhat.com> In-Reply-To: <20170323204544.12015-1-quintela@redhat.com> References: <20170323204544.12015-1-quintela@redhat.com> X-Scanned-By: MIMEDefang 2.79 on 10.5.11.12 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.30]); Thu, 23 Mar 2017 20:47:01 +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 50/51] ram: Use RAMBitmap type for coherence 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: 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 | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/migration/ram.c b/migration/ram.c index 1be9a6b..4d62788 100644 --- a/migration/ram.c +++ b/migration/ram.c @@ -1449,7 +1449,7 @@ void free_xbzrle_decoded_buf(void) xbzrle_decoded_buf =3D NULL; } =20 -static void migration_bitmap_free(struct RAMBitmap *bmap) +static void migration_bitmap_free(RAMBitmap *bmap) { g_free(bmap->bmap); g_free(bmap->unsentmap); @@ -1463,7 +1463,7 @@ static void ram_migration_cleanup(void *opaque) /* caller have hold iothread lock or is in a bh, so there is * no writing race against this migration_bitmap */ - struct RAMBitmap *bitmap =3D rs->ram_bitmap; + RAMBitmap *bitmap =3D rs->ram_bitmap; atomic_rcu_set(&rs->ram_bitmap, NULL); if (bitmap) { memory_global_dirty_log_stop(); @@ -1502,8 +1502,8 @@ void migration_bitmap_extend(ram_addr_t old, ram_addr= _t new) * no writing race against this migration_bitmap */ if (rs->ram_bitmap) { - struct RAMBitmap *old_bitmap =3D rs->ram_bitmap, *bitmap; - bitmap =3D g_new(struct RAMBitmap, 1); + RAMBitmap *old_bitmap =3D rs->ram_bitmap, *bitmap; + bitmap =3D g_new(RAMBitmap, 1); bitmap->bmap =3D bitmap_new(new); =20 /* prevent migration_bitmap content from being set bit @@ -1993,7 +1993,7 @@ static int ram_state_init(RAMState *rs) rcu_read_lock(); ram_state_reset(rs); =20 - rs->ram_bitmap =3D g_new0(struct RAMBitmap, 1); + rs->ram_bitmap =3D g_new0(RAMBitmap, 1); /* Skip setting bitmap if there is no RAM */ if (ram_bytes_total()) { ram_bitmap_pages =3D last_ram_page(); --=20 2.9.3 From nobody Fri May 3 08:55:08 2024 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 1490303985827724.896762409126; Thu, 23 Mar 2017 14:19:45 -0700 (PDT) Received: from localhost ([::1]:58707 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1crA92-0003vf-FC for importer@patchew.org; Thu, 23 Mar 2017 17:19:44 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:46116) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1cr9dQ-0000G2-CO for qemu-devel@nongnu.org; Thu, 23 Mar 2017 16:47:05 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1cr9dP-0000m2-Hm for qemu-devel@nongnu.org; Thu, 23 Mar 2017 16:47:04 -0400 Received: from mx1.redhat.com ([209.132.183.28]:60578) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1cr9dP-0000lO-Bf for qemu-devel@nongnu.org; Thu, 23 Mar 2017 16:47:03 -0400 Received: from smtp.corp.redhat.com (int-mx02.intmail.prod.int.phx2.redhat.com [10.5.11.12]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 50EC67E9CB for ; Thu, 23 Mar 2017 20:47:03 +0000 (UTC) Received: from secure.mitica (ovpn-116-230.ams2.redhat.com [10.36.116.230]) by smtp.corp.redhat.com (Postfix) with ESMTP id D96F777ECB; Thu, 23 Mar 2017 20:47:01 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mx1.redhat.com 50EC67E9CB Authentication-Results: ext-mx02.extmail.prod.ext.phx2.redhat.com; dmarc=none (p=none dis=none) header.from=redhat.com Authentication-Results: ext-mx02.extmail.prod.ext.phx2.redhat.com; spf=pass smtp.mailfrom=quintela@redhat.com DKIM-Filter: OpenDKIM Filter v2.11.0 mx1.redhat.com 50EC67E9CB From: Juan Quintela To: qemu-devel@nongnu.org Date: Thu, 23 Mar 2017 21:45:44 +0100 Message-Id: <20170323204544.12015-52-quintela@redhat.com> In-Reply-To: <20170323204544.12015-1-quintela@redhat.com> References: <20170323204544.12015-1-quintela@redhat.com> X-Scanned-By: MIMEDefang 2.79 on 10.5.11.12 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.26]); Thu, 23 Mar 2017 20:47: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 51/51] migration: Remove MigrationState parameter from migration_is_idle() 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: 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" Only user don't have a MigrationState handly. Signed-off-by: Juan Quintela Reviewed-by: Dr. David Alan Gilbert --- include/migration/migration.h | 2 +- migration/migration.c | 8 +++----- 2 files changed, 4 insertions(+), 6 deletions(-) diff --git a/include/migration/migration.h b/include/migration/migration.h index 39a8e7e..6f7221f 100644 --- a/include/migration/migration.h +++ b/include/migration/migration.h @@ -234,7 +234,7 @@ void remove_migration_state_change_notifier(Notifier *n= otify); MigrationState *migrate_init(const MigrationParams *params); bool migration_is_blocked(Error **errp); bool migration_in_setup(MigrationState *); -bool migration_is_idle(MigrationState *s); +bool migration_is_idle(void); bool migration_has_finished(MigrationState *); bool migration_has_failed(MigrationState *); /* True if outgoing migration has entered postcopy phase */ diff --git a/migration/migration.c b/migration/migration.c index fc19ba7..ba1d094 100644 --- a/migration/migration.c +++ b/migration/migration.c @@ -1067,11 +1067,9 @@ bool migration_in_postcopy_after_devices(MigrationSt= ate *s) return migration_in_postcopy() && s->postcopy_after_devices; } =20 -bool migration_is_idle(MigrationState *s) +bool migration_is_idle(void) { - if (!s) { - s =3D migrate_get_current(); - } + MigrationState *s =3D migrate_get_current(); =20 switch (s->state) { case MIGRATION_STATUS_NONE: @@ -1136,7 +1134,7 @@ int migrate_add_blocker(Error *reason, Error **errp) return -EACCES; } =20 - if (migration_is_idle(NULL)) { + if (migration_is_idle()) { migration_blockers =3D g_slist_prepend(migration_blockers, reason); return 0; } --=20 2.9.3