From nobody Thu May 2 09:51:37 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 1492776648392521.8919101759086; Fri, 21 Apr 2017 05:10:48 -0700 (PDT) Received: from localhost ([::1]:58858 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1d1XOg-0004gi-Pi for importer@patchew.org; Fri, 21 Apr 2017 08:10:46 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:44585) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1d1XBG-0001dD-T1 for qemu-devel@nongnu.org; Fri, 21 Apr 2017 07:56:58 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1d1XBD-000713-FQ for qemu-devel@nongnu.org; Fri, 21 Apr 2017 07:56:54 -0400 Received: from mx1.redhat.com ([209.132.183.28]:41868) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1d1XBD-00070u-5m for qemu-devel@nongnu.org; Fri, 21 Apr 2017 07:56: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 16031C056793 for ; Fri, 21 Apr 2017 11:56:50 +0000 (UTC) Received: from secure.com (ovpn-116-35.ams2.redhat.com [10.36.116.35]) by smtp.corp.redhat.com (Postfix) with ESMTP id 180A389F51; Fri, 21 Apr 2017 11:56:48 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mx1.redhat.com 16031C056793 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 16031C056793 From: Juan Quintela To: qemu-devel@nongnu.org Date: Fri, 21 Apr 2017 13:55:42 +0200 Message-Id: <20170421115646.15544-2-quintela@redhat.com> In-Reply-To: <20170421115646.15544-1-quintela@redhat.com> References: <20170421115646.15544-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]); Fri, 21 Apr 2017 11:56:50 +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] [PULL 01/65] 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 Reviewed-by: Peter Xu -- Fix Peter Xu comments Improve postcopy comments as per reviews. --- migration/ram.c | 348 ++++++++++++++++++++++++++++++++++++----------------= ---- 1 file changed, 227 insertions(+), 121 deletions(-) diff --git a/migration/ram.c b/migration/ram.c index de1e0a3..652abe4 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_throttle_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: pointer to the address of the page contents + * @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 dirty 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 + * be some left. in case that there is any page left, we drop it. + * + * @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 number 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_chunk_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_iterate: 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_postcopy_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_postcopy: 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 Thu May 2 09:51:37 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 1492775922090648.4192418514449; Fri, 21 Apr 2017 04:58:42 -0700 (PDT) Received: from localhost ([::1]:58798 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1d1XCy-00032b-Gp for importer@patchew.org; Fri, 21 Apr 2017 07:58:40 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:44560) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1d1XBG-0001cf-0w for qemu-devel@nongnu.org; Fri, 21 Apr 2017 07:56:54 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1d1XBE-00071T-SG for qemu-devel@nongnu.org; Fri, 21 Apr 2017 07:56:54 -0400 Received: from mx1.redhat.com ([209.132.183.28]:41918) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1d1XBE-000718-MI for qemu-devel@nongnu.org; Fri, 21 Apr 2017 07:56: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 98823C067C0A for ; Fri, 21 Apr 2017 11:56:51 +0000 (UTC) Received: from secure.com (ovpn-116-35.ams2.redhat.com [10.36.116.35]) by smtp.corp.redhat.com (Postfix) with ESMTP id 67B2783830; Fri, 21 Apr 2017 11:56:50 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mx1.redhat.com 98823C067C0A 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 98823C067C0A From: Juan Quintela To: qemu-devel@nongnu.org Date: Fri, 21 Apr 2017 13:55:43 +0200 Message-Id: <20170421115646.15544-3-quintela@redhat.com> In-Reply-To: <20170421115646.15544-1-quintela@redhat.com> References: <20170421115646.15544-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]); Fri, 21 Apr 2017 11:56: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] [PULL 02/65] ram: Rename flush_page_queue() to migration_page_queue_free() 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 reflects better what it does. Signed-off-by: Juan Quintela Reviewed-by: Dr. David Alan Gilbert Reviewed-by: Peter Xu --- include/migration/migration.h | 2 +- migration/migration.c | 2 +- migration/ram.c | 5 +++-- 3 files changed, 5 insertions(+), 4 deletions(-) diff --git a/include/migration/migration.h b/include/migration/migration.h index 5720c88..24487be 100644 --- a/include/migration/migration.h +++ b/include/migration/migration.h @@ -377,7 +377,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 migration_page_queue_free(MigrationState *ms); 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 ad4036f..4bee05d 100644 --- a/migration/migration.c +++ b/migration/migration.c @@ -955,7 +955,7 @@ static void migrate_fd_cleanup(void *opaque) qemu_bh_delete(s->cleanup_bh); s->cleanup_bh =3D NULL; =20 - flush_page_queue(s); + migration_page_queue_free(s); =20 if (s->to_dst_file) { trace_migrate_fd_cleanup(); diff --git a/migration/ram.c b/migration/ram.c index 652abe4..356f8ce 100644 --- a/migration/ram.c +++ b/migration/ram.c @@ -1186,14 +1186,15 @@ static bool get_queued_page(MigrationState *ms, Pag= eSearchStatus *pss, } =20 /** - * flush_page_queue: flush any remaining pages in the ram request queue + * migration_page_queue_free: drop 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. in case that there is any page left, we drop it. * * @ms: current migration state */ -void flush_page_queue(MigrationState *ms) +void migration_page_queue_free(MigrationState *ms) { struct MigrationSrcPageRequest *mspr, *next_mspr; /* This queue generally should be empty - but in the case of a failed --=20 2.9.3 From nobody Thu May 2 09:51:37 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 1492776074012190.71084539302535; Fri, 21 Apr 2017 05:01:14 -0700 (PDT) Received: from localhost ([::1]:58814 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1d1XFQ-0005Fe-Bs for importer@patchew.org; Fri, 21 Apr 2017 08:01:12 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:44589) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1d1XBG-0001dN-Vh for qemu-devel@nongnu.org; Fri, 21 Apr 2017 07:56:55 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1d1XBG-00072G-6t for qemu-devel@nongnu.org; Fri, 21 Apr 2017 07:56:55 -0400 Received: from mx1.redhat.com ([209.132.183.28]:53732) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1d1XBF-00071d-W8 for qemu-devel@nongnu.org; Fri, 21 Apr 2017 07:56: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 E3EC8935CF for ; Fri, 21 Apr 2017 11:56:52 +0000 (UTC) Received: from secure.com (ovpn-116-35.ams2.redhat.com [10.36.116.35]) by smtp.corp.redhat.com (Postfix) with ESMTP id E914F83830; Fri, 21 Apr 2017 11:56:51 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mx1.redhat.com E3EC8935CF 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 E3EC8935CF From: Juan Quintela To: qemu-devel@nongnu.org Date: Fri, 21 Apr 2017 13:55:44 +0200 Message-Id: <20170421115646.15544-4-quintela@redhat.com> In-Reply-To: <20170421115646.15544-1-quintela@redhat.com> References: <20170421115646.15544-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]); Fri, 21 Apr 2017 11:56: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] [PULL 03/65] 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 consistent on the naming 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 356f8ce..776f8a7 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 /** @@ -1943,25 +1943,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 Thu May 2 09:51:37 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 1492776797662323.3523633140686; Fri, 21 Apr 2017 05:13:17 -0700 (PDT) Received: from localhost ([::1]:58866 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1d1XR5-0006oe-Og for importer@patchew.org; Fri, 21 Apr 2017 08:13:15 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:44636) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1d1XBJ-0001fX-UA for qemu-devel@nongnu.org; Fri, 21 Apr 2017 07:57:00 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1d1XBH-00074s-L7 for qemu-devel@nongnu.org; Fri, 21 Apr 2017 07:56:57 -0400 Received: from mx1.redhat.com ([209.132.183.28]:53790) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1d1XBH-00072W-BC for qemu-devel@nongnu.org; Fri, 21 Apr 2017 07:56: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 3FEB883F45 for ; Fri, 21 Apr 2017 11:56:54 +0000 (UTC) Received: from secure.com (ovpn-116-35.ams2.redhat.com [10.36.116.35]) by smtp.corp.redhat.com (Postfix) with ESMTP id 42B9A89F52; Fri, 21 Apr 2017 11:56:53 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mx1.redhat.com 3FEB883F45 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 3FEB883F45 From: Juan Quintela To: qemu-devel@nongnu.org Date: Fri, 21 Apr 2017 13:55:45 +0200 Message-Id: <20170421115646.15544-5-quintela@redhat.com> In-Reply-To: <20170421115646.15544-1-quintela@redhat.com> References: <20170421115646.15544-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]); Fri, 21 Apr 2017 11:56: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] [PULL 04/65] 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 Reviewed-by: Peter Xu -- Fix typo and warnings --- migration/ram.c | 140 +++++++++++++++++++++++++++++++++-------------------= ---- 1 file changed, 83 insertions(+), 57 deletions(-) diff --git a/migration/ram.c b/migration/ram.c index 776f8a7..3eb4430 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 @@ -1283,6 +1301,7 @@ err: * * Returns the number 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 @@ -1290,7 +1309,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, @@ -1302,11 +1321,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 @@ -1322,7 +1341,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 @@ -1340,6 +1359,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 @@ -1347,7 +1367,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, @@ -1357,7 +1377,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; @@ -1380,6 +1400,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 @@ -1388,7 +1409,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; @@ -1403,8 +1424,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) { @@ -1413,22 +1434,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; } @@ -1510,13 +1531,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 */ @@ -1848,12 +1869,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; @@ -1972,7 +1994,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 @@ -2018,7 +2040,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 */ @@ -2065,11 +2087,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; } } @@ -2107,14 +2130,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 */ @@ -2127,7 +2151,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; @@ -2181,6 +2205,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())) { @@ -2195,7 +2221,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) { @@ -2779,5 +2805,5 @@ static SaveVMHandlers savevm_ram_handlers =3D { void ram_mig_init(void) { qemu_mutex_init(&XBZRLE.lock); - register_savevm_live(NULL, "ram", 0, 4, &savevm_ram_handlers, NULL); + register_savevm_live(NULL, "ram", 0, 4, &savevm_ram_handlers, &ram_sta= te); } --=20 2.9.3 From nobody Thu May 2 09:51:37 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 1492776237974835.9011349937364; Fri, 21 Apr 2017 05:03:57 -0700 (PDT) Received: from localhost ([::1]:58824 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1d1XI4-0007Qp-4s for importer@patchew.org; Fri, 21 Apr 2017 08:03:56 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:44652) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1d1XBK-0001g2-An for qemu-devel@nongnu.org; Fri, 21 Apr 2017 07:57:00 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1d1XBI-00076t-U3 for qemu-devel@nongnu.org; Fri, 21 Apr 2017 07:56:58 -0400 Received: from mx1.redhat.com ([209.132.183.28]:38478) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1d1XBI-00075b-KT for qemu-devel@nongnu.org; Fri, 21 Apr 2017 07:56: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 87C3FDB02F for ; Fri, 21 Apr 2017 11:56:55 +0000 (UTC) Received: from secure.com (ovpn-116-35.ams2.redhat.com [10.36.116.35]) by smtp.corp.redhat.com (Postfix) with ESMTP id 9307683830; Fri, 21 Apr 2017 11:56:54 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mx1.redhat.com 87C3FDB02F 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 87C3FDB02F From: Juan Quintela To: qemu-devel@nongnu.org Date: Fri, 21 Apr 2017 13:55:46 +0200 Message-Id: <20170421115646.15544-6-quintela@redhat.com> In-Reply-To: <20170421115646.15544-1-quintela@redhat.com> References: <20170421115646.15544-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]); Fri, 21 Apr 2017 11:56: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] [PULL 05/65] 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 3eb4430..a59140b 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; @@ -1920,7 +1920,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) { @@ -1998,7 +1998,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); @@ -2062,7 +2062,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(); @@ -2210,7 +2210,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); @@ -2243,6 +2243,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; @@ -2251,7 +2252,7 @@ static void ram_save_pending(QEMUFile *f, void *opaqu= e, uint64_t max_size, remaining_size < max_size) { qemu_mutex_lock_iothread(); rcu_read_lock(); - migration_bitmap_sync(); + migration_bitmap_sync(rs); rcu_read_unlock(); qemu_mutex_unlock_iothread(); remaining_size =3D ram_save_remaining() * TARGET_PAGE_SIZE; --=20 2.9.3 From nobody Thu May 2 09:51:37 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 1492776401118780.4780566827637; Fri, 21 Apr 2017 05:06:41 -0700 (PDT) Received: from localhost ([::1]:58837 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1d1XKh-0001Ac-LO for importer@patchew.org; Fri, 21 Apr 2017 08:06:39 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:44670) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1d1XBL-0001gO-At for qemu-devel@nongnu.org; Fri, 21 Apr 2017 07:57:00 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1d1XBK-00079D-7v for qemu-devel@nongnu.org; Fri, 21 Apr 2017 07:56:59 -0400 Received: from mx1.redhat.com ([209.132.183.28]:48044) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1d1XBJ-00077P-Vn for qemu-devel@nongnu.org; Fri, 21 Apr 2017 07:56: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 D18B46E780 for ; Fri, 21 Apr 2017 11:56:56 +0000 (UTC) Received: from secure.com (ovpn-116-35.ams2.redhat.com [10.36.116.35]) by smtp.corp.redhat.com (Postfix) with ESMTP id DACF283830; Fri, 21 Apr 2017 11:56:55 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mx1.redhat.com D18B46E780 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 D18B46E780 From: Juan Quintela To: qemu-devel@nongnu.org Date: Fri, 21 Apr 2017 13:55:47 +0200 Message-Id: <20170421115646.15544-7-quintela@redhat.com> In-Reply-To: <20170421115646.15544-1-quintela@redhat.com> References: <20170421115646.15544-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]); Fri, 21 Apr 2017 11:56: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] [PULL 06/65] 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 a59140b..935311d 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: pointer to the address of the page contents * @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 @@ -1999,7 +2000,7 @@ static int ram_save_init_globals(RAMState *rs) int64_t ram_bitmap_pages; /* Size of bitmap in pages, including gaps */ =20 rs->dirty_rate_high_cnt =3D 0; - bitmap_sync_count =3D 0; + rs->bitmap_sync_count =3D 0; migration_bitmap_sync_init(); qemu_mutex_init(&migration_bitmap_mutex); =20 --=20 2.9.3 From nobody Thu May 2 09:51:37 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 1492775933006624.1471322194053; Fri, 21 Apr 2017 04:58:53 -0700 (PDT) Received: from localhost ([::1]:58802 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1d1XD9-0003Bq-3N for importer@patchew.org; Fri, 21 Apr 2017 07:58:51 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:44686) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1d1XBM-0001hj-AA for qemu-devel@nongnu.org; Fri, 21 Apr 2017 07:57:04 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1d1XBL-0007Ax-Gx for qemu-devel@nongnu.org; Fri, 21 Apr 2017 07:57:00 -0400 Received: from mx1.redhat.com ([209.132.183.28]:38530) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1d1XBL-0007AE-8O for qemu-devel@nongnu.org; Fri, 21 Apr 2017 07:56: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 260B1A0BF6 for ; Fri, 21 Apr 2017 11:56:58 +0000 (UTC) Received: from secure.com (ovpn-116-35.ams2.redhat.com [10.36.116.35]) by smtp.corp.redhat.com (Postfix) with ESMTP id 2E6DF83830; Fri, 21 Apr 2017 11:56:57 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mx1.redhat.com 260B1A0BF6 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 260B1A0BF6 From: Juan Quintela To: qemu-devel@nongnu.org Date: Fri, 21 Apr 2017 13:55:48 +0200 Message-Id: <20170421115646.15544-8-quintela@redhat.com> In-Reply-To: <20170421115646.15544-1-quintela@redhat.com> References: <20170421115646.15544-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]); Fri, 21 Apr 2017 11:56: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] [PULL 07/65] 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 -- Renamed start_time to time_last_bitmap_sync(peterx suggestion) --- migration/ram.c | 20 +++++++++++--------- 1 file changed, 11 insertions(+), 9 deletions(-) diff --git a/migration/ram.c b/migration/ram.c index 935311d..53a547c 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; + /* these variables are used for bitmap sync */ + /* last time we did a full bitmap_sync */ + int64_t time_last_bitmap_sync; }; 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->time_last_bitmap_sync =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->time_last_bitmap_sync) { + rs->time_last_bitmap_sync =3D qemu_clock_get_ms(QEMU_CLOCK_REALTIM= E); } =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->time_last_bitmap_sync + 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->time_last_bitmap_sync); s->dirty_bytes_rate =3D s->dirty_pages_rate * TARGET_PAGE_SIZE; - start_time =3D end_time; + rs->time_last_bitmap_sync =3D end_time; num_dirty_pages_period =3D 0; } s->dirty_sync_count =3D rs->bitmap_sync_count; @@ -2001,7 +2003,7 @@ static int ram_save_init_globals(RAMState *rs) =20 rs->dirty_rate_high_cnt =3D 0; rs->bitmap_sync_count =3D 0; - migration_bitmap_sync_init(); + migration_bitmap_sync_init(rs); qemu_mutex_init(&migration_bitmap_mutex); =20 if (migrate_use_xbzrle()) { --=20 2.9.3 From nobody Thu May 2 09:51:37 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 1492776944417655.699491097241; Fri, 21 Apr 2017 05:15:44 -0700 (PDT) Received: from localhost ([::1]:58884 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1d1XTS-0000Xj-R6 for importer@patchew.org; Fri, 21 Apr 2017 08:15:42 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:44731) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1d1XBQ-0001lY-DX for qemu-devel@nongnu.org; Fri, 21 Apr 2017 07:57:05 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1d1XBM-0007D1-P4 for qemu-devel@nongnu.org; Fri, 21 Apr 2017 07:57:04 -0400 Received: from mx1.redhat.com ([209.132.183.28]:55424) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1d1XBM-0007Bc-Ia for qemu-devel@nongnu.org; Fri, 21 Apr 2017 07:57: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 6C07F7F7DE for ; Fri, 21 Apr 2017 11:56:59 +0000 (UTC) Received: from secure.com (ovpn-116-35.ams2.redhat.com [10.36.116.35]) by smtp.corp.redhat.com (Postfix) with ESMTP id 7685B83830; Fri, 21 Apr 2017 11:56:58 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mx1.redhat.com 6C07F7F7DE 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 6C07F7F7DE From: Juan Quintela To: qemu-devel@nongnu.org Date: Fri, 21 Apr 2017 13:55:49 +0200 Message-Id: <20170421115646.15544-9-quintela@redhat.com> In-Reply-To: <20170421115646.15544-1-quintela@redhat.com> References: <20170421115646.15544-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]); Fri, 21 Apr 2017 11:56: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] [PULL 08/65] 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 53a547c..aeef563 100644 --- a/migration/ram.c +++ b/migration/ram.c @@ -157,6 +157,8 @@ struct RAMState { /* these variables are used for bitmap sync */ /* last time we did a full bitmap_sync */ int64_t time_last_bitmap_sync; + /* 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->time_last_bitmap_sync =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->time_last_bitmap_sync) { @@ -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 Thu May 2 09:51:37 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 1492776412033525.2021966704913; Fri, 21 Apr 2017 05:06:52 -0700 (PDT) Received: from localhost ([::1]:58840 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1d1XKs-0001JF-Jl for importer@patchew.org; Fri, 21 Apr 2017 08:06:50 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:44764) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1d1XBS-0001nc-3x for qemu-devel@nongnu.org; Fri, 21 Apr 2017 07:57:07 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1d1XBO-0007Dz-78 for qemu-devel@nongnu.org; Fri, 21 Apr 2017 07:57:06 -0400 Received: from mx1.redhat.com ([209.132.183.28]:51734) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1d1XBO-0007DM-0x for qemu-devel@nongnu.org; Fri, 21 Apr 2017 07:57: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 E447571096 for ; Fri, 21 Apr 2017 11:57:00 +0000 (UTC) Received: from secure.com (ovpn-116-35.ams2.redhat.com [10.36.116.35]) by smtp.corp.redhat.com (Postfix) with ESMTP id BEB7083830; Fri, 21 Apr 2017 11:56:59 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mx1.redhat.com E447571096 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 E447571096 From: Juan Quintela To: qemu-devel@nongnu.org Date: Fri, 21 Apr 2017 13:55:50 +0200 Message-Id: <20170421115646.15544-10-quintela@redhat.com> In-Reply-To: <20170421115646.15544-1-quintela@redhat.com> References: <20170421115646.15544-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]); Fri, 21 Apr 2017 11:57: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] [PULL 09/65] ram: Change byte_xfer_{prev, now} type to uint64_t 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 | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/migration/ram.c b/migration/ram.c index aeef563..d13674f 100644 --- a/migration/ram.c +++ b/migration/ram.c @@ -158,7 +158,7 @@ struct RAMState { /* last time we did a full bitmap_sync */ int64_t time_last_bitmap_sync; /* bytes transferred at start_time */ - int64_t bytes_xfer_prev; + uint64_t bytes_xfer_prev; }; typedef struct RAMState RAMState; =20 @@ -660,7 +660,7 @@ static void migration_bitmap_sync(RAMState *rs) RAMBlock *block; MigrationState *s =3D migrate_get_current(); int64_t end_time; - int64_t bytes_xfer_now; + uint64_t bytes_xfer_now; =20 rs->bitmap_sync_count++; =20 --=20 2.9.3 From nobody Thu May 2 09:51:37 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 1492776089267104.71483609108589; Fri, 21 Apr 2017 05:01:29 -0700 (PDT) Received: from localhost ([::1]:58818 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1d1XFd-0005PJ-2G for importer@patchew.org; Fri, 21 Apr 2017 08:01:25 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:44734) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1d1XBQ-0001lr-Kp for qemu-devel@nongnu.org; Fri, 21 Apr 2017 07:57:05 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1d1XBP-0007E9-J9 for qemu-devel@nongnu.org; Fri, 21 Apr 2017 07:57:04 -0400 Received: from mx1.redhat.com ([209.132.183.28]:38594) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1d1XBP-0007E4-AB for qemu-devel@nongnu.org; Fri, 21 Apr 2017 07:57: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 37CC3B083A for ; Fri, 21 Apr 2017 11:57:02 +0000 (UTC) Received: from secure.com (ovpn-116-35.ams2.redhat.com [10.36.116.35]) by smtp.corp.redhat.com (Postfix) with ESMTP id 4326083830; Fri, 21 Apr 2017 11:57:01 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mx1.redhat.com 37CC3B083A 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 37CC3B083A From: Juan Quintela To: qemu-devel@nongnu.org Date: Fri, 21 Apr 2017 13:55:51 +0200 Message-Id: <20170421115646.15544-11-quintela@redhat.com> In-Reply-To: <20170421115646.15544-1-quintela@redhat.com> References: <20170421115646.15544-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]); Fri, 21 Apr 2017 11:57: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] [PULL 10/65] 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 d13674f..d6cf032 100644 --- a/migration/ram.c +++ b/migration/ram.c @@ -159,6 +159,8 @@ struct RAMState { int64_t time_last_bitmap_sync; /* bytes transferred at start_time */ uint64_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->time_last_bitmap_sync =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->time_last_bitmap_sync); s->dirty_bytes_rate =3D s->dirty_pages_rate * TARGET_PAGE_SIZE; rs->time_last_bitmap_sync =3D end_time; - num_dirty_pages_period =3D 0; + rs->num_dirty_pages_period =3D 0; } s->dirty_sync_count =3D rs->bitmap_sync_count; if (migrate_use_events()) { --=20 2.9.3 From nobody Thu May 2 09:51:37 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 1492776249718410.4840668843507; Fri, 21 Apr 2017 05:04:09 -0700 (PDT) Received: from localhost ([::1]:58827 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1d1XIG-0007bj-5c for importer@patchew.org; Fri, 21 Apr 2017 08:04:08 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:44755) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1d1XBR-0001n8-L9 for qemu-devel@nongnu.org; Fri, 21 Apr 2017 07:57:06 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1d1XBQ-0007EX-R8 for qemu-devel@nongnu.org; Fri, 21 Apr 2017 07:57:05 -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 1d1XBQ-0007EE-Lh for qemu-devel@nongnu.org; Fri, 21 Apr 2017 07:57:04 -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 911EA6E77F for ; Fri, 21 Apr 2017 11:57:03 +0000 (UTC) Received: from secure.com (ovpn-116-35.ams2.redhat.com [10.36.116.35]) by smtp.corp.redhat.com (Postfix) with ESMTP id 8904C83830; Fri, 21 Apr 2017 11:57:02 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mx1.redhat.com 911EA6E77F 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 911EA6E77F From: Juan Quintela To: qemu-devel@nongnu.org Date: Fri, 21 Apr 2017 13:55:52 +0200 Message-Id: <20170421115646.15544-12-quintela@redhat.com> In-Reply-To: <20170421115646.15544-1-quintela@redhat.com> References: <20170421115646.15544-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]); Fri, 21 Apr 2017 11:57: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] [PULL 11/65] ram: Change num_dirty_pages_period type to uint64_t 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/exec/ram_addr.h | 2 +- migration/ram.c | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/include/exec/ram_addr.h b/include/exec/ram_addr.h index b05dc84..9aadc5c 100644 --- a/include/exec/ram_addr.h +++ b/include/exec/ram_addr.h @@ -356,7 +356,7 @@ static inline uint64_t cpu_physical_memory_sync_dirty_bitmap(unsigned long *dest, ram_addr_t start, ram_addr_t length, - int64_t *real_dirty_pages) + uint64_t *real_dirty_pages) { ram_addr_t addr; unsigned long page =3D BIT_WORD(start >> TARGET_PAGE_BITS); diff --git a/migration/ram.c b/migration/ram.c index d6cf032..9a82355 100644 --- a/migration/ram.c +++ b/migration/ram.c @@ -160,7 +160,7 @@ struct RAMState { /* bytes transferred at start_time */ uint64_t bytes_xfer_prev; /* number of dirty pages since start_time */ - int64_t num_dirty_pages_period; + uint64_t num_dirty_pages_period; }; typedef struct RAMState RAMState; =20 --=20 2.9.3 From nobody Thu May 2 09:51:37 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 149277726205086.15283920429226; Fri, 21 Apr 2017 05:21:02 -0700 (PDT) Received: from localhost ([::1]:58906 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1d1XYa-0004lI-F4 for importer@patchew.org; Fri, 21 Apr 2017 08:21:00 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:44784) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1d1XBT-0001ou-5q for qemu-devel@nongnu.org; Fri, 21 Apr 2017 07:57:08 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1d1XBS-0007F1-6X for qemu-devel@nongnu.org; Fri, 21 Apr 2017 07:57:07 -0400 Received: from mx1.redhat.com ([209.132.183.28]:34426) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1d1XBS-0007Ee-06 for qemu-devel@nongnu.org; Fri, 21 Apr 2017 07:57: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 D9CD8341582 for ; Fri, 21 Apr 2017 11:57:04 +0000 (UTC) Received: from secure.com (ovpn-116-35.ams2.redhat.com [10.36.116.35]) by smtp.corp.redhat.com (Postfix) with ESMTP id E2AE389F47; Fri, 21 Apr 2017 11:57:03 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mx1.redhat.com D9CD8341582 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 D9CD8341582 From: Juan Quintela To: qemu-devel@nongnu.org Date: Fri, 21 Apr 2017 13:55:53 +0200 Message-Id: <20170421115646.15544-13-quintela@redhat.com> In-Reply-To: <20170421115646.15544-1-quintela@redhat.com> References: <20170421115646.15544-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.29]); Fri, 21 Apr 2017 11:57: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] [PULL 12/65] 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 9a82355..32b1cbb 100644 --- a/migration/ram.c +++ b/migration/ram.c @@ -161,6 +161,8 @@ struct RAMState { uint64_t bytes_xfer_prev; /* number of dirty pages since start_time */ uint64_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->time_last_bitmap_sync =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->time_last_bitmap_sync); --=20 2.9.3 From nobody Thu May 2 09:51:37 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 1492776558550263.7353968165604; Fri, 21 Apr 2017 05:09:18 -0700 (PDT) Received: from localhost ([::1]:58847 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1d1XNE-0003PS-VX for importer@patchew.org; Fri, 21 Apr 2017 08:09:17 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:44795) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1d1XBU-0001q1-5k for qemu-devel@nongnu.org; Fri, 21 Apr 2017 07:57:09 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1d1XBT-0007HS-Dq for qemu-devel@nongnu.org; Fri, 21 Apr 2017 07:57:08 -0400 Received: from mx1.redhat.com ([209.132.183.28]:53524) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1d1XBT-0007Fr-8l for qemu-devel@nongnu.org; Fri, 21 Apr 2017 07:57: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 2C8039C0D4 for ; Fri, 21 Apr 2017 11:57:06 +0000 (UTC) Received: from secure.com (ovpn-116-35.ams2.redhat.com [10.36.116.35]) by smtp.corp.redhat.com (Postfix) with ESMTP id 387AA83830; Fri, 21 Apr 2017 11:57:05 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mx1.redhat.com 2C8039C0D4 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 2C8039C0D4 From: Juan Quintela To: qemu-devel@nongnu.org Date: Fri, 21 Apr 2017 13:55:54 +0200 Message-Id: <20170421115646.15544-14-quintela@redhat.com> In-Reply-To: <20170421115646.15544-1-quintela@redhat.com> References: <20170421115646.15544-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]); Fri, 21 Apr 2017 11:57:06 +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] [PULL 13/65] 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 32b1cbb..5b6fef8 100644 --- a/migration/ram.c +++ b/migration/ram.c @@ -163,6 +163,8 @@ struct RAMState { uint64_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->time_last_bitmap_sync =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 Thu May 2 09:51:37 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 1492776706683880.7047806250662; Fri, 21 Apr 2017 05:11:46 -0700 (PDT) Received: from localhost ([::1]:58860 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1d1XPd-0005UL-05 for importer@patchew.org; Fri, 21 Apr 2017 08:11:45 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:44808) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1d1XBW-0001s7-90 for qemu-devel@nongnu.org; Fri, 21 Apr 2017 07:57:14 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1d1XBV-0007Ij-2e for qemu-devel@nongnu.org; Fri, 21 Apr 2017 07:57:10 -0400 Received: from mx1.redhat.com ([209.132.183.28]:59770) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1d1XBU-0007II-Q5 for qemu-devel@nongnu.org; Fri, 21 Apr 2017 07:57: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 A434CC04BD42 for ; Fri, 21 Apr 2017 11:57:07 +0000 (UTC) Received: from secure.com (ovpn-116-35.ams2.redhat.com [10.36.116.35]) by smtp.corp.redhat.com (Postfix) with ESMTP id 7EBB189F45; Fri, 21 Apr 2017 11:57:06 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mx1.redhat.com A434CC04BD42 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 A434CC04BD42 From: Juan Quintela To: qemu-devel@nongnu.org Date: Fri, 21 Apr 2017 13:55:55 +0200 Message-Id: <20170421115646.15544-15-quintela@redhat.com> In-Reply-To: <20170421115646.15544-1-quintela@redhat.com> References: <20170421115646.15544-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]); Fri, 21 Apr 2017 11:57: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] [PULL 14/65] 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 5b6fef8..cdd56b7 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); @@ -1463,8 +1467,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; @@ -2006,6 +2012,7 @@ static int ram_save_init_globals(RAMState *rs) =20 rs->dirty_rate_high_cnt =3D 0; rs->bitmap_sync_count =3D 0; + rs->zero_pages =3D 0; migration_bitmap_sync_init(rs); qemu_mutex_init(&migration_bitmap_mutex); =20 --=20 2.9.3 From nobody Thu May 2 09:51:37 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 1492776767622225.08743347669747; Fri, 21 Apr 2017 05:12:47 -0700 (PDT) Received: from localhost ([::1]:58863 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1d1XQc-0006PY-2o for importer@patchew.org; Fri, 21 Apr 2017 08:12:46 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:44845) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1d1XBa-0001wd-9n for qemu-devel@nongnu.org; Fri, 21 Apr 2017 07:57:15 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1d1XBW-0007KA-D4 for qemu-devel@nongnu.org; Fri, 21 Apr 2017 07:57:14 -0400 Received: from mx1.redhat.com ([209.132.183.28]:35568) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1d1XBW-0007Jg-7p for qemu-devel@nongnu.org; Fri, 21 Apr 2017 07:57: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 2224A41A5E for ; Fri, 21 Apr 2017 11:57:09 +0000 (UTC) Received: from secure.com (ovpn-116-35.ams2.redhat.com [10.36.116.35]) by smtp.corp.redhat.com (Postfix) with ESMTP id 02B5889F45; Fri, 21 Apr 2017 11:57:07 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mx1.redhat.com 2224A41A5E 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 2224A41A5E From: Juan Quintela To: qemu-devel@nongnu.org Date: Fri, 21 Apr 2017 13:55:56 +0200 Message-Id: <20170421115646.15544-16-quintela@redhat.com> In-Reply-To: <20170421115646.15544-1-quintela@redhat.com> References: <20170421115646.15544-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]); Fri, 21 Apr 2017 11:57: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] [PULL 15/65] 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 24487be..f07700f 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 cdd56b7..1398597 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 Thu May 2 09:51:37 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 1492776624655442.6447134265329; Fri, 21 Apr 2017 05:10:24 -0700 (PDT) Received: from localhost ([::1]:58851 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1d1XOJ-0004K6-AF for importer@patchew.org; Fri, 21 Apr 2017 08:10:23 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:44843) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1d1XBa-0001wZ-9f for qemu-devel@nongnu.org; Fri, 21 Apr 2017 07:57:15 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1d1XBX-0007KV-QM for qemu-devel@nongnu.org; Fri, 21 Apr 2017 07:57:14 -0400 Received: from mx1.redhat.com ([209.132.183.28]:48196) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1d1XBX-0007KH-KX for qemu-devel@nongnu.org; Fri, 21 Apr 2017 07:57: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 6EA174C523 for ; Fri, 21 Apr 2017 11:57:10 +0000 (UTC) Received: from secure.com (ovpn-116-35.ams2.redhat.com [10.36.116.35]) by smtp.corp.redhat.com (Postfix) with ESMTP id 74C1489F45; Fri, 21 Apr 2017 11:57:09 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mx1.redhat.com 6EA174C523 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 6EA174C523 From: Juan Quintela To: qemu-devel@nongnu.org Date: Fri, 21 Apr 2017 13:55:57 +0200 Message-Id: <20170421115646.15544-17-quintela@redhat.com> In-Reply-To: <20170421115646.15544-1-quintela@redhat.com> References: <20170421115646.15544-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]); Fri, 21 Apr 2017 11:57: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] [PULL 16/65] 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 f07700f..bd0b60b 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 4bee05d..34c1a83 100644 --- a/migration/migration.c +++ b/migration/migration.c @@ -651,7 +651,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 1398597..78c7f3d 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 Thu May 2 09:51:37 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 1492776850332691.5750614574764; Fri, 21 Apr 2017 05:14:10 -0700 (PDT) Received: from localhost ([::1]:58868 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1d1XRw-0007Yg-Qu for importer@patchew.org; Fri, 21 Apr 2017 08:14:08 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:44844) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1d1XBa-0001wc-9m for qemu-devel@nongnu.org; Fri, 21 Apr 2017 07:57:15 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1d1XBZ-0007Lp-2M for qemu-devel@nongnu.org; Fri, 21 Apr 2017 07:57:14 -0400 Received: from mx1.redhat.com ([209.132.183.28]:48228) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1d1XBY-0007Kb-QE for qemu-devel@nongnu.org; Fri, 21 Apr 2017 07:57: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 AF8198E676 for ; Fri, 21 Apr 2017 11:57:11 +0000 (UTC) Received: from secure.com (ovpn-116-35.ams2.redhat.com [10.36.116.35]) by smtp.corp.redhat.com (Postfix) with ESMTP id BB26C83830; Fri, 21 Apr 2017 11:57:10 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mx1.redhat.com AF8198E676 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 AF8198E676 From: Juan Quintela To: qemu-devel@nongnu.org Date: Fri, 21 Apr 2017 13:55:58 +0200 Message-Id: <20170421115646.15544-18-quintela@redhat.com> In-Reply-To: <20170421115646.15544-1-quintela@redhat.com> References: <20170421115646.15544-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]); Fri, 21 Apr 2017 11:57: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] [PULL 17/65] 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 78c7f3d..587e2c7 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); @@ -1456,7 +1457,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); } @@ -1997,6 +1998,7 @@ static int ram_save_init_globals(RAMState *rs) rs->dirty_rate_high_cnt =3D 0; rs->bitmap_sync_count =3D 0; rs->zero_pages =3D 0; + rs->norm_pages =3D 0; migration_bitmap_sync_init(rs); qemu_mutex_init(&migration_bitmap_mutex); =20 --=20 2.9.3 From nobody Thu May 2 09:51:37 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 1492776913753210.82990755246044; Fri, 21 Apr 2017 05:15:13 -0700 (PDT) Received: from localhost ([::1]:58874 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1d1XSy-0008RA-3G for importer@patchew.org; Fri, 21 Apr 2017 08:15:12 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:44867) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1d1XBb-0001xQ-3g for qemu-devel@nongnu.org; Fri, 21 Apr 2017 07:57:15 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1d1XBa-0007Mq-9f for qemu-devel@nongnu.org; Fri, 21 Apr 2017 07:57:15 -0400 Received: from mx1.redhat.com ([209.132.183.28]:59918) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1d1XBa-0007Mb-3j for qemu-devel@nongnu.org; Fri, 21 Apr 2017 07:57: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 02836C04BD42 for ; Fri, 21 Apr 2017 11:57:13 +0000 (UTC) Received: from secure.com (ovpn-116-35.ams2.redhat.com [10.36.116.35]) by smtp.corp.redhat.com (Postfix) with ESMTP id 0E97189F45; Fri, 21 Apr 2017 11:57:11 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mx1.redhat.com 02836C04BD42 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 02836C04BD42 From: Juan Quintela To: qemu-devel@nongnu.org Date: Fri, 21 Apr 2017 13:55:59 +0200 Message-Id: <20170421115646.15544-19-quintela@redhat.com> In-Reply-To: <20170421115646.15544-1-quintela@redhat.com> References: <20170421115646.15544-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]); Fri, 21 Apr 2017 11:57: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] [PULL 18/65] 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 bd0b60b..87d0cc5 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 34c1a83..7f7bab9 100644 --- a/migration/migration.c +++ b/migration/migration.c @@ -654,7 +654,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 587e2c7..85d66ea 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 Thu May 2 09:51:37 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 1492777067683578.907967972379; Fri, 21 Apr 2017 05:17:47 -0700 (PDT) Received: from localhost ([::1]:58889 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1d1XVS-0002Ba-Be for importer@patchew.org; Fri, 21 Apr 2017 08:17:46 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:44894) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1d1XBc-0001zz-GY for qemu-devel@nongnu.org; Fri, 21 Apr 2017 07:57:17 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1d1XBb-0007NZ-Jb for qemu-devel@nongnu.org; Fri, 21 Apr 2017 07:57:16 -0400 Received: from mx1.redhat.com ([209.132.183.28]:35920) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1d1XBb-0007N7-Dd for qemu-devel@nongnu.org; Fri, 21 Apr 2017 07:57: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 463E141A5E for ; Fri, 21 Apr 2017 11:57:14 +0000 (UTC) Received: from secure.com (ovpn-116-35.ams2.redhat.com [10.36.116.35]) by smtp.corp.redhat.com (Postfix) with ESMTP id 5381983830; Fri, 21 Apr 2017 11:57:13 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mx1.redhat.com 463E141A5E 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 463E141A5E From: Juan Quintela To: qemu-devel@nongnu.org Date: Fri, 21 Apr 2017 13:56:00 +0200 Message-Id: <20170421115646.15544-20-quintela@redhat.com> In-Reply-To: <20170421115646.15544-1-quintela@redhat.com> References: <20170421115646.15544-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]); Fri, 21 Apr 2017 11:57: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] [PULL 19/65] 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 85d66ea..3e500ae 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 @@ -1994,6 +1995,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 @@ -2151,7 +2153,7 @@ static int ram_save_iterate(QEMUFile *f, void *opaque) done =3D 1; break; } - acct_info.iterations++; + rs->iterations++; =20 /* we want to check in the 1st loop, just in case it was the 1st t= ime and we had to sync the dirty bitmap. --=20 2.9.3 From nobody Thu May 2 09:51:37 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 1492776996421399.76054073428384; Fri, 21 Apr 2017 05:16:36 -0700 (PDT) Received: from localhost ([::1]:58886 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1d1XUJ-0001Fn-3t for importer@patchew.org; Fri, 21 Apr 2017 08:16:35 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:44918) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1d1XBe-00022C-IU for qemu-devel@nongnu.org; Fri, 21 Apr 2017 07:57:19 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1d1XBd-0007OH-MY for qemu-devel@nongnu.org; Fri, 21 Apr 2017 07:57:18 -0400 Received: from mx1.redhat.com ([209.132.183.28]:34678) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1d1XBd-0007OB-HM for qemu-devel@nongnu.org; Fri, 21 Apr 2017 07:57: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 6C9AD341ADC for ; Fri, 21 Apr 2017 11:57:16 +0000 (UTC) Received: from secure.com (ovpn-116-35.ams2.redhat.com [10.36.116.35]) by smtp.corp.redhat.com (Postfix) with ESMTP id 9A41183830; Fri, 21 Apr 2017 11:57:14 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mx1.redhat.com 6C9AD341ADC 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 6C9AD341ADC From: Juan Quintela To: qemu-devel@nongnu.org Date: Fri, 21 Apr 2017 13:56:01 +0200 Message-Id: <20170421115646.15544-21-quintela@redhat.com> In-Reply-To: <20170421115646.15544-1-quintela@redhat.com> References: <20170421115646.15544-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]); Fri, 21 Apr 2017 11:57:16 +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] [PULL 20/65] 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 --- migration/ram.c | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/migration/ram.c b/migration/ram.c index 3e500ae..4dc7869 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; @@ -1996,6 +1997,7 @@ static int ram_save_init_globals(RAMState *rs) rs->zero_pages =3D 0; rs->norm_pages =3D 0; rs->iterations =3D 0; + rs->xbzrle_bytes =3D 0; migration_bitmap_sync_init(rs); qemu_mutex_init(&migration_bitmap_mutex); =20 --=20 2.9.3 From nobody Thu May 2 09:51:37 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 1492777155421149.28915311122876; Fri, 21 Apr 2017 05:19:15 -0700 (PDT) Received: from localhost ([::1]:58894 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1d1XWr-0003LV-Rb for importer@patchew.org; Fri, 21 Apr 2017 08:19:13 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:44937) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1d1XBf-00023h-SG for qemu-devel@nongnu.org; Fri, 21 Apr 2017 07:57:23 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1d1XBe-0007OW-W2 for qemu-devel@nongnu.org; Fri, 21 Apr 2017 07:57:19 -0400 Received: from mx1.redhat.com ([209.132.183.28]:53798) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1d1XBe-0007ON-QP for qemu-devel@nongnu.org; Fri, 21 Apr 2017 07:57:18 -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 B33B6A1400 for ; Fri, 21 Apr 2017 11:57:17 +0000 (UTC) Received: from secure.com (ovpn-116-35.ams2.redhat.com [10.36.116.35]) by smtp.corp.redhat.com (Postfix) with ESMTP id BDF7483830; Fri, 21 Apr 2017 11:57:16 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mx1.redhat.com B33B6A1400 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 B33B6A1400 From: Juan Quintela To: qemu-devel@nongnu.org Date: Fri, 21 Apr 2017 13:56:02 +0200 Message-Id: <20170421115646.15544-22-quintela@redhat.com> In-Reply-To: <20170421115646.15544-1-quintela@redhat.com> References: <20170421115646.15544-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]); Fri, 21 Apr 2017 11:57: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] [PULL 21/65] 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 -- Comment why we need bytes and pages --- migration/ram.c | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/migration/ram.c b/migration/ram.c index 4dc7869..cf6681c 100644 --- a/migration/ram.c +++ b/migration/ram.c @@ -172,8 +172,11 @@ struct RAMState { uint64_t norm_pages; /* Iterations since start */ uint64_t iterations; - /* xbzrle transmitted bytes */ + /* xbzrle transmitted bytes. Notice that this is with + * compression, they can't be calculated from the pages */ uint64_t xbzrle_bytes; + /* xbzrle transmmited pages */ + uint64_t xbzrle_pages; }; typedef struct RAMState RAMState; =20 @@ -181,7 +184,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 +213,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 +546,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 @@ -1998,6 +2000,7 @@ static int ram_save_init_globals(RAMState *rs) rs->norm_pages =3D 0; rs->iterations =3D 0; rs->xbzrle_bytes =3D 0; + rs->xbzrle_pages =3D 0; migration_bitmap_sync_init(rs); qemu_mutex_init(&migration_bitmap_mutex); =20 --=20 2.9.3 From nobody Thu May 2 09:51:37 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 1492777379365730.7473168673222; Fri, 21 Apr 2017 05:22:59 -0700 (PDT) Received: from localhost ([::1]:58912 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1d1XaT-0006Nn-RK for importer@patchew.org; Fri, 21 Apr 2017 08:22:57 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:44992) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1d1XBj-00027i-UP for qemu-devel@nongnu.org; Fri, 21 Apr 2017 07:57:24 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1d1XBg-0007P4-9B for qemu-devel@nongnu.org; Fri, 21 Apr 2017 07:57:23 -0400 Received: from mx1.redhat.com ([209.132.183.28]:35996) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1d1XBg-0007Oo-3R for qemu-devel@nongnu.org; Fri, 21 Apr 2017 07:57: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 0482041A5E for ; Fri, 21 Apr 2017 11:57:19 +0000 (UTC) Received: from secure.com (ovpn-116-35.ams2.redhat.com [10.36.116.35]) by smtp.corp.redhat.com (Postfix) with ESMTP id 0F94C83830; Fri, 21 Apr 2017 11:57:17 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mx1.redhat.com 0482041A5E 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 0482041A5E From: Juan Quintela To: qemu-devel@nongnu.org Date: Fri, 21 Apr 2017 13:56:03 +0200 Message-Id: <20170421115646.15544-23-quintela@redhat.com> In-Reply-To: <20170421115646.15544-1-quintela@redhat.com> References: <20170421115646.15544-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]); Fri, 21 Apr 2017 11:57: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] [PULL 22/65] 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 cf6681c..b70db68 100644 --- a/migration/ram.c +++ b/migration/ram.c @@ -177,6 +177,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 @@ -184,7 +186,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; @@ -218,7 +219,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) @@ -498,7 +499,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) { @@ -699,12 +700,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->time_last_bitmap_sync); @@ -2001,6 +2002,7 @@ static int ram_save_init_globals(RAMState *rs) rs->iterations =3D 0; rs->xbzrle_bytes =3D 0; rs->xbzrle_pages =3D 0; + rs->xbzrle_cache_miss =3D 0; migration_bitmap_sync_init(rs); qemu_mutex_init(&migration_bitmap_mutex); =20 --=20 2.9.3 From nobody Thu May 2 09:51:37 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 1492777417006523.4478976984325; Fri, 21 Apr 2017 05:23:37 -0700 (PDT) Received: from localhost ([::1]:58916 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1d1Xb5-0006tj-K2 for importer@patchew.org; Fri, 21 Apr 2017 08:23:35 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:44991) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1d1XBj-00027g-Tw for qemu-devel@nongnu.org; Fri, 21 Apr 2017 07:57:24 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1d1XBh-0007PR-J2 for qemu-devel@nongnu.org; Fri, 21 Apr 2017 07:57:23 -0400 Received: from mx1.redhat.com ([209.132.183.28]:60160) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1d1XBh-0007PD-DK for qemu-devel@nongnu.org; Fri, 21 Apr 2017 07:57: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 4D571C00C7BC for ; Fri, 21 Apr 2017 11:57:20 +0000 (UTC) Received: from secure.com (ovpn-116-35.ams2.redhat.com [10.36.116.35]) by smtp.corp.redhat.com (Postfix) with ESMTP id 5537183830; Fri, 21 Apr 2017 11:57:19 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mx1.redhat.com 4D571C00C7BC 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 4D571C00C7BC From: Juan Quintela To: qemu-devel@nongnu.org Date: Fri, 21 Apr 2017 13:56:04 +0200 Message-Id: <20170421115646.15544-24-quintela@redhat.com> In-Reply-To: <20170421115646.15544-1-quintela@redhat.com> References: <20170421115646.15544-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]); Fri, 21 Apr 2017 11:57: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] [PULL 23/65] 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 b70db68..09f9eff 100644 --- a/migration/ram.c +++ b/migration/ram.c @@ -179,6 +179,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 @@ -186,7 +188,6 @@ static RAMState ram_state; =20 /* accounting for migration statistics */ typedef struct AccountingInfo { - double xbzrle_cache_miss_rate; uint64_t xbzrle_overflows; } AccountingInfo; =20 @@ -224,7 +225,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) @@ -699,7 +700,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); @@ -2003,6 +2004,7 @@ static int ram_save_init_globals(RAMState *rs) rs->xbzrle_bytes =3D 0; rs->xbzrle_pages =3D 0; rs->xbzrle_cache_miss =3D 0; + rs->xbzrle_cache_miss_rate =3D 0; migration_bitmap_sync_init(rs); qemu_mutex_init(&migration_bitmap_mutex); =20 --=20 2.9.3 From nobody Thu May 2 09:51:37 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 149277722623291.64968720032516; Fri, 21 Apr 2017 05:20:26 -0700 (PDT) Received: from localhost ([::1]:58898 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1d1XY0-0004EY-Ol for importer@patchew.org; Fri, 21 Apr 2017 08:20:24 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:44993) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1d1XBj-00027j-UP for qemu-devel@nongnu.org; Fri, 21 Apr 2017 07:57:24 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1d1XBi-0007Po-SV for qemu-devel@nongnu.org; Fri, 21 Apr 2017 07:57:24 -0400 Received: from mx1.redhat.com ([209.132.183.28]:36046) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1d1XBi-0007PW-MT for qemu-devel@nongnu.org; Fri, 21 Apr 2017 07:57:22 -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 8F98D13D15 for ; Fri, 21 Apr 2017 11:57:21 +0000 (UTC) Received: from secure.com (ovpn-116-35.ams2.redhat.com [10.36.116.35]) by smtp.corp.redhat.com (Postfix) with ESMTP id 9B9ED83830; Fri, 21 Apr 2017 11:57:20 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mx1.redhat.com 8F98D13D15 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 8F98D13D15 From: Juan Quintela To: qemu-devel@nongnu.org Date: Fri, 21 Apr 2017 13:56:05 +0200 Message-Id: <20170421115646.15544-25-quintela@redhat.com> In-Reply-To: <20170421115646.15544-1-quintela@redhat.com> References: <20170421115646.15544-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]); Fri, 21 Apr 2017 11:57: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] [PULL 24/65] 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 09f9eff..88392e4 100644 --- a/migration/ram.c +++ b/migration/ram.c @@ -181,23 +181,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; @@ -230,7 +220,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; @@ -528,7 +518,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); @@ -2005,6 +1995,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 @@ -2035,8 +2026,6 @@ static int ram_save_init_globals(RAMState *rs) XBZRLE.encoded_buf =3D NULL; return -1; } - - acct_clear(); } =20 /* For memory_global_dirty_log_start below. */ --=20 2.9.3 From nobody Thu May 2 09:51:37 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 1492777527874600.0707995382996; Fri, 21 Apr 2017 05:25:27 -0700 (PDT) Received: from localhost ([::1]:58923 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1d1Xcs-000063-Ab for importer@patchew.org; Fri, 21 Apr 2017 08:25:26 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:45037) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1d1XBm-0002B7-QR for qemu-devel@nongnu.org; Fri, 21 Apr 2017 07:57:27 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1d1XBl-0007Qz-QN for qemu-devel@nongnu.org; Fri, 21 Apr 2017 07:57:26 -0400 Received: from mx1.redhat.com ([209.132.183.28]:55812) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1d1XBl-0007Qd-HP for qemu-devel@nongnu.org; Fri, 21 Apr 2017 07:57: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 774B367BDC for ; Fri, 21 Apr 2017 11:57:24 +0000 (UTC) Received: from secure.com (ovpn-116-35.ams2.redhat.com [10.36.116.35]) by smtp.corp.redhat.com (Postfix) with ESMTP id E265C89F45; Fri, 21 Apr 2017 11:57:21 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mx1.redhat.com 774B367BDC 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 774B367BDC From: Juan Quintela To: qemu-devel@nongnu.org Date: Fri, 21 Apr 2017 13:56:06 +0200 Message-Id: <20170421115646.15544-26-quintela@redhat.com> In-Reply-To: <20170421115646.15544-1-quintela@redhat.com> References: <20170421115646.15544-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]); Fri, 21 Apr 2017 11:57: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] [PULL 25/65] 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 88392e4..71f8ef3 100644 --- a/migration/ram.c +++ b/migration/ram.c @@ -183,6 +183,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 @@ -223,8 +225,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 { @@ -582,7 +588,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; @@ -591,7 +597,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; } @@ -601,8 +607,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) @@ -1304,7 +1311,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, @@ -1454,11 +1461,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; @@ -1532,6 +1534,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 */ @@ -1557,7 +1560,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); } } @@ -1730,6 +1733,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; @@ -1827,7 +1831,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 @@ -2053,7 +2057,7 @@ static int ram_save_init_globals(RAMState *rs) * Count the total number of pages used by ram blocks not including any * gaps due to alignment or unplugs. */ - migration_dirty_pages =3D ram_bytes_total() >> TARGET_PAGE_BITS; + rs->migration_dirty_pages =3D ram_bytes_total() >> TARGET_PAGE_BITS; =20 memory_global_dirty_log_start(); migration_bitmap_sync(rs); --=20 2.9.3 From nobody Thu May 2 09:51:37 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 1492777562678999.0370795447661; Fri, 21 Apr 2017 05:26:02 -0700 (PDT) Received: from localhost ([::1]:58930 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1d1XdR-0000hT-49 for importer@patchew.org; Fri, 21 Apr 2017 08:26:01 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:45052) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1d1XBn-0002CN-Su for qemu-devel@nongnu.org; Fri, 21 Apr 2017 07:57:28 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1d1XBn-0007RY-1p for qemu-devel@nongnu.org; Fri, 21 Apr 2017 07:57:27 -0400 Received: from mx1.redhat.com ([209.132.183.28]:55832) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1d1XBm-0007R4-Rn for qemu-devel@nongnu.org; Fri, 21 Apr 2017 07:57:26 -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 BE4AD75ED1 for ; Fri, 21 Apr 2017 11:57:25 +0000 (UTC) Received: from secure.com (ovpn-116-35.ams2.redhat.com [10.36.116.35]) by smtp.corp.redhat.com (Postfix) with ESMTP id C7D2F83830; Fri, 21 Apr 2017 11:57:24 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mx1.redhat.com BE4AD75ED1 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 BE4AD75ED1 From: Juan Quintela To: qemu-devel@nongnu.org Date: Fri, 21 Apr 2017 13:56:07 +0200 Message-Id: <20170421115646.15544-27-quintela@redhat.com> In-Reply-To: <20170421115646.15544-1-quintela@redhat.com> References: <20170421115646.15544-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]); Fri, 21 Apr 2017 11:57: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] [PULL 26/65] 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 71f8ef3..42bb82f 100644 --- a/migration/ram.c +++ b/migration/ram.c @@ -612,15 +612,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->time_last_bitmap_sync =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 * @@ -1986,21 +1977,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()) { @@ -2090,7 +2071,7 @@ static int ram_save_setup(QEMUFile *f, void *opaque) =20 /* migration has already setup the bitmap, reuse it. */ if (!migration_in_colo_state()) { - if (ram_save_init_globals(rs) < 0) { + if (ram_state_init(rs) < 0) { return -1; } } --=20 2.9.3 From nobody Thu May 2 09:51:37 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 1492777675772999.2984167172433; Fri, 21 Apr 2017 05:27:55 -0700 (PDT) Received: from localhost ([::1]:58935 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1d1XfF-0002KM-7C for importer@patchew.org; Fri, 21 Apr 2017 08:27:53 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:45065) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1d1XBp-0002Do-Cq for qemu-devel@nongnu.org; Fri, 21 Apr 2017 07:57:33 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1d1XBo-0007Rx-Ei for qemu-devel@nongnu.org; Fri, 21 Apr 2017 07:57:29 -0400 Received: from mx1.redhat.com ([209.132.183.28]:52178) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1d1XBo-0007Rj-5Q for qemu-devel@nongnu.org; Fri, 21 Apr 2017 07:57: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 0F210709D3 for ; Fri, 21 Apr 2017 11:57:27 +0000 (UTC) Received: from secure.com (ovpn-116-35.ams2.redhat.com [10.36.116.35]) by smtp.corp.redhat.com (Postfix) with ESMTP id 1B19B83830; Fri, 21 Apr 2017 11:57:25 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mx1.redhat.com 0F210709D3 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 0F210709D3 From: Juan Quintela To: qemu-devel@nongnu.org Date: Fri, 21 Apr 2017 13:56:08 +0200 Message-Id: <20170421115646.15544-28-quintela@redhat.com> In-Reply-To: <20170421115646.15544-1-quintela@redhat.com> References: <20170421115646.15544-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]); Fri, 21 Apr 2017 11:57: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] [PULL 27/65] 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 42bb82f..23819cd 100644 --- a/migration/ram.c +++ b/migration/ram.c @@ -185,6 +185,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 @@ -230,8 +232,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 */ @@ -653,13 +653,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 @@ -1526,6 +1526,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 */ @@ -1539,7 +1540,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 @@ -1550,7 +1551,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); } @@ -1982,7 +1983,7 @@ static int ram_state_init(RAMState *rs) int64_t ram_bitmap_pages; /* Size of bitmap in pages, including gaps */ =20 memset(rs, 0, sizeof(*rs)); - qemu_mutex_init(&migration_bitmap_mutex); + qemu_mutex_init(&rs->bitmap_mutex); =20 if (migrate_use_xbzrle()) { XBZRLE_cache_lock(); --=20 2.9.3 From nobody Thu May 2 09:51:37 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 1492776009896385.1881468191492; Fri, 21 Apr 2017 05:00:09 -0700 (PDT) Received: from localhost ([::1]:58806 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1d1XEO-0004Iz-FT for importer@patchew.org; Fri, 21 Apr 2017 08:00:08 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:45097) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1d1XBt-0002IR-E6 for qemu-devel@nongnu.org; Fri, 21 Apr 2017 07:57:34 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1d1XBp-0007SH-Nq for qemu-devel@nongnu.org; Fri, 21 Apr 2017 07:57:33 -0400 Received: from mx1.redhat.com ([209.132.183.28]:34794) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1d1XBp-0007S2-F7 for qemu-devel@nongnu.org; Fri, 21 Apr 2017 07:57: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 57B00341599 for ; Fri, 21 Apr 2017 11:57:28 +0000 (UTC) Received: from secure.com (ovpn-116-35.ams2.redhat.com [10.36.116.35]) by smtp.corp.redhat.com (Postfix) with ESMTP id 6222089F45; Fri, 21 Apr 2017 11:57:27 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mx1.redhat.com 57B00341599 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 57B00341599 From: Juan Quintela To: qemu-devel@nongnu.org Date: Fri, 21 Apr 2017 13:56:09 +0200 Message-Id: <20170421115646.15544-29-quintela@redhat.com> In-Reply-To: <20170421115646.15544-1-quintela@redhat.com> References: <20170421115646.15544-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]); Fri, 21 Apr 2017 11:57: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] [PULL 28/65] 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 23819cd..f6ae17f 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 */ @@ -187,6 +200,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 @@ -243,18 +258,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; @@ -577,7 +580,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 { @@ -592,7 +595,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 @@ -606,7 +609,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); @@ -1149,14 +1152,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, @@ -1316,7 +1319,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); } @@ -1480,7 +1483,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); @@ -1489,11 +1492,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); @@ -1530,9 +1535,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 @@ -1550,7 +1555,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); @@ -1565,13 +1570,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) { @@ -1600,8 +1605,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; @@ -1636,11 +1642,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 @@ -1739,8 +1746,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 */ @@ -1898,15 +1905,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 @@ -1927,7 +1935,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 @@ -2022,16 +2030,16 @@ static int ram_state_init(RAMState *rs) bytes_transferred =3D 0; ram_state_reset(rs); =20 - migration_bitmap_rcu =3D g_new0(struct BitmapRcu, 1); + rs->ram_bitmap =3D g_new0(struct RAMBitmap, 1); /* Skip setting bitmap if there is no RAM */ if (ram_bytes_total()) { ram_bitmap_pages =3D last_ram_offset() >> TARGET_PAGE_BITS; - migration_bitmap_rcu->bmap =3D bitmap_new(ram_bitmap_pages); - bitmap_set(migration_bitmap_rcu->bmap, 0, ram_bitmap_pages); + rs->ram_bitmap->bmap =3D bitmap_new(ram_bitmap_pages); + bitmap_set(rs->ram_bitmap->bmap, 0, ram_bitmap_pages); =20 if (migrate_postcopy_ram()) { - migration_bitmap_rcu->unsentmap =3D bitmap_new(ram_bitmap_page= s); - bitmap_set(migration_bitmap_rcu->unsentmap, 0, ram_bitmap_page= s); + rs->ram_bitmap->unsentmap =3D bitmap_new(ram_bitmap_pages); + bitmap_set(rs->ram_bitmap->unsentmap, 0, ram_bitmap_pages); } } =20 --=20 2.9.3 From nobody Thu May 2 09:51:37 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 14927778174411022.7249179037982; Fri, 21 Apr 2017 05:30:17 -0700 (PDT) Received: from localhost ([::1]:58979 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1d1XhX-0004hE-QS for importer@patchew.org; Fri, 21 Apr 2017 08:30:15 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:45096) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1d1XBt-0002IQ-DU for qemu-devel@nongnu.org; Fri, 21 Apr 2017 07:57:34 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1d1XBr-0007Sd-3s for qemu-devel@nongnu.org; Fri, 21 Apr 2017 07:57:33 -0400 Received: from mx1.redhat.com ([209.132.183.28]:53914) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1d1XBq-0007SV-R2 for qemu-devel@nongnu.org; Fri, 21 Apr 2017 07:57:31 -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 BE220A202E for ; Fri, 21 Apr 2017 11:57:29 +0000 (UTC) Received: from secure.com (ovpn-116-35.ams2.redhat.com [10.36.116.35]) by smtp.corp.redhat.com (Postfix) with ESMTP id A9A8389F45; Fri, 21 Apr 2017 11:57:28 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mx1.redhat.com BE220A202E 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 BE220A202E From: Juan Quintela To: qemu-devel@nongnu.org Date: Fri, 21 Apr 2017 13:56:10 +0200 Message-Id: <20170421115646.15544-30-quintela@redhat.com> In-Reply-To: <20170421115646.15544-1-quintela@redhat.com> References: <20170421115646.15544-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]); Fri, 21 Apr 2017 11:57: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] [PULL 29/65] 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 f6ae17f..7fbaa52 100644 --- a/migration/ram.c +++ b/migration/ram.c @@ -198,6 +198,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 */ @@ -247,6 +249,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 */ @@ -871,9 +878,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 @@ -894,7 +899,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); } @@ -990,7 +995,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= */ @@ -1066,7 +1071,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; } } @@ -1450,7 +1455,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); } } @@ -1460,11 +1465,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; @@ -2027,7 +2027,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); @@ -2139,7 +2138,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; @@ -2161,7 +2160,7 @@ static int ram_save_iterate(QEMUFile *f, void *opaque) } i++; } - flush_compressed_data(f); + flush_compressed_data(rs, f); rcu_read_unlock(); =20 /* @@ -2171,7 +2170,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) { @@ -2210,14 +2209,14 @@ static int ram_save_complete(QEMUFile *f, void *opa= que) int pages; =20 pages =3D ram_find_and_save_block(rs, f, !migration_in_colo_state(= ), - &bytes_transferred); + &rs->bytes_transferred); /* no more blocks to sent */ if (pages =3D=3D 0) { break; } } =20 - flush_compressed_data(f); + flush_compressed_data(rs, f); ram_control_after_iterate(f, RAM_CONTROL_FINISH); =20 rcu_read_unlock(); --=20 2.9.3 From nobody Thu May 2 09:51:37 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 14927761719921014.5093449250057; Fri, 21 Apr 2017 05:02:51 -0700 (PDT) Received: from localhost ([::1]:58823 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1d1XH0-0006WU-Fe for importer@patchew.org; Fri, 21 Apr 2017 08:02:50 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:45111) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1d1XBu-0002Kc-5h for qemu-devel@nongnu.org; Fri, 21 Apr 2017 07:57:35 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1d1XBs-0007Sz-Lz for qemu-devel@nongnu.org; Fri, 21 Apr 2017 07:57:34 -0400 Received: from mx1.redhat.com ([209.132.183.28]:42638) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1d1XBs-0007Sm-DE for qemu-devel@nongnu.org; Fri, 21 Apr 2017 07:57: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 48978C037F6A for ; Fri, 21 Apr 2017 11:57:31 +0000 (UTC) Received: from secure.com (ovpn-116-35.ams2.redhat.com [10.36.116.35]) by smtp.corp.redhat.com (Postfix) with ESMTP id 1CC3884BF6; Fri, 21 Apr 2017 11:57:29 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mx1.redhat.com 48978C037F6A 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 48978C037F6A From: Juan Quintela To: qemu-devel@nongnu.org Date: Fri, 21 Apr 2017 13:56:11 +0200 Message-Id: <20170421115646.15544-31-quintela@redhat.com> In-Reply-To: <20170421115646.15544-1-quintela@redhat.com> References: <20170421115646.15544-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]); Fri, 21 Apr 2017 11:57:31 +0000 (UTC) X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] [fuzzy] X-Received-From: 209.132.183.28 Subject: [Qemu-devel] [PULL 30/65] 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: Dr. David Alan Gilbert 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 7fbaa52..cd7226e 100644 --- a/migration/ram.c +++ b/migration/ram.c @@ -495,12 +495,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; @@ -556,7 +554,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; } @@ -728,20 +726,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 @@ -772,11 +768,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; @@ -794,7 +788,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 @@ -814,7 +808,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 @@ -824,7 +818,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 @@ -836,7 +830,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, @@ -845,7 +839,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++; } @@ -913,8 +907,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 @@ -931,7 +924,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; } } @@ -957,12 +950,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; @@ -976,7 +967,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) { @@ -996,7 +987,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 | @@ -1004,7 +995,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 { @@ -1017,10 +1008,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); } @@ -1298,13 +1288,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; @@ -1313,12 +1301,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) { @@ -1356,13 +1341,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; @@ -1370,7 +1353,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; } @@ -1395,14 +1378,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(); @@ -1434,8 +1415,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); @@ -2138,7 +2118,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; @@ -2208,8 +2188,7 @@ static int ram_save_complete(QEMUFile *f, void *opaqu= e) while (true) { int pages; =20 - pages =3D ram_find_and_save_block(rs, f, !migration_in_colo_state(= ), - &rs->bytes_transferred); + pages =3D ram_find_and_save_block(rs, f, !migration_in_colo_state(= )); /* no more blocks to sent */ if (pages =3D=3D 0) { break; --=20 2.9.3 From nobody Thu May 2 09:51:37 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 1492777708610800.9003887052023; Fri, 21 Apr 2017 05:28:28 -0700 (PDT) Received: from localhost ([::1]:58938 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1d1Xfm-0002py-1I for importer@patchew.org; Fri, 21 Apr 2017 08:28:26 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:45126) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1d1XBu-0002NC-OK for qemu-devel@nongnu.org; Fri, 21 Apr 2017 07:57:35 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1d1XBu-0007TZ-2q for qemu-devel@nongnu.org; Fri, 21 Apr 2017 07:57:34 -0400 Received: from mx1.redhat.com ([209.132.183.28]:60244) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1d1XBt-0007TA-U2 for qemu-devel@nongnu.org; Fri, 21 Apr 2017 07:57: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 D25DEC04B326 for ; Fri, 21 Apr 2017 11:57:32 +0000 (UTC) Received: from secure.com (ovpn-116-35.ams2.redhat.com [10.36.116.35]) by smtp.corp.redhat.com (Postfix) with ESMTP id 95E2E84BF6; Fri, 21 Apr 2017 11:57:31 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mx1.redhat.com D25DEC04B326 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 D25DEC04B326 From: Juan Quintela To: qemu-devel@nongnu.org Date: Fri, 21 Apr 2017 13:56:12 +0200 Message-Id: <20170421115646.15544-32-quintela@redhat.com> In-Reply-To: <20170421115646.15544-1-quintela@redhat.com> References: <20170421115646.15544-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]); Fri, 21 Apr 2017 11:57: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] [PULL 31/65] 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 cd7226e..2f5cbd1 100644 --- a/migration/ram.c +++ b/migration/ram.c @@ -244,16 +244,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 */ @@ -1440,11 +1440,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; @@ -2212,7 +2207,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) { @@ -2221,7 +2216,7 @@ static void ram_save_pending(QEMUFile *f, void *opaqu= e, uint64_t max_size, migration_bitmap_sync(rs); rcu_read_unlock(); qemu_mutex_unlock_iothread(); - remaining_size =3D ram_save_remaining() * TARGET_PAGE_SIZE; + remaining_size =3D rs->migration_dirty_pages * TARGET_PAGE_SIZE; } =20 /* We can do postcopy, and all the data is postcopiable */ --=20 2.9.3 From nobody Thu May 2 09:51:37 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 1492777977992874.973059449643; Fri, 21 Apr 2017 05:32:57 -0700 (PDT) Received: from localhost ([::1]:58995 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1d1Xk8-00072Q-CQ for importer@patchew.org; Fri, 21 Apr 2017 08:32:56 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:45164) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1d1XBy-0002Q6-0P for qemu-devel@nongnu.org; Fri, 21 Apr 2017 07:57:39 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1d1XBw-0007Vf-Pj for qemu-devel@nongnu.org; Fri, 21 Apr 2017 07:57:38 -0400 Received: from mx1.redhat.com ([209.132.183.28]:54458) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1d1XBw-0007VR-GB for qemu-devel@nongnu.org; Fri, 21 Apr 2017 07:57: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 5CBA4787F9 for ; Fri, 21 Apr 2017 11:57:35 +0000 (UTC) Received: from secure.com (ovpn-116-35.ams2.redhat.com [10.36.116.35]) by smtp.corp.redhat.com (Postfix) with ESMTP id 2EA4B84BF6; Fri, 21 Apr 2017 11:57:33 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mx1.redhat.com 5CBA4787F9 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 5CBA4787F9 From: Juan Quintela To: qemu-devel@nongnu.org Date: Fri, 21 Apr 2017 13:56:13 +0200 Message-Id: <20170421115646.15544-33-quintela@redhat.com> In-Reply-To: <20170421115646.15544-1-quintela@redhat.com> References: <20170421115646.15544-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]); Fri, 21 Apr 2017 11:57:35 +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] [PULL 32/65] 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 87d0cc5..0f75573 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 7f7bab9..c1730a0 100644 --- a/migration/migration.c +++ b/migration/migration.c @@ -1126,7 +1126,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 2f5cbd1..cec51b4 100644 --- a/migration/ram.c +++ b/migration/ram.c @@ -204,6 +204,8 @@ struct RAMState { QemuMutex bitmap_mutex; /* Ram Bitmap protected by RCU */ RAMBitmap *ram_bitmap; + /* The RAMBlock used in the last src_page_requests */ + RAMBlock *last_req_rb; }; typedef struct RAMState RAMState; =20 @@ -1226,12 +1228,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) { /* @@ -1249,7 +1252,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 Thu May 2 09:51:37 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 1492778136968538.7610759798582; Fri, 21 Apr 2017 05:35:36 -0700 (PDT) Received: from localhost ([::1]:59010 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1d1Xmh-0000oK-EN for importer@patchew.org; Fri, 21 Apr 2017 08:35:35 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:45196) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1d1XC3-0002Tp-0T for qemu-devel@nongnu.org; Fri, 21 Apr 2017 07:57:44 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1d1XBz-0007WC-2r for qemu-devel@nongnu.org; Fri, 21 Apr 2017 07:57:43 -0400 Received: from mx1.redhat.com ([209.132.183.28]:39230) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1d1XBy-0007Vu-QH for qemu-devel@nongnu.org; Fri, 21 Apr 2017 07:57:39 -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 AD3F5DF23C for ; Fri, 21 Apr 2017 11:57:37 +0000 (UTC) Received: from secure.com (ovpn-116-35.ams2.redhat.com [10.36.116.35]) by smtp.corp.redhat.com (Postfix) with ESMTP id ABF4D89F64; Fri, 21 Apr 2017 11:57:35 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mx1.redhat.com AD3F5DF23C 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 AD3F5DF23C From: Juan Quintela To: qemu-devel@nongnu.org Date: Fri, 21 Apr 2017 13:56:14 +0200 Message-Id: <20170421115646.15544-34-quintela@redhat.com> In-Reply-To: <20170421115646.15544-1-quintela@redhat.com> References: <20170421115646.15544-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]); Fri, 21 Apr 2017 11:57: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] [PULL 33/65] 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 | 61 +++++++++++++++++++++++++++------------= ---- 3 files changed, 40 insertions(+), 43 deletions(-) diff --git a/include/migration/migration.h b/include/migration/migration.h index 0f75573..084d195 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 migration_page_queue_free(MigrationState *ms); +void migration_page_queue_free(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 c1730a0..5918b21 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; @@ -957,7 +956,7 @@ static void migrate_fd_cleanup(void *opaque) qemu_bh_delete(s->cleanup_bh); s->cleanup_bh =3D NULL; =20 - migration_page_queue_free(s); + migration_page_queue_free(); =20 if (s->to_dst_file) { trace_migrate_fd_cleanup(); @@ -1131,8 +1130,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 cec51b4..be26d0c 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 */ @@ -206,6 +218,9 @@ struct RAMState { RAMBitmap *ram_bitmap; /* The RAMBlock used in the last src_page_requests */ 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 @@ -1085,20 +1100,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) & @@ -1109,11 +1124,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; } @@ -1126,13 +1141,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; @@ -1140,7 +1153,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 @@ -1194,18 +1207,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 * be some left. in case that there is any page left, we drop it. * - * @ms: current migration state */ -void migration_page_queue_free(MigrationState *ms) +void migration_page_queue_free(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(); @@ -1262,16 +1275,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; @@ -1410,7 +1423,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 */ @@ -1970,6 +1983,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 Thu May 2 09:51:37 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 1492778301006703.807721570605; Fri, 21 Apr 2017 05:38:21 -0700 (PDT) Received: from localhost ([::1]:59020 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1d1XpL-0002v2-MJ for importer@patchew.org; Fri, 21 Apr 2017 08:38:19 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:45214) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1d1XC8-0002Yo-6L for qemu-devel@nongnu.org; Fri, 21 Apr 2017 07:57:49 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1d1XC7-0007X1-9z for qemu-devel@nongnu.org; Fri, 21 Apr 2017 07:57:48 -0400 Received: from mx1.redhat.com ([209.132.183.28]:54636) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1d1XC7-0007Wv-1H for qemu-devel@nongnu.org; Fri, 21 Apr 2017 07:57:47 -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 EB6B7AB12A for ; Fri, 21 Apr 2017 11:57:45 +0000 (UTC) Received: from secure.com (ovpn-116-35.ams2.redhat.com [10.36.116.35]) by smtp.corp.redhat.com (Postfix) with ESMTP id 0B15A89F64; Fri, 21 Apr 2017 11:57:37 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mx1.redhat.com EB6B7AB12A 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 EB6B7AB12A From: Juan Quintela To: qemu-devel@nongnu.org Date: Fri, 21 Apr 2017 13:56:15 +0200 Message-Id: <20170421115646.15544-35-quintela@redhat.com> In-Reply-To: <20170421115646.15544-1-quintela@redhat.com> References: <20170421115646.15544-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]); Fri, 21 Apr 2017 11:57: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] [PULL 34/65] 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 084d195..2f9c973 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 5918b21..94647a8 100644 --- a/migration/migration.c +++ b/migration/migration.c @@ -656,7 +656,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) { @@ -1120,7 +1120,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 be26d0c..1580617 100644 --- a/migration/ram.c +++ b/migration/ram.c @@ -271,6 +271,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 */ @@ -727,7 +732,6 @@ static void migration_bitmap_sync(RAMState *rs) rs->time_last_bitmap_sync =3D end_time; rs->num_dirty_pages_period =3D 0; } - s->dirty_sync_count =3D rs->bitmap_sync_count; if (migrate_use_events()) { qapi_event_send_migration_pass(rs->bitmap_sync_count, NULL); } --=20 2.9.3 From nobody Thu May 2 09:51:37 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 1492776339112167.49673860365078; Fri, 21 Apr 2017 05:05:39 -0700 (PDT) Received: from localhost ([::1]:58836 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1d1XJh-0000Kb-MM for importer@patchew.org; Fri, 21 Apr 2017 08:05:37 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:45246) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1d1XCE-0002gV-0Q for qemu-devel@nongnu.org; Fri, 21 Apr 2017 07:57:55 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1d1XCA-0007Xz-3I for qemu-devel@nongnu.org; Fri, 21 Apr 2017 07:57:54 -0400 Received: from mx1.redhat.com ([209.132.183.28]:48896) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1d1XC9-0007Xc-Sv for qemu-devel@nongnu.org; Fri, 21 Apr 2017 07:57:50 -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 BC2568E697 for ; Fri, 21 Apr 2017 11:57:48 +0000 (UTC) Received: from secure.com (ovpn-116-35.ams2.redhat.com [10.36.116.35]) by smtp.corp.redhat.com (Postfix) with ESMTP id 4A94889F6B; Fri, 21 Apr 2017 11:57:46 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mx1.redhat.com BC2568E697 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 BC2568E697 From: Juan Quintela To: qemu-devel@nongnu.org Date: Fri, 21 Apr 2017 13:56:16 +0200 Message-Id: <20170421115646.15544-36-quintela@redhat.com> In-Reply-To: <20170421115646.15544-1-quintela@redhat.com> References: <20170421115646.15544-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]); Fri, 21 Apr 2017 11:57: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] [PULL 35/65] 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: Dr. David Alan Gilbert Reviewed-by: Peter Xu -- Dave was the one that reviewed it O:-) --- 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 2f9c973..e185d13 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 94647a8..dcf9b94 100644 --- a/migration/migration.c +++ b/migration/migration.c @@ -1118,7 +1118,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; @@ -2008,8 +2007,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 1580617..ef4f508 100644 --- a/migration/ram.c +++ b/migration/ram.c @@ -728,7 +728,6 @@ static void migration_bitmap_sync(RAMState *rs) } s->dirty_pages_rate =3D rs->num_dirty_pages_period * 1000 / (end_time - rs->time_last_bitmap_sync); - s->dirty_bytes_rate =3D s->dirty_pages_rate * TARGET_PAGE_SIZE; rs->time_last_bitmap_sync =3D end_time; rs->num_dirty_pages_period =3D 0; } --=20 2.9.3 From nobody Thu May 2 09:51:37 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 1492776495217637.4525630454114; Fri, 21 Apr 2017 05:08:15 -0700 (PDT) Received: from localhost ([::1]:58844 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1d1XMD-0002SS-OS for importer@patchew.org; Fri, 21 Apr 2017 08:08:13 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:45244) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1d1XCD-0002gT-Vf for qemu-devel@nongnu.org; Fri, 21 Apr 2017 07:57:55 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1d1XCC-0007YX-Uw for qemu-devel@nongnu.org; Fri, 21 Apr 2017 07:57:54 -0400 Received: from mx1.redhat.com ([209.132.183.28]:52446) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1d1XCC-0007YP-Lb for qemu-devel@nongnu.org; Fri, 21 Apr 2017 07:57: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 8E131711D2 for ; Fri, 21 Apr 2017 11:57:51 +0000 (UTC) Received: from secure.com (ovpn-116-35.ams2.redhat.com [10.36.116.35]) by smtp.corp.redhat.com (Postfix) with ESMTP id 15BC289F6B; Fri, 21 Apr 2017 11:57:48 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mx1.redhat.com 8E131711D2 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 8E131711D2 From: Juan Quintela To: qemu-devel@nongnu.org Date: Fri, 21 Apr 2017 13:56:17 +0200 Message-Id: <20170421115646.15544-37-quintela@redhat.com> In-Reply-To: <20170421115646.15544-1-quintela@redhat.com> References: <20170421115646.15544-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]); Fri, 21 Apr 2017 11:57: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] [PULL 36/65] 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: Dr. David Alan Gilbert Reviewed-by: Peter Xu -- Again, dave was the one reviewing it --- 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 e185d13..c4e3d42 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 dcf9b94..e430aec 100644 --- a/migration/migration.c +++ b/migration/migration.c @@ -661,7 +661,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 @@ -1117,7 +1117,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; @@ -2007,8 +2006,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 ef4f508..c5240eb 100644 --- a/migration/ram.c +++ b/migration/ram.c @@ -212,6 +212,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 */ @@ -276,6 +278,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 */ @@ -666,7 +673,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; uint64_t bytes_xfer_now; =20 @@ -705,7 +711,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)) { @@ -726,7 +732,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->time_last_bitmap_sync); rs->time_last_bitmap_sync =3D end_time; rs->num_dirty_pages_period =3D 0; --=20 2.9.3 From nobody Thu May 2 09:51:37 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 1492777314369791.8653332400285; Fri, 21 Apr 2017 05:21:54 -0700 (PDT) Received: from localhost ([::1]:58909 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1d1XZQ-0005Rg-Sb for importer@patchew.org; Fri, 21 Apr 2017 08:21:52 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:45322) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1d1XCH-0002js-FM for qemu-devel@nongnu.org; Fri, 21 Apr 2017 07:58:04 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1d1XCG-0007aJ-AJ for qemu-devel@nongnu.org; Fri, 21 Apr 2017 07:57:57 -0400 Received: from mx1.redhat.com ([209.132.183.28]:56480) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1d1XCG-0007Zs-15 for qemu-devel@nongnu.org; Fri, 21 Apr 2017 07:57: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 DE43475ED1 for ; Fri, 21 Apr 2017 11:57:54 +0000 (UTC) Received: from secure.com (ovpn-116-35.ams2.redhat.com [10.36.116.35]) by smtp.corp.redhat.com (Postfix) with ESMTP id E0F7589F77; Fri, 21 Apr 2017 11:57:51 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mx1.redhat.com DE43475ED1 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 DE43475ED1 From: Juan Quintela To: qemu-devel@nongnu.org Date: Fri, 21 Apr 2017 13:56:18 +0200 Message-Id: <20170421115646.15544-38-quintela@redhat.com> In-Reply-To: <20170421115646.15544-1-quintela@redhat.com> References: <20170421115646.15544-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]); Fri, 21 Apr 2017 11:57: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] [PULL 37/65] 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 c4e3d42..357eaa0 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 migration_page_queue_free(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 e430aec..2990c40 100644 --- a/migration/migration.c +++ b/migration/migration.c @@ -657,7 +657,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(); @@ -1120,7 +1120,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; @@ -1480,7 +1479,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 c5240eb..b9f415c 100644 --- a/migration/ram.c +++ b/migration/ram.c @@ -214,6 +214,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 */ @@ -283,6 +285,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 */ @@ -1240,19 +1247,17 @@ void migration_page_queue_free(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 Thu May 2 09:51:37 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 1492777462990174.63907520240969; Fri, 21 Apr 2017 05:24:22 -0700 (PDT) Received: from localhost ([::1]:58919 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1d1Xbp-0007ac-Hi for importer@patchew.org; Fri, 21 Apr 2017 08:24:21 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:45543) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1d1XCO-0002pk-J0 for qemu-devel@nongnu.org; Fri, 21 Apr 2017 07:58:05 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1d1XCI-0007cy-3r for qemu-devel@nongnu.org; Fri, 21 Apr 2017 07:58:04 -0400 Received: from mx1.redhat.com ([209.132.183.28]:35474) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1d1XCH-0007c6-RG for qemu-devel@nongnu.org; Fri, 21 Apr 2017 07:57: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 B0855335EAF for ; Fri, 21 Apr 2017 11:57:56 +0000 (UTC) Received: from secure.com (ovpn-116-35.ams2.redhat.com [10.36.116.35]) by smtp.corp.redhat.com (Postfix) with ESMTP id 3B3A589F57; Fri, 21 Apr 2017 11:57:55 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mx1.redhat.com B0855335EAF 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 B0855335EAF From: Juan Quintela To: qemu-devel@nongnu.org Date: Fri, 21 Apr 2017 13:56:19 +0200 Message-Id: <20170421115646.15544-39-quintela@redhat.com> In-Reply-To: <20170421115646.15544-1-quintela@redhat.com> References: <20170421115646.15544-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]); Fri, 21 Apr 2017 11:57: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] [PULL 38/65] 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 b9f415c..62b44cf 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 */ @@ -525,14 +527,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: pointer to the address of the page contents * @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) { @@ -583,10 +584,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; @@ -850,7 +852,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 @@ -2090,6 +2092,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 Thu May 2 09:51:37 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 1492778454982945.5178558057534; Fri, 21 Apr 2017 05:40:54 -0700 (PDT) Received: from localhost ([::1]:59054 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1d1Xrp-00055w-Fu for importer@patchew.org; Fri, 21 Apr 2017 08:40:53 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:45542) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1d1XCO-0002pj-IM for qemu-devel@nongnu.org; Fri, 21 Apr 2017 07:58:07 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1d1XCL-0007eD-80 for qemu-devel@nongnu.org; Fri, 21 Apr 2017 07:58:04 -0400 Received: from mx1.redhat.com ([209.132.183.28]:54894) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1d1XCK-0007dU-TG for qemu-devel@nongnu.org; Fri, 21 Apr 2017 07:58: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 C5CF383F45 for ; Fri, 21 Apr 2017 11:57:59 +0000 (UTC) Received: from secure.com (ovpn-116-35.ams2.redhat.com [10.36.116.35]) by smtp.corp.redhat.com (Postfix) with ESMTP id 0DEAB89F51; Fri, 21 Apr 2017 11:57:56 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mx1.redhat.com C5CF383F45 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 C5CF383F45 From: Juan Quintela To: qemu-devel@nongnu.org Date: Fri, 21 Apr 2017 13:56:20 +0200 Message-Id: <20170421115646.15544-40-quintela@redhat.com> In-Reply-To: <20170421115646.15544-1-quintela@redhat.com> References: <20170421115646.15544-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]); Fri, 21 Apr 2017 11:57: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] [PULL 39/65] 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 62b44cf..14d54fd 100644 --- a/migration/ram.c +++ b/migration/ram.c @@ -757,21 +757,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; } @@ -799,12 +798,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; @@ -820,7 +818,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; @@ -843,7 +841,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 @@ -865,14 +863,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; @@ -907,7 +905,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 @@ -927,7 +925,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); @@ -941,8 +939,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 @@ -952,7 +950,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); @@ -981,13 +979,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; @@ -999,7 +995,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; @@ -1021,20 +1017,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!"); } } @@ -1043,9 +1039,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); } @@ -1062,13 +1058,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, @@ -1096,7 +1091,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; } } @@ -1317,12 +1312,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) @@ -1333,9 +1327,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) { @@ -1370,12 +1364,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) @@ -1384,8 +1377,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; } @@ -1408,14 +1400,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(); @@ -1443,12 +1434,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 @@ -2148,7 +2138,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; @@ -2170,7 +2160,7 @@ static int ram_save_iterate(QEMUFile *f, void *opaque) } i++; } - flush_compressed_data(rs, f); + flush_compressed_data(rs); rcu_read_unlock(); =20 /* @@ -2218,14 +2208,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 Thu May 2 09:51:37 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 1492777607503429.99210552696616; Fri, 21 Apr 2017 05:26:47 -0700 (PDT) Received: from localhost ([::1]:58932 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1d1Xe9-0001Jp-Qb for importer@patchew.org; Fri, 21 Apr 2017 08:26:45 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:45546) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1d1XCO-0002pq-Ke for qemu-devel@nongnu.org; Fri, 21 Apr 2017 07:58:06 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1d1XCN-0007gY-IR for qemu-devel@nongnu.org; Fri, 21 Apr 2017 07:58:04 -0400 Received: from mx1.redhat.com ([209.132.183.28]:54710) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1d1XCN-0007fj-DB for qemu-devel@nongnu.org; Fri, 21 Apr 2017 07:58: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 4709D2EAAAA for ; Fri, 21 Apr 2017 11:58:02 +0000 (UTC) Received: from secure.com (ovpn-116-35.ams2.redhat.com [10.36.116.35]) by smtp.corp.redhat.com (Postfix) with ESMTP id 1E61B89F4E; Fri, 21 Apr 2017 11:57:59 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mx1.redhat.com 4709D2EAAAA 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 4709D2EAAAA From: Juan Quintela To: qemu-devel@nongnu.org Date: Fri, 21 Apr 2017 13:56:21 +0200 Message-Id: <20170421115646.15544-41-quintela@redhat.com> In-Reply-To: <20170421115646.15544-1-quintela@redhat.com> References: <20170421115646.15544-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]); Fri, 21 Apr 2017 11:58: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] [PULL 40/65] ram: Remove compression_switch and inline its logic 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 can calculate its value, so we don't create a variable for it. Signed-off-by: Juan Quintela Reviewed-by: Dr. David Alan Gilbert -- After Peter and Dave review, I dropped the variable and just inlined the condition. Fix typo --- migration/ram.c | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/migration/ram.c b/migration/ram.c index 14d54fd..fa5a290 100644 --- a/migration/ram.c +++ b/migration/ram.c @@ -336,7 +336,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; @@ -420,7 +419,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); @@ -1092,7 +1090,6 @@ 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; } } /* Didn't find anything this time, but try again on the new block = */ @@ -1326,7 +1323,14 @@ static int ram_save_target_page(RAMState *rs, Migrat= ionState *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 xbzrle is on, stop using the data compression after first + * round of migration even if compression is enabled. In theory, + * xbzrle can do better than compression. + */ + + if (migrate_use_compression() + && (rs->ram_bulk_stage || !migrate_use_xbzrle())) { 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 Thu May 2 09:51:37 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 1492777754178688.1966573445941; Fri, 21 Apr 2017 05:29:14 -0700 (PDT) Received: from localhost ([::1]:58940 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1d1XgW-0003dB-Jd for importer@patchew.org; Fri, 21 Apr 2017 08:29:12 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:45621) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1d1XCR-0002si-E9 for qemu-devel@nongnu.org; Fri, 21 Apr 2017 07:58:08 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1d1XCQ-0007ib-33 for qemu-devel@nongnu.org; Fri, 21 Apr 2017 07:58:07 -0400 Received: from mx1.redhat.com ([209.132.183.28]:54758) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1d1XCP-0007i2-Ov for qemu-devel@nongnu.org; Fri, 21 Apr 2017 07:58: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 B077FA2044 for ; Fri, 21 Apr 2017 11:58:04 +0000 (UTC) Received: from secure.com (ovpn-116-35.ams2.redhat.com [10.36.116.35]) by smtp.corp.redhat.com (Postfix) with ESMTP id 983F389F4E; Fri, 21 Apr 2017 11:58:02 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mx1.redhat.com B077FA2044 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 B077FA2044 From: Juan Quintela To: qemu-devel@nongnu.org Date: Fri, 21 Apr 2017 13:56:22 +0200 Message-Id: <20170421115646.15544-42-quintela@redhat.com> In-Reply-To: <20170421115646.15544-1-quintela@redhat.com> References: <20170421115646.15544-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]); Fri, 21 Apr 2017 11:58:04 +0000 (UTC) X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] [fuzzy] X-Received-From: 209.132.183.28 Subject: [Qemu-devel] [PULL 41/65] 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 357eaa0..2cd2007 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 2990c40..7da16cf 100644 --- a/migration/migration.c +++ b/migration/migration.c @@ -1062,14 +1062,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 fa5a290..289d7eb 100644 --- a/migration/ram.c +++ b/migration/ram.c @@ -776,10 +776,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 @@ -845,9 +844,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) { @@ -866,7 +865,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); } @@ -896,8 +895,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; @@ -1033,7 +1031,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; @@ -1041,7 +1039,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); } } } @@ -2200,7 +2198,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 @@ -2238,7 +2236,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 Thu May 2 09:51:37 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 1492777902129138.32757747309586; Fri, 21 Apr 2017 05:31:42 -0700 (PDT) Received: from localhost ([::1]:58990 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1d1Xit-0005xm-MI for importer@patchew.org; Fri, 21 Apr 2017 08:31:39 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:45655) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1d1XCT-0002uB-4J for qemu-devel@nongnu.org; Fri, 21 Apr 2017 07:58:10 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1d1XCS-0007je-6u for qemu-devel@nongnu.org; Fri, 21 Apr 2017 07:58:09 -0400 Received: from mx1.redhat.com ([209.132.183.28]:32944) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1d1XCR-0007jL-VC for qemu-devel@nongnu.org; Fri, 21 Apr 2017 07:58:08 -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 E4DE1C04F4BF for ; Fri, 21 Apr 2017 11:58:06 +0000 (UTC) Received: from secure.com (ovpn-116-35.ams2.redhat.com [10.36.116.35]) by smtp.corp.redhat.com (Postfix) with ESMTP id 0EAEA96521; Fri, 21 Apr 2017 11:58:04 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mx1.redhat.com E4DE1C04F4BF 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 E4DE1C04F4BF From: Juan Quintela To: qemu-devel@nongnu.org Date: Fri, 21 Apr 2017 13:56:23 +0200 Message-Id: <20170421115646.15544-43-quintela@redhat.com> In-Reply-To: <20170421115646.15544-1-quintela@redhat.com> References: <20170421115646.15544-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]); Fri, 21 Apr 2017 11:58: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] [PULL 42/65] 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 289d7eb..fe01e7b 100644 --- a/migration/ram.c +++ b/migration/ram.c @@ -794,13 +794,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; @@ -974,13 +972,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; @@ -1311,10 +1308,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 @@ -1329,9 +1324,9 @@ static int ram_save_target_page(RAMState *rs, Migrati= onState *ms, =20 if (migrate_use_compression() && (rs->ram_bulk_stage || !migrate_use_xbzrle())) { - 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) { @@ -1370,8 +1365,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) { @@ -1379,7 +1373,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; } @@ -1411,7 +1405,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 @@ -1440,7 +1433,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 Thu May 2 09:51:37 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 1492778063411223.09247272540654; Fri, 21 Apr 2017 05:34:23 -0700 (PDT) Received: from localhost ([::1]:59000 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1d1XlV-0008A8-Fz for importer@patchew.org; Fri, 21 Apr 2017 08:34:21 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:45751) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1d1XCd-00032Q-56 for qemu-devel@nongnu.org; Fri, 21 Apr 2017 07:58:20 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1d1XCZ-0007mO-9l for qemu-devel@nongnu.org; Fri, 21 Apr 2017 07:58:19 -0400 Received: from mx1.redhat.com ([209.132.183.28]:37184) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1d1XCZ-0007lz-0z for qemu-devel@nongnu.org; Fri, 21 Apr 2017 07:58: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 E93008DEF2 for ; Fri, 21 Apr 2017 11:58:13 +0000 (UTC) Received: from secure.com (ovpn-116-35.ams2.redhat.com [10.36.116.35]) by smtp.corp.redhat.com (Postfix) with ESMTP id 424ED89F47; Fri, 21 Apr 2017 11:58:07 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mx1.redhat.com E93008DEF2 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 E93008DEF2 From: Juan Quintela To: qemu-devel@nongnu.org Date: Fri, 21 Apr 2017 13:56:24 +0200 Message-Id: <20170421115646.15544-44-quintela@redhat.com> In-Reply-To: <20170421115646.15544-1-quintela@redhat.com> References: <20170421115646.15544-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]); Fri, 21 Apr 2017 11:58: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] [PULL 43/65] 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 c97ef4a..7a640c7 100644 --- a/exec.c +++ b/exec.c @@ -3307,9 +3307,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 7da16cf..92a3754 100644 --- a/migration/migration.c +++ b/migration/migration.c @@ -654,7 +654,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(); @@ -2009,7 +2009,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 Thu May 2 09:51:37 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 1492778225810826.5926711094168; Fri, 21 Apr 2017 05:37:05 -0700 (PDT) Received: from localhost ([::1]:59016 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1d1Xo8-0001vv-8B for importer@patchew.org; Fri, 21 Apr 2017 08:37:04 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:45769) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1d1XCf-000347-2d for qemu-devel@nongnu.org; Fri, 21 Apr 2017 07:58:22 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1d1XCe-0007n3-45 for qemu-devel@nongnu.org; Fri, 21 Apr 2017 07:58:21 -0400 Received: from mx1.redhat.com ([209.132.183.28]:36220) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1d1XCd-0007mp-UN for qemu-devel@nongnu.org; Fri, 21 Apr 2017 07:58: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 BF3C1341AD5; Fri, 21 Apr 2017 11:58:18 +0000 (UTC) Received: from secure.com (ovpn-116-35.ams2.redhat.com [10.36.116.35]) by smtp.corp.redhat.com (Postfix) with ESMTP id 3B60489F52; Fri, 21 Apr 2017 11:58:14 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mx1.redhat.com BF3C1341AD5 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 BF3C1341AD5 From: Juan Quintela To: qemu-devel@nongnu.org Date: Fri, 21 Apr 2017 13:56:25 +0200 Message-Id: <20170421115646.15544-45-quintela@redhat.com> In-Reply-To: <20170421115646.15544-1-quintela@redhat.com> References: <20170421115646.15544-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]); Fri, 21 Apr 2017 11:58:18 +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] [PULL 44/65] ram: 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 is output 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 Reviewed-by: Eric Blake Signed-off-by: Juan Quintela --- 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 92a3754..156daf9 100644 --- a/migration/migration.c +++ b/migration/migration.c @@ -658,6 +658,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 250e4dc..01b087f 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 Thu May 2 09:51:37 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 1492778603404883.19864162351; Fri, 21 Apr 2017 05:43:23 -0700 (PDT) Received: from localhost ([::1]:59067 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1d1XuD-0007HW-Vq for importer@patchew.org; Fri, 21 Apr 2017 08:43:22 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:45781) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1d1XCj-000382-13 for qemu-devel@nongnu.org; Fri, 21 Apr 2017 07:58:29 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1d1XCi-0007nR-7t for qemu-devel@nongnu.org; Fri, 21 Apr 2017 07:58:25 -0400 Received: from mx1.redhat.com ([209.132.183.28]:55510) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1d1XCi-0007nL-2K for qemu-devel@nongnu.org; Fri, 21 Apr 2017 07:58: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 EDE56A13E3 for ; Fri, 21 Apr 2017 11:58:22 +0000 (UTC) Received: from secure.com (ovpn-116-35.ams2.redhat.com [10.36.116.35]) by smtp.corp.redhat.com (Postfix) with ESMTP id 1B97389F52; Fri, 21 Apr 2017 11:58:18 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mx1.redhat.com EDE56A13E3 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 EDE56A13E3 From: Juan Quintela To: qemu-devel@nongnu.org Date: Fri, 21 Apr 2017 13:56:26 +0200 Message-Id: <20170421115646.15544-46-quintela@redhat.com> In-Reply-To: <20170421115646.15544-1-quintela@redhat.com> References: <20170421115646.15544-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]); Fri, 21 Apr 2017 11:58:23 +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] [PULL 45/65] 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 Reviewed-by: Dr. David Alan Gilbert --- 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 9aadc5c..8a1372c 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, uint64_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 fe01e7b..3f3842a 100644 --- a/migration/ram.c +++ b/migration/ram.c @@ -646,13 +646,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 @@ -699,7 +699,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 Thu May 2 09:51:37 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 1492776644221898.1106269241712; Fri, 21 Apr 2017 05:10:44 -0700 (PDT) Received: from localhost ([::1]:58857 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1d1XOc-0004dv-LI for importer@patchew.org; Fri, 21 Apr 2017 08:10:42 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:45797) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1d1XCn-0003Bg-3f for qemu-devel@nongnu.org; Fri, 21 Apr 2017 07:58:30 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1d1XCk-0007nq-US for qemu-devel@nongnu.org; Fri, 21 Apr 2017 07:58:29 -0400 Received: from mx1.redhat.com ([209.132.183.28]:17961) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1d1XCk-0007nd-LK for qemu-devel@nongnu.org; Fri, 21 Apr 2017 07:58:26 -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 864F3C0272DE for ; Fri, 21 Apr 2017 11:58:25 +0000 (UTC) Received: from secure.com (ovpn-116-35.ams2.redhat.com [10.36.116.35]) by smtp.corp.redhat.com (Postfix) with ESMTP id 4C91083830; Fri, 21 Apr 2017 11:58:23 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mx1.redhat.com 864F3C0272DE 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 864F3C0272DE From: Juan Quintela To: qemu-devel@nongnu.org Date: Fri, 21 Apr 2017 13:56:27 +0200 Message-Id: <20170421115646.15544-47-quintela@redhat.com> In-Reply-To: <20170421115646.15544-1-quintela@redhat.com> References: <20170421115646.15544-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]); Fri, 21 Apr 2017 11:58: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] [PULL 46/65] 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: 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 2cd2007..b84ec3d 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 3f3842a..9ed91e5 100644 --- a/migration/ram.c +++ b/migration/ram.c @@ -782,7 +782,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 /** @@ -1608,7 +1608,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); } @@ -1948,15 +1948,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 Thu May 2 09:51:37 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 1492776790240846.5730719347395; Fri, 21 Apr 2017 05:13:10 -0700 (PDT) Received: from localhost ([::1]:58865 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1d1XQy-0006id-4y for importer@patchew.org; Fri, 21 Apr 2017 08:13:08 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:45815) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1d1XCo-0003DN-L5 for qemu-devel@nongnu.org; Fri, 21 Apr 2017 07:58:31 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1d1XCn-0007o8-9Z for qemu-devel@nongnu.org; Fri, 21 Apr 2017 07:58:30 -0400 Received: from mx1.redhat.com ([209.132.183.28]:37902) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1d1XCm-0007ny-Ve for qemu-devel@nongnu.org; Fri, 21 Apr 2017 07:58: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 DC88C8DEFE for ; Fri, 21 Apr 2017 11:58:27 +0000 (UTC) Received: from secure.com (ovpn-116-35.ams2.redhat.com [10.36.116.35]) by smtp.corp.redhat.com (Postfix) with ESMTP id DA06096533; Fri, 21 Apr 2017 11:58:25 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mx1.redhat.com DC88C8DEFE 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 DC88C8DEFE From: Juan Quintela To: qemu-devel@nongnu.org Date: Fri, 21 Apr 2017 13:56:28 +0200 Message-Id: <20170421115646.15544-48-quintela@redhat.com> In-Reply-To: <20170421115646.15544-1-quintela@redhat.com> References: <20170421115646.15544-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]); Fri, 21 Apr 2017 11:58: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] [PULL 47/65] 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. We also set CONTINUE flag in a single place. 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 9ed91e5..1ef142f 100644 --- a/migration/ram.c +++ b/migration/ram.c @@ -451,18 +451,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; } @@ -582,7 +586,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); @@ -767,7 +771,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; @@ -824,9 +828,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) { @@ -858,8 +859,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() & @@ -880,10 +881,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()); @@ -1014,7 +1016,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()); @@ -1031,7 +1033,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); @@ -1336,13 +1337,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 Thu May 2 09:51:37 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 1492778747381615.3848807134902; Fri, 21 Apr 2017 05:45:47 -0700 (PDT) Received: from localhost ([::1]:59089 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1d1XwX-0001CX-SC for importer@patchew.org; Fri, 21 Apr 2017 08:45:45 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:45834) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1d1XCq-0003Ey-1g for qemu-devel@nongnu.org; Fri, 21 Apr 2017 07:58:33 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1d1XCo-0007oM-JI for qemu-devel@nongnu.org; Fri, 21 Apr 2017 07:58:32 -0400 Received: from mx1.redhat.com ([209.132.183.28]:55975) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1d1XCo-0007oC-Ab for qemu-devel@nongnu.org; Fri, 21 Apr 2017 07:58: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 36D97C001606 for ; Fri, 21 Apr 2017 11:58:29 +0000 (UTC) Received: from secure.com (ovpn-116-35.ams2.redhat.com [10.36.116.35]) by smtp.corp.redhat.com (Postfix) with ESMTP id 26EBE91000; Fri, 21 Apr 2017 11:58:27 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mx1.redhat.com 36D97C001606 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 36D97C001606 From: Juan Quintela To: qemu-devel@nongnu.org Date: Fri, 21 Apr 2017 13:56:29 +0200 Message-Id: <20170421115646.15544-49-quintela@redhat.com> In-Reply-To: <20170421115646.15544-1-quintela@redhat.com> References: <20170421115646.15544-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]); Fri, 21 Apr 2017 11:58: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] [PULL 48/65] 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 Reviewed-by: Dr. David Alan Gilbert -- rename page to page_abs everywhere. fix trace types for pages --- migration/ram.c | 76 ++++++++++++++++++++++------------------------= ---- migration/trace-events | 4 +-- 2 files changed, 36 insertions(+), 44 deletions(-) diff --git a/migration/ram.c b/migration/ram.c index 1ef142f..52ab14b 100644 --- a/migration/ram.c +++ b/migration/ram.c @@ -609,13 +609,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_abs: 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_abs) { unsigned long base =3D rb->offset >> TARGET_PAGE_BITS; unsigned long nr =3D base + (start >> TARGET_PAGE_BITS); @@ -632,17 +631,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_abs =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_abs) { 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_abs, bitmap); =20 if (ret) { rs->migration_dirty_pages--; @@ -1054,14 +1053,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_abs: 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_abs) { pss->offset =3D migration_bitmap_find_dirty(rs, pss->block, pss->offse= t, - ram_addr_abs); + page_abs); if (pss->complete_round && pss->block =3D=3D rs->last_seen_block && pss->offset >=3D rs->last_offset) { /* @@ -1108,11 +1106,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_abs: 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_abs) { RAMBlock *block =3D NULL; =20 @@ -1122,8 +1119,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_abs =3D (entry->offset + entry->rb->offset) >> TARGET_PAGE_B= ITS; =20 if (entry->len > TARGET_PAGE_SIZE) { entry->len -=3D TARGET_PAGE_SIZE; @@ -1148,18 +1144,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_abs: 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_abs) { 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_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 @@ -1169,17 +1164,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_abs, 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_abs, + test_bit(*page_abs, + 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_abs); } } =20 @@ -1307,15 +1300,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_abs: 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_abs) { 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_abs)) { unsigned long *unsentmap; /* * If xbzrle is on, stop using the data compression after first @@ -1335,7 +1328,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_abs, unsentmap); } } =20 @@ -1357,24 +1350,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_abs: 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_abs) { 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_abs); if (tmppages < 0) { return tmppages; } =20 pages +=3D tmppages; pss->offset +=3D TARGET_PAGE_SIZE; - dirty_ram_abs +=3D TARGET_PAGE_SIZE; + page_abs++; } while (pss->offset & (pagesize - 1)); =20 /* The offset we leave with is the last one we looked at */ @@ -1401,8 +1394,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_abs; /* Page number of the dirty page */ =20 /* No dirty page as there is zero RAM */ if (!ram_bytes_total()) { @@ -1419,15 +1411,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_abs); =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_abs); } =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_abs); } } while (!pages && again); =20 diff --git a/migration/trace-events b/migration/trace-events index 7372ce2..b8f01a2 100644 --- a/migration/trace-events +++ b/migration/trace-events @@ -63,8 +63,8 @@ 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_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= )" +get_queued_page(const char *block_name, uint64_t tmp_offset, unsigned long= page_abs) "%s/%" PRIx64 " page_abs=3D%lx" +get_queued_page_not_dirty(const char *block_name, uint64_t tmp_offset, uns= igned long page_abs, int sent) "%s/%" PRIx64 " page_abs=3D%lx (sent=3D%d)" migration_bitmap_sync_start(void) "" migration_bitmap_sync_end(uint64_t dirty_pages) "dirty_pages %" PRIu64 migration_throttle(void) "" --=20 2.9.3 From nobody Thu May 2 09:51:37 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 149277693671149.51381789959851; Fri, 21 Apr 2017 05:15:36 -0700 (PDT) Received: from localhost ([::1]:58883 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1d1XTL-0000Qb-72 for importer@patchew.org; Fri, 21 Apr 2017 08:15:35 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:45844) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1d1XCq-0003GW-VU for qemu-devel@nongnu.org; Fri, 21 Apr 2017 07:58:33 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1d1XCq-0007os-4R for qemu-devel@nongnu.org; Fri, 21 Apr 2017 07:58:33 -0400 Received: from mx1.redhat.com ([209.132.183.28]:38090) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1d1XCp-0007oX-Re for qemu-devel@nongnu.org; Fri, 21 Apr 2017 07:58: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 AE295AA442 for ; Fri, 21 Apr 2017 11:58:30 +0000 (UTC) Received: from secure.com (ovpn-116-35.ams2.redhat.com [10.36.116.35]) by smtp.corp.redhat.com (Postfix) with ESMTP id 877DC83830; Fri, 21 Apr 2017 11:58:29 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mx1.redhat.com AE295AA442 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 AE295AA442 From: Juan Quintela To: qemu-devel@nongnu.org Date: Fri, 21 Apr 2017 13:56:30 +0200 Message-Id: <20170421115646.15544-50-quintela@redhat.com> In-Reply-To: <20170421115646.15544-1-quintela@redhat.com> References: <20170421115646.15544-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.30]); Fri, 21 Apr 2017 11:58:30 +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] [PULL 49/65] 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-Type: text/plain; charset="utf-8" Signed-off-by: Juan Quintela Reviewed-by: Dr. David Alan Gilbert Reviewed-by: Philippe Mathieu-Daud=C3=A9 -- Improve comment Fix typo --- migration/ram.c | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/migration/ram.c b/migration/ram.c index 52ab14b..d501040 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 target 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 */ @@ -1061,7 +1061,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_abs); if (pss->complete_round && pss->block =3D=3D rs->last_seen_block && - pss->offset >=3D rs->last_offset) { + (pss->offset >> TARGET_PAGE_BITS) >=3D rs->last_page) { /* * We've been once around the RAM and haven't found anything. * Give up. @@ -1402,7 +1402,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) { @@ -1424,7 +1424,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; } @@ -1499,7 +1499,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; } @@ -1844,7 +1844,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 Thu May 2 09:51:37 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 1492777093542995.5825917655003; Fri, 21 Apr 2017 05:18:13 -0700 (PDT) Received: from localhost ([::1]:58891 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1d1XVr-0002X0-2h for importer@patchew.org; Fri, 21 Apr 2017 08:18:11 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:45860) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1d1XCt-0003KQ-Hg for qemu-devel@nongnu.org; Fri, 21 Apr 2017 07:58:39 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1d1XCs-0007pQ-7j for qemu-devel@nongnu.org; Fri, 21 Apr 2017 07:58:35 -0400 Received: from mx1.redhat.com ([209.132.183.28]:4740) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1d1XCr-0007pI-Ul for qemu-devel@nongnu.org; Fri, 21 Apr 2017 07:58: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 CF5AFDDB3A for ; Fri, 21 Apr 2017 11:58:32 +0000 (UTC) Received: from secure.com (ovpn-116-35.ams2.redhat.com [10.36.116.35]) by smtp.corp.redhat.com (Postfix) with ESMTP id 0F41489F52; Fri, 21 Apr 2017 11:58:30 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mx1.redhat.com CF5AFDDB3A 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 CF5AFDDB3A From: Juan Quintela To: qemu-devel@nongnu.org Date: Fri, 21 Apr 2017 13:56:31 +0200 Message-Id: <20170421115646.15544-51-quintela@redhat.com> In-Reply-To: <20170421115646.15544-1-quintela@redhat.com> References: <20170421115646.15544-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]); Fri, 21 Apr 2017 11:58: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] [PULL 50/65] 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 | 51 ++++++++++++++++++++++++++------------------------- 1 file changed, 26 insertions(+), 25 deletions(-) diff --git a/migration/ram.c b/migration/ram.c index d501040..eec398f 100644 --- a/migration/ram.c +++ b/migration/ram.c @@ -296,8 +296,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; }; @@ -608,16 +608,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_abs: 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_abs) +unsigned long migration_bitmap_find_dirty(RAMState *rs, RAMBlock *rb, + unsigned long start, + unsigned long *page_abs) { 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; @@ -632,7 +632,7 @@ ram_addr_t migration_bitmap_find_dirty(RAMState *rs, RA= MBlock *rb, } =20 *page_abs =3D next; - return (next - base) << TARGET_PAGE_BITS; + return next - base; } =20 static inline bool migration_bitmap_clear_dirty(RAMState *rs, @@ -810,7 +810,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 @@ -842,7 +842,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, @@ -985,7 +985,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 @@ -1029,14 +1029,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); } } } @@ -1058,10 +1058,10 @@ static int ram_save_compressed_page(RAMState *rs, P= ageSearchStatus *pss, static bool find_dirty_block(RAMState *rs, PageSearchStatus *pss, bool *again, unsigned long *page_abs) { - pss->offset =3D migration_bitmap_find_dirty(rs, pss->block, pss->offse= t, - page_abs); + pss->page =3D migration_bitmap_find_dirty(rs, pss->block, pss->page, + page_abs); if (pss->complete_round && pss->block =3D=3D rs->last_seen_block && - (pss->offset >> TARGET_PAGE_BITS) >=3D rs->last_page) { + pss->page >=3D rs->last_page) { /* * We've been once around the RAM and haven't found anything. * Give up. @@ -1069,9 +1069,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 */ @@ -1193,7 +1193,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; @@ -1357,7 +1357,8 @@ static int ram_save_host_page(RAMState *rs, PageSearc= hStatus *pss, unsigned long page_abs) { 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_abs); @@ -1366,12 +1367,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_abs++; - } 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 @@ -1402,7 +1403,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) { @@ -1424,7 +1425,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 Thu May 2 09:51:37 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 1492778880516219.16607554166728; Fri, 21 Apr 2017 05:48:00 -0700 (PDT) Received: from localhost ([::1]:59118 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1d1Xyg-00036f-SR for importer@patchew.org; Fri, 21 Apr 2017 08:47:58 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:45878) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1d1XCx-0003NE-KB for qemu-devel@nongnu.org; Fri, 21 Apr 2017 07:58:40 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1d1XCu-0007qo-1z for qemu-devel@nongnu.org; Fri, 21 Apr 2017 07:58:39 -0400 Received: from mx1.redhat.com ([209.132.183.28]:46445) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1d1XCt-0007qf-OR for qemu-devel@nongnu.org; Fri, 21 Apr 2017 07:58:35 -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 A3CDFC073D64 for ; Fri, 21 Apr 2017 11:58:34 +0000 (UTC) Received: from secure.com (ovpn-116-35.ams2.redhat.com [10.36.116.35]) by smtp.corp.redhat.com (Postfix) with ESMTP id 2B3ED89F54; Fri, 21 Apr 2017 11:58:32 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mx1.redhat.com A3CDFC073D64 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 A3CDFC073D64 From: Juan Quintela To: qemu-devel@nongnu.org Date: Fri, 21 Apr 2017 13:56:32 +0200 Message-Id: <20170421115646.15544-52-quintela@redhat.com> In-Reply-To: <20170421115646.15544-1-quintela@redhat.com> References: <20170421115646.15544-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]); Fri, 21 Apr 2017 11:58: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] [PULL 51/65] 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 Reviewed-by: Dr. David Alan Gilbert --- migration/ram.c | 65 ++++++++++++++++++++++++-----------------------------= ---- 1 file changed, 27 insertions(+), 38 deletions(-) diff --git a/migration/ram.c b/migration/ram.c index eec398f..932a96e 100644 --- a/migration/ram.c +++ b/migration/ram.c @@ -609,12 +609,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_abs: 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_abs) + unsigned long start) { unsigned long base =3D rb->offset >> TARGET_PAGE_BITS; unsigned long nr =3D base + start; @@ -631,17 +629,18 @@ unsigned long migration_bitmap_find_dirty(RAMState *r= s, RAMBlock *rb, next =3D find_next_bit(bitmap, size, nr); } =20 - *page_abs =3D next; return next - base; } =20 static inline bool migration_bitmap_clear_dirty(RAMState *rs, - unsigned long page_abs) + 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_abs, bitmap); + ret =3D test_and_clear_bit(nr, bitmap); =20 if (ret) { rs->migration_dirty_pages--; @@ -1053,13 +1052,10 @@ 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 - * @page_abs: pointer into where to store the dirty page */ -static bool find_dirty_block(RAMState *rs, PageSearchStatus *pss, - bool *again, unsigned long *page_abs) +static bool find_dirty_block(RAMState *rs, PageSearchStatus *pss, bool *ag= ain) { - pss->page =3D migration_bitmap_find_dirty(rs, pss->block, pss->page, - page_abs); + 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) { /* @@ -1106,10 +1102,8 @@ static bool find_dirty_block(RAMState *rs, PageSearc= hStatus *pss, * * @rs: current RAM state * @offset: used to return the offset within the RAMBlock - * @page_abs: pointer into where to store the dirty page */ -static RAMBlock *unqueue_page(RAMState *rs, ram_addr_t *offset, - unsigned long *page_abs) +static RAMBlock *unqueue_page(RAMState *rs, ram_addr_t *offset) { RAMBlock *block =3D NULL; =20 @@ -1119,7 +1113,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_abs =3D (entry->offset + entry->rb->offset) >> TARGET_PAGE_B= ITS; =20 if (entry->len > TARGET_PAGE_SIZE) { entry->len -=3D TARGET_PAGE_SIZE; @@ -1144,17 +1137,15 @@ 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 - * @page_abs: pointer into where to store the dirty page */ -static bool get_queued_page(RAMState *rs, PageSearchStatus *pss, - unsigned long *page_abs) +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_abs); + 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 @@ -1163,16 +1154,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_abs, 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_abs, - test_bit(*page_abs, + page, + test_bit(page, atomic_rcu_read(&rs->ram_bitmap)->unsentmap)); } else { - trace_get_queued_page(block->idstr, (uint64_t)offset, - *page_abs); + trace_get_queued_page(block->idstr, (uint64_t)offset, page= ); } } =20 @@ -1300,22 +1293,22 @@ err: * @ms: current migration state * @pss: data about the page we want to send * @last_stage: if we are at the completion stage - * @page_abs: page number of the dirty page */ static int ram_save_target_page(RAMState *rs, PageSearchStatus *pss, - bool last_stage, unsigned long page_abs) + 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_abs)) { + if (migration_bitmap_clear_dirty(rs, pss->block, pss->page)) { unsigned long *unsentmap; /* * If xbzrle is on, stop using the data compression after first * round of migration even if compression is enabled. In theory, * xbzrle can do better than compression. */ - + unsigned long page =3D + (pss->block->offset >> TARGET_PAGE_BITS) + pss->page; if (migrate_use_compression() && (rs->ram_bulk_stage || !migrate_use_xbzrle())) { res =3D ram_save_compressed_page(rs, pss, last_stage); @@ -1328,7 +1321,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(page_abs, unsentmap); + clear_bit(page, unsentmap); } } =20 @@ -1350,25 +1343,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_abs: Page number of the dirty page */ static int ram_save_host_page(RAMState *rs, PageSearchStatus *pss, - bool last_stage, - unsigned long page_abs) + 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_abs); + tmppages =3D ram_save_target_page(rs, pss, last_stage); if (tmppages < 0) { return tmppages; } =20 pages +=3D tmppages; pss->page++; - page_abs++; } while (pss->page & (pagesize_bits - 1)); =20 /* The offset we leave with is the last one we looked at */ @@ -1395,7 +1385,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_abs; /* Page number of the dirty page */ =20 /* No dirty page as there is zero RAM */ if (!ram_bytes_total()) { @@ -1412,15 +1401,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_abs); + 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_abs); + found =3D find_dirty_block(rs, &pss, &again); } =20 if (found) { - pages =3D ram_save_host_page(rs, &pss, last_stage, page_abs); + pages =3D ram_save_host_page(rs, &pss, last_stage); } } while (!pages && again); =20 --=20 2.9.3 From nobody Thu May 2 09:51:37 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 1492777253024988.6016779325168; Fri, 21 Apr 2017 05:20:53 -0700 (PDT) Received: from localhost ([::1]:58905 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1d1XYR-0004dW-Ct for importer@patchew.org; Fri, 21 Apr 2017 08:20:51 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:45879) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1d1XCx-0003NG-KV for qemu-devel@nongnu.org; Fri, 21 Apr 2017 07:58:40 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1d1XCw-0007r2-3v for qemu-devel@nongnu.org; Fri, 21 Apr 2017 07:58:39 -0400 Received: from mx1.redhat.com ([209.132.183.28]:55910) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1d1XCv-0007qv-RY for qemu-devel@nongnu.org; Fri, 21 Apr 2017 07:58: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 973EBC59C7 for ; Fri, 21 Apr 2017 11:58:36 +0000 (UTC) Received: from secure.com (ovpn-116-35.ams2.redhat.com [10.36.116.35]) by smtp.corp.redhat.com (Postfix) with ESMTP id F315289F45; Fri, 21 Apr 2017 11:58:34 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mx1.redhat.com 973EBC59C7 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 973EBC59C7 From: Juan Quintela To: qemu-devel@nongnu.org Date: Fri, 21 Apr 2017 13:56:33 +0200 Message-Id: <20170421115646.15544-53-quintela@redhat.com> In-Reply-To: <20170421115646.15544-1-quintela@redhat.com> References: <20170421115646.15544-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]); Fri, 21 Apr 2017 11:58: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] [PULL 52/65] 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 7a640c7..de843f4 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 8a1372c..a8411c7 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 932a96e..f972882 100644 --- a/migration/ram.c +++ b/migration/ram.c @@ -1537,7 +1537,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; @@ -1904,8 +1904,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(); @@ -1953,7 +1952,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); @@ -1999,7 +1998,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 @@ -2460,7 +2459,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 Thu May 2 09:51:37 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 1492778442590729.2939054208653; Fri, 21 Apr 2017 05:40:42 -0700 (PDT) Received: from localhost ([::1]:59053 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1d1Xrd-0004wp-1q for importer@patchew.org; Fri, 21 Apr 2017 08:40:41 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:45897) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1d1XCy-0003O5-Jl for qemu-devel@nongnu.org; Fri, 21 Apr 2017 07:58:41 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1d1XCx-0007rK-Mu for qemu-devel@nongnu.org; Fri, 21 Apr 2017 07:58:40 -0400 Received: from mx1.redhat.com ([209.132.183.28]:55998) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1d1XCx-0007r9-Gf for qemu-devel@nongnu.org; Fri, 21 Apr 2017 07:58:39 -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 6251FC59CB for ; Fri, 21 Apr 2017 11:58:38 +0000 (UTC) Received: from secure.com (ovpn-116-35.ams2.redhat.com [10.36.116.35]) by smtp.corp.redhat.com (Postfix) with ESMTP id E57E691000; Fri, 21 Apr 2017 11:58:36 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mx1.redhat.com 6251FC59CB 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 6251FC59CB From: Juan Quintela To: qemu-devel@nongnu.org Date: Fri, 21 Apr 2017 13:56:34 +0200 Message-Id: <20170421115646.15544-54-quintela@redhat.com> In-Reply-To: <20170421115646.15544-1-quintela@redhat.com> References: <20170421115646.15544-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]); Fri, 21 Apr 2017 11:58: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] [PULL 53/65] 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 f972882..2af8080 100644 --- a/migration/ram.c +++ b/migration/ram.c @@ -1451,7 +1451,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); @@ -1465,7 +1465,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(); @@ -1504,8 +1504,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 @@ -1995,7 +1995,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 Thu May 2 09:51:37 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 1492778593293375.3790869265721; Fri, 21 Apr 2017 05:43:13 -0700 (PDT) Received: from localhost ([::1]:59066 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1d1Xu4-00077R-0Q for importer@patchew.org; Fri, 21 Apr 2017 08:43:12 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:45916) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1d1XD0-0003Pa-1Z for qemu-devel@nongnu.org; Fri, 21 Apr 2017 07:58:42 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1d1XCz-0007ro-3V for qemu-devel@nongnu.org; Fri, 21 Apr 2017 07:58:42 -0400 Received: from mx1.redhat.com ([209.132.183.28]:45270) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1d1XCy-0007rc-TZ for qemu-devel@nongnu.org; Fri, 21 Apr 2017 07:58: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 BFE49C00C0E7 for ; Fri, 21 Apr 2017 11:58:39 +0000 (UTC) Received: from secure.com (ovpn-116-35.ams2.redhat.com [10.36.116.35]) by smtp.corp.redhat.com (Postfix) with ESMTP id B57D384BF1; Fri, 21 Apr 2017 11:58:38 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mx1.redhat.com BFE49C00C0E7 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 BFE49C00C0E7 From: Juan Quintela To: qemu-devel@nongnu.org Date: Fri, 21 Apr 2017 13:56:35 +0200 Message-Id: <20170421115646.15544-55-quintela@redhat.com> In-Reply-To: <20170421115646.15544-1-quintela@redhat.com> References: <20170421115646.15544-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]); Fri, 21 Apr 2017 11:58: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] [PULL 54/65] 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 b84ec3d..ba1a16c 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 156daf9..a92d7f7 100644 --- a/migration/migration.c +++ b/migration/migration.c @@ -1075,11 +1075,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: @@ -1144,7 +1142,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 From nobody Thu May 2 09:51:37 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 1492779004833609.4795483812885; Fri, 21 Apr 2017 05:50:04 -0700 (PDT) Received: from localhost ([::1]:59124 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1d1Y0h-0004d4-Gx for importer@patchew.org; Fri, 21 Apr 2017 08:50:03 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:45943) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1d1XD1-0003Qo-FC for qemu-devel@nongnu.org; Fri, 21 Apr 2017 07:58:44 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1d1XD0-0007sT-IT for qemu-devel@nongnu.org; Fri, 21 Apr 2017 07:58:43 -0400 Received: from mx1.redhat.com ([209.132.183.28]:41558) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1d1XD0-0007s2-CH for qemu-devel@nongnu.org; Fri, 21 Apr 2017 07:58: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 431B1DB009 for ; Fri, 21 Apr 2017 11:58:41 +0000 (UTC) Received: from secure.com (ovpn-116-35.ams2.redhat.com [10.36.116.35]) by smtp.corp.redhat.com (Postfix) with ESMTP id 1CA9F89F52; Fri, 21 Apr 2017 11:58:39 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mx1.redhat.com 431B1DB009 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 431B1DB009 From: Juan Quintela To: qemu-devel@nongnu.org Date: Fri, 21 Apr 2017 13:56:36 +0200 Message-Id: <20170421115646.15544-56-quintela@redhat.com> In-Reply-To: <20170421115646.15544-1-quintela@redhat.com> References: <20170421115646.15544-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.39]); Fri, 21 Apr 2017 11:58:41 +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] [PULL 55/65] qdev: qdev_hotplug is really a bool 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: zhanghailiang Reviewed-by: Eric Blake Reviewed-by: Philippe Mathieu-Daud=C3=A9 --- hw/core/qdev.c | 4 ++-- include/hw/qdev-core.h | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/hw/core/qdev.c b/hw/core/qdev.c index 1e7fb33..6fa46b5 100644 --- a/hw/core/qdev.c +++ b/hw/core/qdev.c @@ -39,7 +39,7 @@ #include "qapi-event.h" #include "migration/migration.h" =20 -int qdev_hotplug =3D 0; +bool qdev_hotplug =3D false; static bool qdev_hot_added =3D false; static bool qdev_hot_removed =3D false; =20 @@ -385,7 +385,7 @@ void qdev_machine_creation_done(void) * ok, initial machine setup is done, starting from now we can * only create hotpluggable devices */ - qdev_hotplug =3D 1; + qdev_hotplug =3D true; } =20 bool qdev_machine_modified(void) diff --git a/include/hw/qdev-core.h b/include/hw/qdev-core.h index b44b476..a96a913 100644 --- a/include/hw/qdev-core.h +++ b/include/hw/qdev-core.h @@ -386,7 +386,7 @@ Object *qdev_get_machine(void); /* FIXME: make this a link<> */ void qdev_set_parent_bus(DeviceState *dev, BusState *bus); =20 -extern int qdev_hotplug; +extern bool qdev_hotplug; =20 char *qdev_get_dev_path(DeviceState *dev); =20 --=20 2.9.3 From nobody Thu May 2 09:51:37 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 1492777410948307.9928700115156; Fri, 21 Apr 2017 05:23:30 -0700 (PDT) Received: from localhost ([::1]:58915 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1d1Xav-0006ke-3h for importer@patchew.org; Fri, 21 Apr 2017 08:23:25 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:45963) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1d1XD2-0003ST-RI for qemu-devel@nongnu.org; Fri, 21 Apr 2017 07:58:48 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1d1XD2-0007sx-3o for qemu-devel@nongnu.org; Fri, 21 Apr 2017 07:58:44 -0400 Received: from mx1.redhat.com ([209.132.183.28]:50540) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1d1XD1-0007sk-US for qemu-devel@nongnu.org; Fri, 21 Apr 2017 07:58:44 -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 CA378923A2 for ; Fri, 21 Apr 2017 11:58:42 +0000 (UTC) Received: from secure.com (ovpn-116-35.ams2.redhat.com [10.36.116.35]) by smtp.corp.redhat.com (Postfix) with ESMTP id 94DB683830; Fri, 21 Apr 2017 11:58:41 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mx1.redhat.com CA378923A2 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 CA378923A2 From: Juan Quintela To: qemu-devel@nongnu.org Date: Fri, 21 Apr 2017 13:56:37 +0200 Message-Id: <20170421115646.15544-57-quintela@redhat.com> In-Reply-To: <20170421115646.15544-1-quintela@redhat.com> References: <20170421115646.15544-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]); Fri, 21 Apr 2017 11:58: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] [PULL 56/65] qdev: Export qdev_hot_removed 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" I need to move qdev_unplug to qdev-monitor in the following patch, and it needs access to this variable. Signed-off-by: Juan Quintela Reviewed-by: Eric Blake Reviewed-by: zhanghailiang --- hw/core/qdev.c | 2 +- include/hw/qdev-core.h | 1 + 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/hw/core/qdev.c b/hw/core/qdev.c index 6fa46b5..c26cf84 100644 --- a/hw/core/qdev.c +++ b/hw/core/qdev.c @@ -41,7 +41,7 @@ =20 bool qdev_hotplug =3D false; static bool qdev_hot_added =3D false; -static bool qdev_hot_removed =3D false; +bool qdev_hot_removed =3D false; =20 const VMStateDescription *qdev_get_vmsd(DeviceState *dev) { diff --git a/include/hw/qdev-core.h b/include/hw/qdev-core.h index a96a913..f09b6b7 100644 --- a/include/hw/qdev-core.h +++ b/include/hw/qdev-core.h @@ -387,6 +387,7 @@ Object *qdev_get_machine(void); void qdev_set_parent_bus(DeviceState *dev, BusState *bus); =20 extern bool qdev_hotplug; +extern bool qdev_hot_removed; =20 char *qdev_get_dev_path(DeviceState *dev); =20 --=20 2.9.3 From nobody Thu May 2 09:51:37 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 1492777914965271.10191859128565; Fri, 21 Apr 2017 05:31:54 -0700 (PDT) Received: from localhost ([::1]:58992 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1d1Xj7-0006AF-Iy for importer@patchew.org; Fri, 21 Apr 2017 08:31:53 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:45994) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1d1XD6-0003Vw-Rm for qemu-devel@nongnu.org; Fri, 21 Apr 2017 07:58:49 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1d1XD3-0007tQ-IQ for qemu-devel@nongnu.org; Fri, 21 Apr 2017 07:58:48 -0400 Received: from mx1.redhat.com ([209.132.183.28]:45526) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1d1XD3-0007t6-9D for qemu-devel@nongnu.org; Fri, 21 Apr 2017 07:58: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 2701CC00B8DD for ; Fri, 21 Apr 2017 11:58:44 +0000 (UTC) Received: from secure.com (ovpn-116-35.ams2.redhat.com [10.36.116.35]) by smtp.corp.redhat.com (Postfix) with ESMTP id 272EB89F45; Fri, 21 Apr 2017 11:58:42 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mx1.redhat.com 2701CC00B8DD 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 2701CC00B8DD From: Juan Quintela To: qemu-devel@nongnu.org Date: Fri, 21 Apr 2017 13:56:38 +0200 Message-Id: <20170421115646.15544-58-quintela@redhat.com> In-Reply-To: <20170421115646.15544-1-quintela@redhat.com> References: <20170421115646.15544-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]); Fri, 21 Apr 2017 11:58:44 +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] [PULL 57/65] qdev: Move qdev_unplug() to qdev-monitor.c 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 is not used by linux-user, otherwise I need to to create one stub for migration_is_idle() on following patch. Signed-off-by: Juan Quintela Reviewed-by: Eric Blake Reviewed-by: zhanghailiang Reviewed-by: Markus Armbruster --- hw/core/qdev.c | 34 ---------------------------------- qdev-monitor.c | 34 ++++++++++++++++++++++++++++++++++ 2 files changed, 34 insertions(+), 34 deletions(-) diff --git a/hw/core/qdev.c b/hw/core/qdev.c index c26cf84..0df0050 100644 --- a/hw/core/qdev.c +++ b/hw/core/qdev.c @@ -271,40 +271,6 @@ HotplugHandler *qdev_get_hotplug_handler(DeviceState *= dev) return hotplug_ctrl; } =20 -void qdev_unplug(DeviceState *dev, Error **errp) -{ - DeviceClass *dc =3D DEVICE_GET_CLASS(dev); - HotplugHandler *hotplug_ctrl; - HotplugHandlerClass *hdc; - - if (dev->parent_bus && !qbus_is_hotpluggable(dev->parent_bus)) { - error_setg(errp, QERR_BUS_NO_HOTPLUG, dev->parent_bus->name); - return; - } - - if (!dc->hotpluggable) { - error_setg(errp, QERR_DEVICE_NO_HOTPLUG, - object_get_typename(OBJECT(dev))); - return; - } - - qdev_hot_removed =3D true; - - hotplug_ctrl =3D qdev_get_hotplug_handler(dev); - /* hotpluggable device MUST have HotplugHandler, if it doesn't - * then something is very wrong with it */ - g_assert(hotplug_ctrl); - - /* If device supports async unplug just request it to be done, - * otherwise just remove it synchronously */ - hdc =3D HOTPLUG_HANDLER_GET_CLASS(hotplug_ctrl); - if (hdc->unplug_request) { - hotplug_handler_unplug_request(hotplug_ctrl, dev, errp); - } else { - hotplug_handler_unplug(hotplug_ctrl, dev, errp); - } -} - static int qdev_reset_one(DeviceState *dev, void *opaque) { device_reset(dev); diff --git a/qdev-monitor.c b/qdev-monitor.c index 5f2fcdf..bb3d8ba 100644 --- a/qdev-monitor.c +++ b/qdev-monitor.c @@ -836,6 +836,40 @@ static DeviceState *find_device_state(const char *id, = Error **errp) return DEVICE(obj); } =20 +void qdev_unplug(DeviceState *dev, Error **errp) +{ + DeviceClass *dc =3D DEVICE_GET_CLASS(dev); + HotplugHandler *hotplug_ctrl; + HotplugHandlerClass *hdc; + + if (dev->parent_bus && !qbus_is_hotpluggable(dev->parent_bus)) { + error_setg(errp, QERR_BUS_NO_HOTPLUG, dev->parent_bus->name); + return; + } + + if (!dc->hotpluggable) { + error_setg(errp, QERR_DEVICE_NO_HOTPLUG, + object_get_typename(OBJECT(dev))); + return; + } + + qdev_hot_removed =3D true; + + hotplug_ctrl =3D qdev_get_hotplug_handler(dev); + /* hotpluggable device MUST have HotplugHandler, if it doesn't + * then something is very wrong with it */ + g_assert(hotplug_ctrl); + + /* If device supports async unplug just request it to be done, + * otherwise just remove it synchronously */ + hdc =3D HOTPLUG_HANDLER_GET_CLASS(hotplug_ctrl); + if (hdc->unplug_request) { + hotplug_handler_unplug_request(hotplug_ctrl, dev, errp); + } else { + hotplug_handler_unplug(hotplug_ctrl, dev, errp); + } +} + void qmp_device_del(const char *id, Error **errp) { DeviceState *dev =3D find_device_state(id, errp); --=20 2.9.3 From nobody Thu May 2 09:51:37 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 1492777551421754.4897295841739; Fri, 21 Apr 2017 05:25:51 -0700 (PDT) Received: from localhost ([::1]:58929 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1d1XdG-0000Vz-18 for importer@patchew.org; Fri, 21 Apr 2017 08:25:50 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:45995) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1d1XD6-0003Vy-SG for qemu-devel@nongnu.org; Fri, 21 Apr 2017 07:58:49 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1d1XD4-0007tj-PL for qemu-devel@nongnu.org; Fri, 21 Apr 2017 07:58:48 -0400 Received: from mx1.redhat.com ([209.132.183.28]:37636) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1d1XD4-0007tV-JG for qemu-devel@nongnu.org; Fri, 21 Apr 2017 07:58: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 74F88335EAF for ; Fri, 21 Apr 2017 11:58:45 +0000 (UTC) Received: from secure.com (ovpn-116-35.ams2.redhat.com [10.36.116.35]) by smtp.corp.redhat.com (Postfix) with ESMTP id 7A69589F47; Fri, 21 Apr 2017 11:58:44 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mx1.redhat.com 74F88335EAF 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 74F88335EAF From: Juan Quintela To: qemu-devel@nongnu.org Date: Fri, 21 Apr 2017 13:56:39 +0200 Message-Id: <20170421115646.15544-59-quintela@redhat.com> In-Reply-To: <20170421115646.15544-1-quintela@redhat.com> References: <20170421115646.15544-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]); Fri, 21 Apr 2017 11:58: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] [PULL 58/65] migration: Disable hotplug/unplug during migration 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" Until we have reviewed what can/can't be hotplugged during migration, disable it. We can enable it later for the things that we know that work. For instance, memory hotplug during postcopy doesn't work currently. Signed-off-by: Juan Quintela Reviewed-by: zhanghailiang -- - Fix typo. Thanks Thomas. - Delay migration check after we have checked that we can hotplug that device. - more typos --- qdev-monitor.c | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/qdev-monitor.c b/qdev-monitor.c index bb3d8ba..e61d596 100644 --- a/qdev-monitor.c +++ b/qdev-monitor.c @@ -29,6 +29,7 @@ #include "qemu/error-report.h" #include "qemu/help_option.h" #include "sysemu/block-backend.h" +#include "migration/migration.h" =20 /* * Aliases were a bad idea from the start. Let's keep them @@ -603,6 +604,11 @@ DeviceState *qdev_device_add(QemuOpts *opts, Error **e= rrp) return NULL; } =20 + if (!migration_is_idle()) { + error_setg(errp, "device_add not allowed while migrating"); + return NULL; + } + /* create device */ dev =3D DEVICE(object_new(driver)); =20 @@ -853,6 +859,11 @@ void qdev_unplug(DeviceState *dev, Error **errp) return; } =20 + if (!migration_is_idle()) { + error_setg(errp, "device_del not allowed while migrating"); + return; + } + qdev_hot_removed =3D true; =20 hotplug_ctrl =3D qdev_get_hotplug_handler(dev); --=20 2.9.3 From nobody Thu May 2 09:51:37 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 1492778736522701.6895401649957; Fri, 21 Apr 2017 05:45:36 -0700 (PDT) Received: from localhost ([::1]:59088 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1d1XwN-00012p-0c for importer@patchew.org; Fri, 21 Apr 2017 08:45:35 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:45998) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1d1XD7-0003WE-3v for qemu-devel@nongnu.org; Fri, 21 Apr 2017 07:58:50 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1d1XD6-0007ty-6l for qemu-devel@nongnu.org; Fri, 21 Apr 2017 07:58:49 -0400 Received: from mx1.redhat.com ([209.132.183.28]:56174) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1d1XD5-0007tn-UA for qemu-devel@nongnu.org; Fri, 21 Apr 2017 07:58: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 D131D83F45 for ; Fri, 21 Apr 2017 11:58:46 +0000 (UTC) Received: from secure.com (ovpn-116-35.ams2.redhat.com [10.36.116.35]) by smtp.corp.redhat.com (Postfix) with ESMTP id C6DE689F45; Fri, 21 Apr 2017 11:58:45 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mx1.redhat.com D131D83F45 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 D131D83F45 From: Juan Quintela To: qemu-devel@nongnu.org Date: Fri, 21 Apr 2017 13:56:40 +0200 Message-Id: <20170421115646.15544-60-quintela@redhat.com> In-Reply-To: <20170421115646.15544-1-quintela@redhat.com> References: <20170421115646.15544-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]); Fri, 21 Apr 2017 11:58: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] [PULL 59/65] ram: Remove migration_bitmap_extend() 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 have disabled memory hotplug, so we don't need to handle migration_bitamp there. Signed-off-by: Juan Quintela Reviewed-by: Eric Blake Reviewed-by: zhanghailiang --- exec.c | 1 - include/exec/ram_addr.h | 2 -- migration/ram.c | 34 ---------------------------------- 3 files changed, 37 deletions(-) diff --git a/exec.c b/exec.c index de843f4..c2def9e 100644 --- a/exec.c +++ b/exec.c @@ -1758,7 +1758,6 @@ static void ram_block_add(RAMBlock *new_block, Error = **errp) new_ram_size =3D MAX(old_ram_size, (new_block->offset + new_block->max_length) >> TARGET_PAGE_B= ITS); if (new_ram_size > old_ram_size) { - migration_bitmap_extend(old_ram_size, new_ram_size); dirty_memory_extend(old_ram_size, new_ram_size); } /* Keep the list sorted from biggest to smallest block. Unlike QTAILQ, diff --git a/include/exec/ram_addr.h b/include/exec/ram_addr.h index a8411c7..c9ddcd0 100644 --- a/include/exec/ram_addr.h +++ b/include/exec/ram_addr.h @@ -413,7 +413,5 @@ uint64_t cpu_physical_memory_sync_dirty_bitmap(unsigned= long *dest, =20 return num_dirty; } - -void migration_bitmap_extend(ram_addr_t old, ram_addr_t new); #endif #endif diff --git a/migration/ram.c b/migration/ram.c index 2af8080..f48664e 100644 --- a/migration/ram.c +++ b/migration/ram.c @@ -1496,40 +1496,6 @@ static void ram_state_reset(RAMState *rs) =20 #define MAX_WAIT 50 /* ms, half buffered_file limit */ =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 - */ - if (rs->ram_bitmap) { - RAMBitmap *old_bitmap =3D rs->ram_bitmap, *bitmap; - bitmap =3D g_new(RAMBitmap, 1); - bitmap->bmap =3D bitmap_new(new); - - /* prevent migration_bitmap content from being set bit - * by migration_bitmap_sync_range() at the same time. - * it is safe to migration if migration_bitmap is cleared bit - * at the same time. - */ - qemu_mutex_lock(&rs->bitmap_mutex); - bitmap_copy(bitmap->bmap, old_bitmap->bmap, old); - bitmap_set(bitmap->bmap, old, new - old); - - /* We don't have a way to safely extend the sentmap - * with RCU; so mark it as missing, entry to postcopy - * will fail. - */ - bitmap->unsentmap =3D NULL; - - 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); - } -} - /* * 'expected' is the value you expect the bitmap mostly to be full * of; it won't bother printing lines that are all this value. --=20 2.9.3 From nobody Thu May 2 09:51:37 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 1492778077100668.1037502606761; Fri, 21 Apr 2017 05:34:37 -0700 (PDT) Received: from localhost ([::1]:59001 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1d1Xlj-0008NM-F4 for importer@patchew.org; Fri, 21 Apr 2017 08:34:35 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:46025) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1d1XD8-0003Y1-Pk for qemu-devel@nongnu.org; Fri, 21 Apr 2017 07:58:51 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1d1XD7-0007uY-Ta for qemu-devel@nongnu.org; Fri, 21 Apr 2017 07:58:50 -0400 Received: from mx1.redhat.com ([209.132.183.28]:41900) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1d1XD7-0007uM-NU for qemu-devel@nongnu.org; Fri, 21 Apr 2017 07:58: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 99B6451440 for ; Fri, 21 Apr 2017 11:58:48 +0000 (UTC) Received: from secure.com (ovpn-116-35.ams2.redhat.com [10.36.116.35]) by smtp.corp.redhat.com (Postfix) with ESMTP id 2FC8283830; Fri, 21 Apr 2017 11:58:47 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mx1.redhat.com 99B6451440 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 99B6451440 From: Juan Quintela To: qemu-devel@nongnu.org Date: Fri, 21 Apr 2017 13:56:41 +0200 Message-Id: <20170421115646.15544-61-quintela@redhat.com> In-Reply-To: <20170421115646.15544-1-quintela@redhat.com> References: <20170421115646.15544-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]); Fri, 21 Apr 2017 11:58: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] [PULL 60/65] migration: don't close a file descriptor while it can be in use 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: Laurent Vivier , 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" From: Laurent Vivier If we close the QEMUFile descriptor in process_incoming_migration_co() while it has been stopped by an error, the postcopy_ram_listen_thread() can try to continue to use it. And as the memory has been freed it is working with an invalid pointer and crashes. Fix this by releasing the memory after having managed the error case (which, in fact, calls exit()) Signed-off-by: Laurent Vivier Reviewed-by: Dr. David Alan Gilbert Reviewed-by: Juan Quintela Reviewed-by: Amit Shah Reviewed-by: Stefan Hajnoczi Signed-off-by: Juan Quintela --- migration/migration.c | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/migration/migration.c b/migration/migration.c index a92d7f7..31e8141 100644 --- a/migration/migration.c +++ b/migration/migration.c @@ -435,17 +435,17 @@ static void process_incoming_migration_co(void *opaqu= e) qemu_thread_join(&mis->colo_incoming_thread); } =20 + if (ret < 0) { + migrate_set_state(&mis->state, MIGRATION_STATUS_ACTIVE, + MIGRATION_STATUS_FAILED); + error_report("load of migration failed: %s", strerror(-ret)); + migrate_decompress_threads_join(); + exit(EXIT_FAILURE); + } + qemu_fclose(f); free_xbzrle_decoded_buf(); =20 - if (ret < 0) { - migrate_set_state(&mis->state, MIGRATION_STATUS_ACTIVE, - MIGRATION_STATUS_FAILED); - error_report("load of migration failed: %s", strerror(-ret)); - migrate_decompress_threads_join(); - exit(EXIT_FAILURE); - } - mis->bh =3D qemu_bh_new(process_incoming_migration_bh, mis); qemu_bh_schedule(mis->bh); } --=20 2.9.3 From nobody Thu May 2 09:51:37 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 1492778867599992.744203165606; Fri, 21 Apr 2017 05:47:47 -0700 (PDT) Received: from localhost ([::1]:59115 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1d1XyT-0002wM-VW for importer@patchew.org; Fri, 21 Apr 2017 08:47:46 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:46048) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1d1XDA-0003ZV-DA for qemu-devel@nongnu.org; Fri, 21 Apr 2017 07:58:53 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1d1XD9-0007v1-Go for qemu-devel@nongnu.org; Fri, 21 Apr 2017 07:58:52 -0400 Received: from mx1.redhat.com ([209.132.183.28]:50720) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1d1XD9-0007ue-7Y for qemu-devel@nongnu.org; Fri, 21 Apr 2017 07:58: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 1D07E6E795 for ; Fri, 21 Apr 2017 11:58:50 +0000 (UTC) Received: from secure.com (ovpn-116-35.ams2.redhat.com [10.36.116.35]) by smtp.corp.redhat.com (Postfix) with ESMTP id EC5B389F51; Fri, 21 Apr 2017 11:58:48 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mx1.redhat.com 1D07E6E795 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 1D07E6E795 From: Juan Quintela To: qemu-devel@nongnu.org Date: Fri, 21 Apr 2017 13:56:42 +0200 Message-Id: <20170421115646.15544-62-quintela@redhat.com> In-Reply-To: <20170421115646.15544-1-quintela@redhat.com> References: <20170421115646.15544-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]); Fri, 21 Apr 2017 11:58:50 +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] [PULL 61/65] virtio-rng: stop virtqueue while the CPU is stopped 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: Laurent Vivier , 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" From: Laurent Vivier If we modify the virtio-rng virqueue while the vmstate is already migrated we can have some inconsistencies between the virtqueue state and the memory content. To avoid this, stop the virtqueue while the CPU is stopped. Signed-off-by: Laurent Vivier Reviewed-by: Amit Shah Reviewed-by: Stefan Hajnoczi Reviewed-by: Juan Quintela Signed-off-by: Juan Quintela --- hw/virtio/trace-events | 3 +++ hw/virtio/virtio-rng.c | 29 +++++++++++++++++++++++------ include/hw/virtio/virtio-rng.h | 2 ++ 3 files changed, 28 insertions(+), 6 deletions(-) diff --git a/hw/virtio/trace-events b/hw/virtio/trace-events index 6926eed..1f7a7c1 100644 --- a/hw/virtio/trace-events +++ b/hw/virtio/trace-events @@ -11,8 +11,11 @@ virtio_set_status(void *vdev, uint8_t val) "vdev %p val = %u" =20 # hw/virtio/virtio-rng.c virtio_rng_guest_not_ready(void *rng) "rng %p: guest not ready" +virtio_rng_cpu_is_stopped(void *rng, int size) "rng %p: cpu is stopped, dr= opping %d bytes" +virtio_rng_popped(void *rng) "rng %p: elem popped" virtio_rng_pushed(void *rng, size_t len) "rng %p: %zd bytes pushed" virtio_rng_request(void *rng, size_t size, unsigned quota) "rng %p: %zd by= tes requested, %u bytes quota left" +virtio_rng_vm_state_change(void *rng, int running, int state) "rng %p: sta= te change to running %d state %d" =20 # hw/virtio/virtio-balloon.c # diff --git a/hw/virtio/virtio-rng.c b/hw/virtio/virtio-rng.c index 9639f4e..a6ee501 100644 --- a/hw/virtio/virtio-rng.c +++ b/hw/virtio/virtio-rng.c @@ -53,6 +53,15 @@ static void chr_read(void *opaque, const void *buf, size= _t size) return; } =20 + /* we can't modify the virtqueue until + * our state is fully synced + */ + + if (!runstate_check(RUN_STATE_RUNNING)) { + trace_virtio_rng_cpu_is_stopped(vrng, size); + return; + } + vrng->quota_remaining -=3D size; =20 offset =3D 0; @@ -61,6 +70,7 @@ static void chr_read(void *opaque, const void *buf, size_= t size) if (!elem) { break; } + trace_virtio_rng_popped(vrng); len =3D iov_from_buf(elem->in_sg, elem->in_num, 0, buf + offset, size - offset); offset +=3D len; @@ -120,17 +130,21 @@ static uint64_t get_features(VirtIODevice *vdev, uint= 64_t f, Error **errp) return f; } =20 -static int virtio_rng_post_load(void *opaque, int version_id) +static void virtio_rng_vm_state_change(void *opaque, int running, + RunState state) { VirtIORNG *vrng =3D opaque; =20 + trace_virtio_rng_vm_state_change(vrng, running, state); + /* We may have an element ready but couldn't process it due to a quota - * limit. Make sure to try again after live migration when the quota = may - * have been reset. + * limit or because CPU was stopped. Make sure to try again when the + * CPU restart. */ - virtio_rng_process(vrng); =20 - return 0; + if (running && is_guest_ready(vrng)) { + virtio_rng_process(vrng); + } } =20 static void check_rate_limit(void *opaque) @@ -198,6 +212,9 @@ static void virtio_rng_device_realize(DeviceState *dev,= Error **errp) vrng->rate_limit_timer =3D timer_new_ms(QEMU_CLOCK_VIRTUAL, check_rate_limit, vrng); vrng->activate_timer =3D true; + + vrng->vmstate =3D qemu_add_vm_change_state_handler(virtio_rng_vm_state= _change, + vrng); } =20 static void virtio_rng_device_unrealize(DeviceState *dev, Error **errp) @@ -205,6 +222,7 @@ static void virtio_rng_device_unrealize(DeviceState *de= v, Error **errp) VirtIODevice *vdev =3D VIRTIO_DEVICE(dev); VirtIORNG *vrng =3D VIRTIO_RNG(dev); =20 + qemu_del_vm_change_state_handler(vrng->vmstate); timer_del(vrng->rate_limit_timer); timer_free(vrng->rate_limit_timer); virtio_cleanup(vdev); @@ -218,7 +236,6 @@ static const VMStateDescription vmstate_virtio_rng =3D { VMSTATE_VIRTIO_DEVICE, VMSTATE_END_OF_LIST() }, - .post_load =3D virtio_rng_post_load, }; =20 static Property virtio_rng_properties[] =3D { diff --git a/include/hw/virtio/virtio-rng.h b/include/hw/virtio/virtio-rng.h index 2d40abd..922dce7 100644 --- a/include/hw/virtio/virtio-rng.h +++ b/include/hw/virtio/virtio-rng.h @@ -45,6 +45,8 @@ typedef struct VirtIORNG { QEMUTimer *rate_limit_timer; int64_t quota_remaining; bool activate_timer; + + VMChangeStateEntry *vmstate; } VirtIORNG; =20 #endif --=20 2.9.3 From nobody Thu May 2 09:51:37 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 1492778993205217.96955483514296; Fri, 21 Apr 2017 05:49:53 -0700 (PDT) Received: from localhost ([::1]:59122 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1d1Y0V-0004Sv-Oi for importer@patchew.org; Fri, 21 Apr 2017 08:49:51 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:46095) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1d1XDG-0003fa-Oi for qemu-devel@nongnu.org; Fri, 21 Apr 2017 07:59:00 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1d1XDC-0007vX-Te for qemu-devel@nongnu.org; Fri, 21 Apr 2017 07:58:58 -0400 Received: from mx1.redhat.com ([209.132.183.28]:40606) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1d1XDC-0007vO-N9 for qemu-devel@nongnu.org; Fri, 21 Apr 2017 07:58: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 966AC2EAAB4 for ; Fri, 21 Apr 2017 11:58:53 +0000 (UTC) Received: from secure.com (ovpn-116-35.ams2.redhat.com [10.36.116.35]) by smtp.corp.redhat.com (Postfix) with ESMTP id B1C4983830; Fri, 21 Apr 2017 11:58:50 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mx1.redhat.com 966AC2EAAB4 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 966AC2EAAB4 From: Juan Quintela To: qemu-devel@nongnu.org Date: Fri, 21 Apr 2017 13:56:43 +0200 Message-Id: <20170421115646.15544-63-quintela@redhat.com> In-Reply-To: <20170421115646.15544-1-quintela@redhat.com> References: <20170421115646.15544-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]); Fri, 21 Apr 2017 11:58:53 +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] [PULL 62/65] migration: set current_active_state once 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, Peter Xu 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" From: Peter Xu We set it right above this one. No need to set it twice. CC: Juan Quintela CC: Dr. David Alan Gilbert Reviewed-by: Dr. David Alan Gilbert Signed-off-by: Peter Xu Reviewed-by: Philippe Mathieu-Daud=C3=A9 Reviewed-by: Juan Quintela Signed-off-by: Juan Quintela --- migration/migration.c | 1 - 1 file changed, 1 deletion(-) diff --git a/migration/migration.c b/migration/migration.c index 31e8141..dd7f721 100644 --- a/migration/migration.c +++ b/migration/migration.c @@ -1941,7 +1941,6 @@ static void *migration_thread(void *opaque) qemu_savevm_state_begin(s->to_dst_file, &s->params); =20 s->setup_time =3D qemu_clock_get_ms(QEMU_CLOCK_HOST) - setup_start; - current_active_state =3D MIGRATION_STATUS_ACTIVE; migrate_set_state(&s->state, MIGRATION_STATUS_SETUP, MIGRATION_STATUS_ACTIVE); =20 --=20 2.9.3 From nobody Thu May 2 09:51:37 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 1492779124420262.87731069856693; Fri, 21 Apr 2017 05:52:04 -0700 (PDT) Received: from localhost ([::1]:59135 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1d1Y2d-0006DZ-3u for importer@patchew.org; Fri, 21 Apr 2017 08:52:03 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:46092) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1d1XDG-0003fW-OV for qemu-devel@nongnu.org; Fri, 21 Apr 2017 07:59:00 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1d1XDE-0007wH-Gt for qemu-devel@nongnu.org; Fri, 21 Apr 2017 07:58:58 -0400 Received: from mx1.redhat.com ([209.132.183.28]:37940) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1d1XDE-0007vp-7j for qemu-devel@nongnu.org; Fri, 21 Apr 2017 07:58: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 1CD03335EAF for ; Fri, 21 Apr 2017 11:58:55 +0000 (UTC) Received: from secure.com (ovpn-116-35.ams2.redhat.com [10.36.116.35]) by smtp.corp.redhat.com (Postfix) with ESMTP id E93C983830; Fri, 21 Apr 2017 11:58:53 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mx1.redhat.com 1CD03335EAF 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 1CD03335EAF From: Juan Quintela To: qemu-devel@nongnu.org Date: Fri, 21 Apr 2017 13:56:44 +0200 Message-Id: <20170421115646.15544-64-quintela@redhat.com> In-Reply-To: <20170421115646.15544-1-quintela@redhat.com> References: <20170421115646.15544-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.29]); Fri, 21 Apr 2017 11:58:55 +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] [PULL 63/65] migration: rename max_size to threshold_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, Peter Xu 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" From: Peter Xu In migration codes (especially in migration_thread()), max_size is used in many place for the threshold value that we will start to do the final flush and jump to the next stage to dump the whole rest things to destination. However its name is confusing to first readers. Let's rename it to "threshold_size" when proper and add a comment for it. No functional change is made. CC: Juan Quintela CC: "Dr. David Alan Gilbert" Signed-off-by: Peter Xu Reviewed-by: "Dr. David Alan Gilbert" Reviewed-by: Philippe Mathieu-Daud=C3=A9 Reviewed-by: Juan Quintela Signed-off-by: Juan Quintela --- include/migration/vmstate.h | 3 ++- migration/migration.c | 21 +++++++++++++-------- migration/savevm.c | 4 ++-- 3 files changed, 17 insertions(+), 11 deletions(-) diff --git a/include/migration/vmstate.h b/include/migration/vmstate.h index f2dbf84..dad3984 100644 --- a/include/migration/vmstate.h +++ b/include/migration/vmstate.h @@ -56,7 +56,8 @@ typedef struct SaveVMHandlers { =20 /* This runs outside the iothread lock! */ int (*save_live_setup)(QEMUFile *f, void *opaque); - void (*save_live_pending)(QEMUFile *f, void *opaque, uint64_t max_size, + void (*save_live_pending)(QEMUFile *f, void *opaque, + uint64_t threshold_size, uint64_t *non_postcopiable_pending, uint64_t *postcopiable_pending); LoadStateHandler *load_state; diff --git a/migration/migration.c b/migration/migration.c index dd7f721..353f272 100644 --- a/migration/migration.c +++ b/migration/migration.c @@ -1910,7 +1910,12 @@ static void *migration_thread(void *opaque) int64_t initial_time =3D qemu_clock_get_ms(QEMU_CLOCK_REALTIME); int64_t setup_start =3D qemu_clock_get_ms(QEMU_CLOCK_HOST); int64_t initial_bytes =3D 0; - int64_t max_size =3D 0; + /* + * The final stage happens when the remaining data is smaller than + * this threshold; it's calculated from the requested downtime and + * measured bandwidth + */ + int64_t threshold_size =3D 0; int64_t start_time =3D initial_time; int64_t end_time; bool old_vm_running =3D false; @@ -1954,17 +1959,17 @@ static void *migration_thread(void *opaque) if (!qemu_file_rate_limit(s->to_dst_file)) { uint64_t pend_post, pend_nonpost; =20 - qemu_savevm_state_pending(s->to_dst_file, max_size, &pend_nonp= ost, - &pend_post); + qemu_savevm_state_pending(s->to_dst_file, threshold_size, + &pend_nonpost, &pend_post); pending_size =3D pend_nonpost + pend_post; - trace_migrate_pending(pending_size, max_size, + trace_migrate_pending(pending_size, threshold_size, pend_post, pend_nonpost); - if (pending_size && pending_size >=3D max_size) { + if (pending_size && pending_size >=3D threshold_size) { /* Still a significant amount to transfer */ =20 if (migrate_postcopy_ram() && s->state !=3D MIGRATION_STATUS_POSTCOPY_ACTIVE && - pend_nonpost <=3D max_size && + pend_nonpost <=3D threshold_size && atomic_read(&s->start_postcopy)) { =20 if (!postcopy_start(s, &old_vm_running)) { @@ -1996,13 +2001,13 @@ static void *migration_thread(void *opaque) initial_bytes; uint64_t time_spent =3D current_time - initial_time; double bandwidth =3D (double)transferred_bytes / time_spent; - max_size =3D bandwidth * s->parameters.downtime_limit; + threshold_size =3D bandwidth * s->parameters.downtime_limit; =20 s->mbps =3D (((double) transferred_bytes * 8.0) / ((double) time_spent / 1000.0)) / 1000.0 / 1000.0; =20 trace_migrate_transferred(transferred_bytes, time_spent, - bandwidth, max_size); + bandwidth, threshold_size); /* if we haven't sent anything, we don't want to recalculate 10000 is a small enough number for our purposes */ if (ram_dirty_pages_rate() && transferred_bytes > 10000) { diff --git a/migration/savevm.c b/migration/savevm.c index 7cf387f..03ae1bd 100644 --- a/migration/savevm.c +++ b/migration/savevm.c @@ -1197,7 +1197,7 @@ void qemu_savevm_state_complete_precopy(QEMUFile *f, = bool iterable_only) * the result is split into the amount for units that can and * for units that can't do postcopy. */ -void qemu_savevm_state_pending(QEMUFile *f, uint64_t max_size, +void qemu_savevm_state_pending(QEMUFile *f, uint64_t threshold_size, uint64_t *res_non_postcopiable, uint64_t *res_postcopiable) { @@ -1216,7 +1216,7 @@ void qemu_savevm_state_pending(QEMUFile *f, uint64_t = max_size, continue; } } - se->ops->save_live_pending(f, se->opaque, max_size, + se->ops->save_live_pending(f, se->opaque, threshold_size, res_non_postcopiable, res_postcopiable); } } --=20 2.9.3 From nobody Thu May 2 09:51:37 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 149277823862051.537358387267204; Fri, 21 Apr 2017 05:37:18 -0700 (PDT) Received: from localhost ([::1]:59017 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1d1XoL-000263-4p for importer@patchew.org; Fri, 21 Apr 2017 08:37:17 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:46093) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1d1XDG-0003fX-OJ for qemu-devel@nongnu.org; Fri, 21 Apr 2017 07:58:59 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1d1XDF-0007wY-T5 for qemu-devel@nongnu.org; Fri, 21 Apr 2017 07:58:58 -0400 Received: from mx1.redhat.com ([209.132.183.28]:57058) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1d1XDF-0007wQ-MV for qemu-devel@nongnu.org; Fri, 21 Apr 2017 07:58: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 938182EAAAB for ; Fri, 21 Apr 2017 11:58:56 +0000 (UTC) Received: from secure.com (ovpn-116-35.ams2.redhat.com [10.36.116.35]) by smtp.corp.redhat.com (Postfix) with ESMTP id 6E30A83830; Fri, 21 Apr 2017 11:58:55 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mx1.redhat.com 938182EAAAB 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 938182EAAAB From: Juan Quintela To: qemu-devel@nongnu.org Date: Fri, 21 Apr 2017 13:56:45 +0200 Message-Id: <20170421115646.15544-65-quintela@redhat.com> In-Reply-To: <20170421115646.15544-1-quintela@redhat.com> References: <20170421115646.15544-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]); Fri, 21 Apr 2017 11:58:56 +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] [PULL 64/65] hmp: info migrate_capability format tunes 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, Peter Xu 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" From: Peter Xu Dump the info in a single line is hard to read. Do it one per line. Also, the first "capabilities:" didn't help much. Let's remove it. CC: "Dr. David Alan Gilbert" Signed-off-by: Peter Xu Reviewed-by: "Dr. David Alan Gilbert" Reviewed-by: Philippe Mathieu-Daud=C3=A9 Reviewed-by: Juan Quintela Signed-off-by: Juan Quintela --- hmp.c | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/hmp.c b/hmp.c index be75e71..70db84f 100644 --- a/hmp.c +++ b/hmp.c @@ -268,13 +268,11 @@ void hmp_info_migrate_capabilities(Monitor *mon, cons= t QDict *qdict) caps =3D qmp_query_migrate_capabilities(NULL); =20 if (caps) { - monitor_printf(mon, "capabilities: "); for (cap =3D caps; cap; cap =3D cap->next) { - monitor_printf(mon, "%s: %s ", + monitor_printf(mon, "%s: %s\n", MigrationCapability_lookup[cap->value->capabili= ty], cap->value->state ? "on" : "off"); } - monitor_printf(mon, "\n"); } =20 qapi_free_MigrationCapabilityStatusList(caps); --=20 2.9.3 From nobody Thu May 2 09:51:37 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 1492779115461556.7560134442386; Fri, 21 Apr 2017 05:51:55 -0700 (PDT) Received: from localhost ([::1]:59134 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1d1Y2T-00064P-7h for importer@patchew.org; Fri, 21 Apr 2017 08:51:53 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:46125) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1d1XDI-0003gQ-Sh for qemu-devel@nongnu.org; Fri, 21 Apr 2017 07:59:01 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1d1XDH-0007x9-Ke for qemu-devel@nongnu.org; Fri, 21 Apr 2017 07:59:00 -0400 Received: from mx1.redhat.com ([209.132.183.28]:35064) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1d1XDH-0007wh-B8 for qemu-devel@nongnu.org; Fri, 21 Apr 2017 07:58: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 4389AC04BD42 for ; Fri, 21 Apr 2017 11:58:58 +0000 (UTC) Received: from secure.com (ovpn-116-35.ams2.redhat.com [10.36.116.35]) by smtp.corp.redhat.com (Postfix) with ESMTP id E63E383830; Fri, 21 Apr 2017 11:58:56 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mx1.redhat.com 4389AC04BD42 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 4389AC04BD42 From: Juan Quintela To: qemu-devel@nongnu.org Date: Fri, 21 Apr 2017 13:56:46 +0200 Message-Id: <20170421115646.15544-66-quintela@redhat.com> In-Reply-To: <20170421115646.15544-1-quintela@redhat.com> References: <20170421115646.15544-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.31]); Fri, 21 Apr 2017 11:58:58 +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] [PULL 65/65] hmp: info migrate_parameters format tunes 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, Peter Xu 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" From: Peter Xu Do the same (one per line) to the parameter list. CC: "Dr. David Alan Gilbert" Signed-off-by: Peter Xu Reviewed-by: "Dr. David Alan Gilbert" Reviewed-by: Philippe Mathieu-Daud=C3=A9 Reviewed-by: Juan Quintela Signed-off-by: Juan Quintela --- hmp.c | 22 ++++++++++------------ 1 file changed, 10 insertions(+), 12 deletions(-) diff --git a/hmp.c b/hmp.c index 70db84f..ab407d6 100644 --- a/hmp.c +++ b/hmp.c @@ -285,46 +285,44 @@ void hmp_info_migrate_parameters(Monitor *mon, const = QDict *qdict) params =3D qmp_query_migrate_parameters(NULL); =20 if (params) { - monitor_printf(mon, "parameters:"); assert(params->has_compress_level); - monitor_printf(mon, " %s: %" PRId64, + monitor_printf(mon, "%s: %" PRId64 "\n", MigrationParameter_lookup[MIGRATION_PARAMETER_COMPRESS_LEVEL], params->compress_level); assert(params->has_compress_threads); - monitor_printf(mon, " %s: %" PRId64, + monitor_printf(mon, "%s: %" PRId64 "\n", MigrationParameter_lookup[MIGRATION_PARAMETER_COMPRESS_THREADS= ], params->compress_threads); assert(params->has_decompress_threads); - monitor_printf(mon, " %s: %" PRId64, + monitor_printf(mon, "%s: %" PRId64 "\n", MigrationParameter_lookup[MIGRATION_PARAMETER_DECOMPRESS_THREA= DS], params->decompress_threads); assert(params->has_cpu_throttle_initial); - monitor_printf(mon, " %s: %" PRId64, + monitor_printf(mon, "%s: %" PRId64 "\n", MigrationParameter_lookup[MIGRATION_PARAMETER_CPU_THROTTLE_INI= TIAL], params->cpu_throttle_initial); assert(params->has_cpu_throttle_increment); - monitor_printf(mon, " %s: %" PRId64, + monitor_printf(mon, "%s: %" PRId64 "\n", MigrationParameter_lookup[MIGRATION_PARAMETER_CPU_THROTTLE_INC= REMENT], params->cpu_throttle_increment); - monitor_printf(mon, " %s: '%s'", + monitor_printf(mon, "%s: '%s'\n", MigrationParameter_lookup[MIGRATION_PARAMETER_TLS_CREDS], params->has_tls_creds ? params->tls_creds : ""); - monitor_printf(mon, " %s: '%s'", + monitor_printf(mon, "%s: '%s'\n", MigrationParameter_lookup[MIGRATION_PARAMETER_TLS_HOSTNAME], params->has_tls_hostname ? params->tls_hostname : ""); assert(params->has_max_bandwidth); - monitor_printf(mon, " %s: %" PRId64 " bytes/second", + monitor_printf(mon, "%s: %" PRId64 " bytes/second\n", MigrationParameter_lookup[MIGRATION_PARAMETER_MAX_BANDWIDTH], params->max_bandwidth); assert(params->has_downtime_limit); - monitor_printf(mon, " %s: %" PRId64 " milliseconds", + monitor_printf(mon, "%s: %" PRId64 " milliseconds\n", MigrationParameter_lookup[MIGRATION_PARAMETER_DOWNTIME_LIMIT], params->downtime_limit); assert(params->has_x_checkpoint_delay); - monitor_printf(mon, " %s: %" PRId64, + monitor_printf(mon, "%s: %" PRId64 "\n", MigrationParameter_lookup[MIGRATION_PARAMETER_X_CHECKPOINT_DEL= AY], params->x_checkpoint_delay); - monitor_printf(mon, "\n"); } =20 qapi_free_MigrationParameters(params); --=20 2.9.3