Skip to contentSkip to conversation

migration: just pass RAMBlock is enough

PATCH In review Wei Yang 4 participants 5 messages Jul 18, 2019 – Aug 7, 2019

lore
Share & tools
lore

Wei Yang

author
#0 lore raw

PATCH 1/1 migration: just pass RAMBlock is enough

RAMBlock->used_length is always passed to migration_bitmap_sync_range(), which could be retrieved from RAMBlock.

---
 migration/ram.c | 9 ++++-----
 1 file changed, 4 insertions(+), 5 deletions(-)
migration/ram.c +4 -5
index 908517fc2b..0a6070d787 100644
@@ -1669,11 +1669,10 @@ static inline bool migration_bitmap_clear_dirty(RAMState *rs,
     return ret;
 }
 
-static void migration_bitmap_sync_range(RAMState *rs, RAMBlock *rb,
-                                        ram_addr_t length)
+static void migration_bitmap_sync_range(RAMState *rs, RAMBlock *rb)
 {
     rs->migration_dirty_pages +=
-        cpu_physical_memory_sync_dirty_bitmap(rb, 0, length,
+        cpu_physical_memory_sync_dirty_bitmap(rb, 0, rb->used_length,
                                               &rs->num_dirty_pages_period);
 }
 
@@ -1762,7 +1761,7 @@ static void migration_bitmap_sync(RAMState *rs)
     qemu_mutex_lock(&rs->bitmap_mutex);
     rcu_read_lock();
     RAMBLOCK_FOREACH_NOT_IGNORED(block) {
-        migration_bitmap_sync_range(rs, block, block->used_length);
+        migration_bitmap_sync_range(rs, block);
     }
     ram_counters.remaining = ram_bytes_remaining();
     rcu_read_unlock();
@@ -4193,7 +4192,7 @@ static void colo_flush_ram_cache(void)
     memory_global_dirty_log_sync();
     rcu_read_lock();
     RAMBLOCK_FOREACH_NOT_IGNORED(block) {
-        migration_bitmap_sync_range(ram_state, block, block->used_length);
+        migration_bitmap_sync_range(ram_state, block);
     }
     rcu_read_unlock();
 
Signature · 1 line
2.17.1
Reviewed-by on v1 1/1
#2 lore raw
In reply to Wei Yang
Quoted 38 lines · Wei Yang

RAMBlock->used_length is always passed to migration_bitmap_sync_range(), which could be retrieved from RAMBlock.

---
 migration/ram.c | 9 ++++-----
 1 file changed, 4 insertions(+), 5 deletions(-)
migration/ram.c +3 -4
index 908517fc2b..0a6070d787 100644
@@ -1669,11 +1669,10 @@ static inline bool migration_bitmap_clear_dirty(RAMState *rs,
     return ret;
 }
 
-static void migration_bitmap_sync_range(RAMState *rs, RAMBlock *rb,
-                                        ram_addr_t length)
+static void migration_bitmap_sync_range(RAMState *rs, RAMBlock *rb)
 {
     rs->migration_dirty_pages +=
-        cpu_physical_memory_sync_dirty_bitmap(rb, 0, length,
+        cpu_physical_memory_sync_dirty_bitmap(rb, 0, rb->used_length,
                                               &rs->num_dirty_pages_period);
 }
 
@@ -1762,7 +1761,7 @@ static void migration_bitmap_sync(RAMState *rs)
     qemu_mutex_lock(&rs->bitmap_mutex);
     rcu_read_lock();
     RAMBLOCK_FOREACH_NOT_IGNORED(block) {
-        migration_bitmap_sync_range(rs, block, block->used_length);
+        migration_bitmap_sync_range(rs, block);
     }
     ram_counters.remaining = ram_bytes_remaining();
     rcu_read_unlock();

migration/ram.c static void colo_flush_ram_cache(void) · line 4198

Quoted 8 lines
migration/ram.c +1 -1
@@ -4193,7 +4192,7 @@ static void colo_flush_ram_cache(void)
     memory_global_dirty_log_sync();
     rcu_read_lock();
     RAMBLOCK_FOREACH_NOT_IGNORED(block) {
-        migration_bitmap_sync_range(ram_state, block, block->used_length);
+        migration_bitmap_sync_range(ram_state, block);
     }
     rcu_read_unlock();
 

and in fact we can rename the function to ramblock_sync_dirty_bitmap.

Paolo

author
#3 lore raw
Quoted 50 lines · Paolo Bonzini
Quoted 38 lines · Wei Yang

RAMBlock->used_length is always passed to migration_bitmap_sync_range(), which could be retrieved from RAMBlock.

---
 migration/ram.c | 9 ++++-----
 1 file changed, 4 insertions(+), 5 deletions(-)
migration/ram.c +3 -4
index 908517fc2b..0a6070d787 100644
@@ -1669,11 +1669,10 @@ static inline bool migration_bitmap_clear_dirty(RAMState *rs,
     return ret;
 }
 
-static void migration_bitmap_sync_range(RAMState *rs, RAMBlock *rb,
-                                        ram_addr_t length)
+static void migration_bitmap_sync_range(RAMState *rs, RAMBlock *rb)
 {
     rs->migration_dirty_pages +=
-        cpu_physical_memory_sync_dirty_bitmap(rb, 0, length,
+        cpu_physical_memory_sync_dirty_bitmap(rb, 0, rb->used_length,
                                               &rs->num_dirty_pages_period);
 }
 
@@ -1762,7 +1761,7 @@ static void migration_bitmap_sync(RAMState *rs)
     qemu_mutex_lock(&rs->bitmap_mutex);
     rcu_read_lock();
     RAMBLOCK_FOREACH_NOT_IGNORED(block) {
-        migration_bitmap_sync_range(rs, block, block->used_length);
+        migration_bitmap_sync_range(rs, block);
     }
     ram_counters.remaining = ram_bytes_remaining();
     rcu_read_unlock();

migration/ram.c static void colo_flush_ram_cache(void) · line 4198

Quoted 8 lines
migration/ram.c +1 -1
@@ -4193,7 +4192,7 @@ static void colo_flush_ram_cache(void)
     memory_global_dirty_log_sync();
     rcu_read_lock();
     RAMBLOCK_FOREACH_NOT_IGNORED(block) {
-        migration_bitmap_sync_range(ram_state, block, block->used_length);
+        migration_bitmap_sync_range(ram_state, block);
     }
     rcu_read_unlock();
 
Quoted 1 line

and in fact we can rename the function to ramblock_sync_dirty_bitmap.

Sounds reasonable. Let me improve it.

Quoted 2 lines

Paolo

Signature · 2 lines
Wei Yang
Help you, Help me
#4 lore raw
In reply to Wei Yang
Quoted 5 lines · * Wei Yang ([email protected]) wrote:

RAMBlock->used_length is always passed to migration_bitmap_sync_range(), which could be retrieved from RAMBlock.

Queued

Quoted 44 lines
---
 migration/ram.c | 9 ++++-----
 1 file changed, 4 insertions(+), 5 deletions(-)
migration/ram.c +4 -5
index 908517fc2b..0a6070d787 100644
@@ -1669,11 +1669,10 @@ static inline bool migration_bitmap_clear_dirty(RAMState *rs,
     return ret;
 }
 
-static void migration_bitmap_sync_range(RAMState *rs, RAMBlock *rb,
-                                        ram_addr_t length)
+static void migration_bitmap_sync_range(RAMState *rs, RAMBlock *rb)
 {
     rs->migration_dirty_pages +=
-        cpu_physical_memory_sync_dirty_bitmap(rb, 0, length,
+        cpu_physical_memory_sync_dirty_bitmap(rb, 0, rb->used_length,
                                               &rs->num_dirty_pages_period);
 }
 
@@ -1762,7 +1761,7 @@ static void migration_bitmap_sync(RAMState *rs)
     qemu_mutex_lock(&rs->bitmap_mutex);
     rcu_read_lock();
     RAMBLOCK_FOREACH_NOT_IGNORED(block) {
-        migration_bitmap_sync_range(rs, block, block->used_length);
+        migration_bitmap_sync_range(rs, block);
     }
     ram_counters.remaining = ram_bytes_remaining();
     rcu_read_unlock();
@@ -4193,7 +4192,7 @@ static void colo_flush_ram_cache(void)
     memory_global_dirty_log_sync();
     rcu_read_lock();
     RAMBLOCK_FOREACH_NOT_IGNORED(block) {
-        migration_bitmap_sync_range(ram_state, block, block->used_length);
+        migration_bitmap_sync_range(ram_state, block);
     }
     rcu_read_unlock();
 
Signature · 1 line
2.17.1

--
Dr. David Alan Gilbert / [email protected] / Manchester, UK