Patchwork [09/41] ram: introduce migration_bitmap_set_dirty()

login
register
mail settings
Submitter Juan Quintela
Date Sept. 21, 2012, 8:47 a.m.
Message ID <1348217255-22441-10-git-send-email-quintela@redhat.com>
Download mbox | patch
Permalink /patch/185666/
State New
Headers show

Comments

Juan Quintela - Sept. 21, 2012, 8:47 a.m.
It just marks a region of memory as dirty.

Signed-off-by: Juan Quintela <quintela@redhat.com>
---
 arch_init.c | 20 +++++++++++++-------
 1 file changed, 13 insertions(+), 7 deletions(-)
Orit Wasserman - Sept. 25, 2012, 8:38 a.m.
On 09/21/2012 11:47 AM, Juan Quintela wrote:
> It just marks a region of memory as dirty.
> 
> Signed-off-by: Juan Quintela <quintela@redhat.com>
> ---
>  arch_init.c | 20 +++++++++++++-------
>  1 file changed, 13 insertions(+), 7 deletions(-)
> 
> diff --git a/arch_init.c b/arch_init.c
> index 57f7f1a..b2dcc24 100644
> --- a/arch_init.c
> +++ b/arch_init.c
> @@ -332,6 +332,18 @@ static int save_xbzrle_page(QEMUFile *f, uint8_t *current_data,
>  static RAMBlock *last_block;
>  static ram_addr_t last_offset;
> 
> +static inline void migration_bitmap_set_dirty(MemoryRegion *mr, int length)
> +{
> +    ram_addr_t addr;
> +
> +    for (addr = 0; addr < length; addr += TARGET_PAGE_SIZE) {
> +        if (!memory_region_get_dirty(mr, addr, TARGET_PAGE_SIZE,
> +                                     DIRTY_MEMORY_MIGRATION)) {
> +            memory_region_set_dirty(mr, addr, TARGET_PAGE_SIZE);
> +        }
> +    }
> +}
> +
>  /*
>   * ram_save_block: Writes a page of memory to the stream f
>   *
> @@ -494,7 +506,6 @@ static void reset_ram_globals(void)
> 
>  static int ram_save_setup(QEMUFile *f, void *opaque)
>  {
> -    ram_addr_t addr;
>      RAMBlock *block;
> 
>      memory_global_sync_dirty_bitmap(get_system_memory());
> @@ -516,12 +527,7 @@ static int ram_save_setup(QEMUFile *f, void *opaque)
> 
>      /* Make sure all dirty bits are set */
>      QLIST_FOREACH(block, &ram_list.blocks, next) {
> -        for (addr = 0; addr < block->length; addr += TARGET_PAGE_SIZE) {
> -            if (!memory_region_get_dirty(block->mr, addr, TARGET_PAGE_SIZE,
> -                                         DIRTY_MEMORY_MIGRATION)) {
> -                memory_region_set_dirty(block->mr, addr, TARGET_PAGE_SIZE);
> -            }
> -        }
> +        migration_bitmap_set_dirty(block->mr, block->length);
>      }
> 
>      memory_global_dirty_log_start();
> 
Reviewed-by: Orit Wasserman <owasserm@redhat.com>

Patch

diff --git a/arch_init.c b/arch_init.c
index 57f7f1a..b2dcc24 100644
--- a/arch_init.c
+++ b/arch_init.c
@@ -332,6 +332,18 @@  static int save_xbzrle_page(QEMUFile *f, uint8_t *current_data,
 static RAMBlock *last_block;
 static ram_addr_t last_offset;

+static inline void migration_bitmap_set_dirty(MemoryRegion *mr, int length)
+{
+    ram_addr_t addr;
+
+    for (addr = 0; addr < length; addr += TARGET_PAGE_SIZE) {
+        if (!memory_region_get_dirty(mr, addr, TARGET_PAGE_SIZE,
+                                     DIRTY_MEMORY_MIGRATION)) {
+            memory_region_set_dirty(mr, addr, TARGET_PAGE_SIZE);
+        }
+    }
+}
+
 /*
  * ram_save_block: Writes a page of memory to the stream f
  *
@@ -494,7 +506,6 @@  static void reset_ram_globals(void)

 static int ram_save_setup(QEMUFile *f, void *opaque)
 {
-    ram_addr_t addr;
     RAMBlock *block;

     memory_global_sync_dirty_bitmap(get_system_memory());
@@ -516,12 +527,7 @@  static int ram_save_setup(QEMUFile *f, void *opaque)

     /* Make sure all dirty bits are set */
     QLIST_FOREACH(block, &ram_list.blocks, next) {
-        for (addr = 0; addr < block->length; addr += TARGET_PAGE_SIZE) {
-            if (!memory_region_get_dirty(block->mr, addr, TARGET_PAGE_SIZE,
-                                         DIRTY_MEMORY_MIGRATION)) {
-                memory_region_set_dirty(block->mr, addr, TARGET_PAGE_SIZE);
-            }
-        }
+        migration_bitmap_set_dirty(block->mr, block->length);
     }

     memory_global_dirty_log_start();