qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
From: Juan Quintela <quintela@redhat.com>
To: qemu-devel@nongnu.org
Cc: dgilbert@redhat.com
Subject: [Qemu-devel] [PATCH 48/59] ram: Use page number instead of an address for the bitmap operations
Date: Wed, 19 Apr 2017 22:59:12 +0200	[thread overview]
Message-ID: <20170419205923.8808-49-quintela@redhat.com> (raw)
In-Reply-To: <20170419205923.8808-1-quintela@redhat.com>

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 <quintela@redhat.com>
Reviewed-by: Dr. David Alan Gilbert <dgilbert@redhat.com>

--

rename page to page_abs everywhere.
fix trace types for pages

Signed-off-by: Juan Quintela <quintela@redhat.com>
---
 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 **current_data,
  * @rs: current RAM state
  * @rb: RAMBlock where to search for dirty pages
  * @start: starting 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
+ * @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 = rb->offset >> TARGET_PAGE_BITS;
     unsigned long nr = base + (start >> TARGET_PAGE_BITS);
@@ -632,17 +631,17 @@ ram_addr_t migration_bitmap_find_dirty(RAMState *rs, RAMBlock *rb,
         next = find_next_bit(bitmap, size, nr);
     }
 
-    *ram_addr_abs = next << TARGET_PAGE_BITS;
+    *page_abs = next;
     return (next - base) << TARGET_PAGE_BITS;
 }
 
-static inline bool migration_bitmap_clear_dirty(RAMState *rs, ram_addr_t addr)
+static inline bool migration_bitmap_clear_dirty(RAMState *rs,
+                                                unsigned long page_abs)
 {
     bool ret;
-    int nr = addr >> TARGET_PAGE_BITS;
     unsigned long *bitmap = atomic_rcu_read(&rs->ram_bitmap)->bmap;
 
-    ret = test_and_clear_bit(nr, bitmap);
+    ret = test_and_clear_bit(page_abs, bitmap);
 
     if (ret) {
         rs->migration_dirty_pages--;
@@ -1054,14 +1053,13 @@ static int ram_save_compressed_page(RAMState *rs, PageSearchStatus *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 = migration_bitmap_find_dirty(rs, pss->block, pss->offset,
-                                              ram_addr_abs);
+                                              page_abs);
     if (pss->complete_round && pss->block == rs->last_seen_block &&
         pss->offset >= rs->last_offset) {
         /*
@@ -1108,11 +1106,10 @@ static bool find_dirty_block(RAMState *rs, PageSearchStatus *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 = NULL;
 
@@ -1122,8 +1119,7 @@ static RAMBlock *unqueue_page(RAMState *rs, ram_addr_t *offset,
                                 QSIMPLEQ_FIRST(&rs->src_page_requests);
         block = entry->rb;
         *offset = entry->offset;
-        *ram_addr_abs = (entry->offset + entry->rb->offset) &
-                        TARGET_PAGE_MASK;
+        *page_abs = (entry->offset + entry->rb->offset) >> TARGET_PAGE_BITS;
 
         if (entry->len > TARGET_PAGE_SIZE) {
             entry->len -= TARGET_PAGE_SIZE;
@@ -1148,18 +1144,17 @@ static RAMBlock *unqueue_page(RAMState *rs, ram_addr_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;
 
     do {
-        block = unqueue_page(rs, &offset, ram_addr_abs);
+        block = 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, PageSearchStatus *pss,
         if (block) {
             unsigned long *bitmap;
             bitmap = atomic_rcu_read(&rs->ram_bitmap)->bmap;
-            dirty = test_bit(*ram_addr_abs >> TARGET_PAGE_BITS, bitmap);
+            dirty = 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)offset,
+                    *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);
             }
         }
 
@@ -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 space
+ * @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 = 0;
 
     /* 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, PageSearchStatus *pss,
         }
         unsentmap = atomic_rcu_read(&rs->ram_bitmap)->unsentmap;
         if (unsentmap) {
-            clear_bit(dirty_ram_abs >> TARGET_PAGE_BITS, unsentmap);
+            clear_bit(page_abs, unsentmap);
         }
     }
 
@@ -1357,24 +1350,24 @@ static int ram_save_target_page(RAMState *rs, PageSearchStatus *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 space
+ * @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 = 0;
     size_t pagesize = qemu_ram_pagesize(pss->block);
 
     do {
-        tmppages = ram_save_target_page(rs, pss, last_stage, dirty_ram_abs);
+        tmppages = ram_save_target_page(rs, pss, last_stage, page_abs);
         if (tmppages < 0) {
             return tmppages;
         }
 
         pages += tmppages;
         pss->offset += TARGET_PAGE_SIZE;
-        dirty_ram_abs += TARGET_PAGE_SIZE;
+        page_abs++;
     } while (pss->offset & (pagesize - 1));
 
     /* 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 = 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 */
 
     /* 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, bool last_stage)
 
     do {
         again = true;
-        found = get_queued_page(rs, &pss, &dirty_ram_abs);
+        found = get_queued_page(rs, &pss, &page_abs);
 
         if (!found) {
             /* priority queue empty, so just search for something dirty */
-            found = find_dirty_block(rs, &pss, &again, &dirty_ram_abs);
+            found = find_dirty_block(rs, &pss, &again, &page_abs);
         }
 
         if (found) {
-            pages = ram_save_host_page(rs, &pss, last_stage, dirty_ram_abs);
+            pages = ram_save_host_page(rs, &pss, last_stage, page_abs);
         }
     } while (!pages && again);
 
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) ""
 
 # migration/ram.c
-get_queued_page(const char *block_name, uint64_t tmp_offset, uint64_t ram_addr) "%s/%" PRIx64 " ram_addr=%" PRIx64
-get_queued_page_not_dirty(const char *block_name, uint64_t tmp_offset, uint64_t ram_addr, int sent) "%s/%" PRIx64 " ram_addr=%" PRIx64 " (sent=%d)"
+get_queued_page(const char *block_name, uint64_t tmp_offset, unsigned long page_abs) "%s/%" PRIx64 " page_abs=%lx"
+get_queued_page_not_dirty(const char *block_name, uint64_t tmp_offset, unsigned long page_abs, int sent) "%s/%" PRIx64 " page_abs=%lx (sent=%d)"
 migration_bitmap_sync_start(void) ""
 migration_bitmap_sync_end(uint64_t dirty_pages) "dirty_pages %" PRIu64
 migration_throttle(void) ""
-- 
2.9.3

  parent reply	other threads:[~2017-04-19 21:00 UTC|newest]

Thread overview: 65+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2017-04-19 20:58 [Qemu-devel] [PATCH 00/59] RAMState + qdev Juan Quintela
2017-04-19 20:58 ` [Qemu-devel] [PATCH 01/59] ram: Update all functions comments Juan Quintela
2017-04-19 20:58 ` [Qemu-devel] [PATCH 02/59] ram: Rename flush_page_queue() to migration_page_queue_free() Juan Quintela
2017-04-19 20:58 ` [Qemu-devel] [PATCH 03/59] ram: Rename block_name to rbname Juan Quintela
2017-04-19 20:58 ` [Qemu-devel] [PATCH 04/59] ram: Create RAMState Juan Quintela
2017-04-19 20:58 ` [Qemu-devel] [PATCH 05/59] ram: Add dirty_rate_high_cnt to RAMState Juan Quintela
2017-04-19 20:58 ` [Qemu-devel] [PATCH 06/59] ram: Move bitmap_sync_count into RAMState Juan Quintela
2017-04-19 20:58 ` [Qemu-devel] [PATCH 07/59] ram: Move start time " Juan Quintela
2017-04-19 20:58 ` [Qemu-devel] [PATCH 08/59] ram: Move bytes_xfer_prev " Juan Quintela
2017-04-19 20:58 ` [Qemu-devel] [PATCH 09/59] ram: Change byte_xfer_{prev, now} type to uint64_t Juan Quintela
2017-04-19 20:58 ` [Qemu-devel] [PATCH 10/59] ram: Move num_dirty_pages_period into RAMState Juan Quintela
2017-04-19 20:58 ` [Qemu-devel] [PATCH 11/59] ram: Change num_dirty_pages_period type to uint64_t Juan Quintela
2017-04-19 20:58 ` [Qemu-devel] [PATCH 12/59] ram: Move xbzrle_cache_miss_prev into RAMState Juan Quintela
2017-04-19 20:58 ` [Qemu-devel] [PATCH 13/59] ram: Move iterations_prev " Juan Quintela
2017-04-19 20:58 ` [Qemu-devel] [PATCH 14/59] ram: Move dup_pages " Juan Quintela
2017-04-19 20:58 ` [Qemu-devel] [PATCH 15/59] ram: Remove unused dup_mig_bytes_transferred() Juan Quintela
2017-04-19 20:58 ` [Qemu-devel] [PATCH 16/59] ram: Remove unused pages_skipped variable Juan Quintela
2017-04-19 20:58 ` [Qemu-devel] [PATCH 17/59] ram: Move norm_pages to RAMState Juan Quintela
2017-04-19 20:58 ` [Qemu-devel] [PATCH 18/59] ram: Remove norm_mig_bytes_transferred Juan Quintela
2017-04-19 20:58 ` [Qemu-devel] [PATCH 19/59] ram: Move iterations into RAMState Juan Quintela
2017-04-19 20:58 ` [Qemu-devel] [PATCH 20/59] ram: Move xbzrle_bytes " Juan Quintela
2017-04-19 20:58 ` [Qemu-devel] [PATCH 21/59] ram: Move xbzrle_pages " Juan Quintela
2017-04-19 20:58 ` [Qemu-devel] [PATCH 22/59] ram: Move xbzrle_cache_miss " Juan Quintela
2017-04-19 20:58 ` [Qemu-devel] [PATCH 23/59] ram: Move xbzrle_cache_miss_rate " Juan Quintela
2017-04-19 20:58 ` [Qemu-devel] [PATCH 24/59] ram: Move xbzrle_overflows " Juan Quintela
2017-04-19 20:58 ` [Qemu-devel] [PATCH 25/59] ram: Move migration_dirty_pages to RAMState Juan Quintela
2017-04-19 20:58 ` [Qemu-devel] [PATCH 26/59] ram: Everything was init to zero, so use memset Juan Quintela
2017-04-19 20:58 ` [Qemu-devel] [PATCH 27/59] ram: Move migration_bitmap_mutex into RAMState Juan Quintela
2017-04-19 20:58 ` [Qemu-devel] [PATCH 28/59] ram: Move migration_bitmap_rcu " Juan Quintela
2017-04-19 20:58 ` [Qemu-devel] [PATCH 29/59] ram: Move bytes_transferred " Juan Quintela
2017-04-19 20:58 ` [Qemu-devel] [PATCH 30/59] ram: Use the RAMState bytes_transferred parameter Juan Quintela
2017-04-19 20:58 ` [Qemu-devel] [PATCH 31/59] ram: Remove ram_save_remaining Juan Quintela
2017-04-19 20:58 ` [Qemu-devel] [PATCH 32/59] ram: Move last_req_rb to RAMState Juan Quintela
2017-04-19 20:58 ` [Qemu-devel] [PATCH 33/59] ram: Move src_page_req* " Juan Quintela
2017-04-19 20:58 ` [Qemu-devel] [PATCH 34/59] ram: Create ram_dirty_sync_count() Juan Quintela
2017-04-19 20:58 ` [Qemu-devel] [PATCH 35/59] ram: Remove dirty_bytes_rate Juan Quintela
2017-04-19 20:59 ` [Qemu-devel] [PATCH 36/59] ram: Move dirty_pages_rate to RAMState Juan Quintela
2017-04-19 20:59 ` [Qemu-devel] [PATCH 37/59] ram: Move postcopy_requests into RAMState Juan Quintela
2017-04-19 20:59 ` [Qemu-devel] [PATCH 38/59] ram: Add QEMUFile to RAMState Juan Quintela
2017-04-19 20:59 ` [Qemu-devel] [PATCH 39/59] ram: Move QEMUFile into RAMState Juan Quintela
2017-04-19 20:59 ` [Qemu-devel] [PATCH 40/59] ram: Remove compression_switch and inline its logic Juan Quintela
2017-04-19 20:59 ` [Qemu-devel] [PATCH 41/59] migration: Remove MigrationState from migration_in_postcopy Juan Quintela
2017-04-19 20:59 ` [Qemu-devel] [PATCH 42/59] ram: We don't need MigrationState parameter anymore Juan Quintela
2017-04-19 20:59 ` [Qemu-devel] [PATCH 43/59] ram: Rename qemu_target_page_bits() to qemu_target_page_size() Juan Quintela
2017-04-19 20:59 ` [Qemu-devel] [PATCH 44/59] ram: Add page-size to output in 'info migrate' Juan Quintela
2017-04-19 20:59 ` [Qemu-devel] [PATCH 45/59] ram: Pass RAMBlock to bitmap_sync Juan Quintela
2017-04-19 20:59 ` [Qemu-devel] [PATCH 46/59] ram: ram_discard_range() don't use the mis parameter Juan Quintela
2017-04-19 20:59 ` [Qemu-devel] [PATCH 47/59] ram: reorganize last_sent_block Juan Quintela
2017-04-19 20:59 ` Juan Quintela [this message]
2017-04-19 20:59 ` [Qemu-devel] [PATCH 49/59] ram: Remember last_page instead of last_offset Juan Quintela
2017-04-19 22:17   ` Philippe Mathieu-Daudé
2017-04-21  9:26     ` Juan Quintela
2017-04-20  8:57   ` Dr. David Alan Gilbert
2017-04-19 20:59 ` [Qemu-devel] [PATCH 50/59] ram: Change offset field in PageSearchStatus to page Juan Quintela
2017-04-19 20:59 ` [Qemu-devel] [PATCH 51/59] ram: Use ramblock and page offset instead of absolute offset Juan Quintela
2017-04-19 20:59 ` [Qemu-devel] [PATCH 52/59] ram: rename last_ram_offset() last_ram_pages() Juan Quintela
2017-04-19 20:59 ` [Qemu-devel] [PATCH 53/59] ram: Use RAMBitmap type for coherence Juan Quintela
2017-04-19 20:59 ` [Qemu-devel] [PATCH 54/59] migration: Remove MigrationState parameter from migration_is_idle() Juan Quintela
2017-04-19 20:59 ` [Qemu-devel] [PATCH 55/59] qdev: qdev_hotplug is really a bool Juan Quintela
2017-04-19 20:59 ` [Qemu-devel] [PATCH 56/59] qdev: Export qdev_hot_removed Juan Quintela
2017-04-19 20:59 ` [Qemu-devel] [PATCH 57/59] qdev: Move qdev_unplug() to qdev-monitor.c Juan Quintela
2017-04-19 20:59 ` [Qemu-devel] [PATCH 58/59] migration: Disable hotplug/unplug during migration Juan Quintela
2017-04-19 20:59 ` [Qemu-devel] [PATCH 59/59] ram: Remove migration_bitmap_extend() Juan Quintela
2017-04-19 21:49 ` [Qemu-devel] [PATCH 00/59] RAMState + qdev no-reply
2017-04-20  7:35   ` Juan Quintela

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20170419205923.8808-49-quintela@redhat.com \
    --to=quintela@redhat.com \
    --cc=dgilbert@redhat.com \
    --cc=qemu-devel@nongnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).