diff mbox series

migration: don't set MIGRATION dirty range for ignored block

Message ID 20190504054255.8610-1-richardw.yang@linux.intel.com (mailing list archive)
State New, archived
Headers show
Series migration: don't set MIGRATION dirty range for ignored block | expand

Commit Message

Wei Yang May 4, 2019, 5:42 a.m. UTC
The ignored blocks are not migrated and those ranges are not used.

Signed-off-by: Wei Yang <richardw.yang@linux.intel.com>
---
 exec.c                  | 4 +++-
 include/exec/ram_addr.h | 2 ++
 migration/ram.c         | 2 +-
 3 files changed, 6 insertions(+), 2 deletions(-)

Comments

Wei Yang May 5, 2019, 3:29 a.m. UTC | #1
On Sat, May 04, 2019 at 01:42:55PM +0800, Wei Yang wrote:
>The ignored blocks are not migrated and those ranges are not used.

My bad, this change is not correct.

>
>Signed-off-by: Wei Yang <richardw.yang@linux.intel.com>
>---
> exec.c                  | 4 +++-
> include/exec/ram_addr.h | 2 ++
> migration/ram.c         | 2 +-
> 3 files changed, 6 insertions(+), 2 deletions(-)
>
>diff --git a/exec.c b/exec.c
>index 86a38d3b3b..97da155c12 100644
>--- a/exec.c
>+++ b/exec.c
>@@ -2192,6 +2192,8 @@ static void ram_block_add(RAMBlock *new_block, Error **errp, bool shared)
>     RAMBlock *last_block = NULL;
>     ram_addr_t old_ram_size, new_ram_size;
>     Error *err = NULL;
>+    uint8_t dirty_memory_clients = ramblock_is_ignored(new_block) ?
>+                         DIRTY_CLIENTS_NOMIG : DIRTY_CLIENTS_ALL;
> 
>     old_ram_size = last_ram_page();
> 
>@@ -2252,7 +2254,7 @@ static void ram_block_add(RAMBlock *new_block, Error **errp, bool shared)
> 
>     cpu_physical_memory_set_dirty_range(new_block->offset,
>                                         new_block->used_length,
>-                                        DIRTY_CLIENTS_ALL);
>+                                        dirty_memory_clients);
> 
>     if (new_block->host) {
>         qemu_ram_setup_dump(new_block->host, new_block->max_length);
>diff --git a/include/exec/ram_addr.h b/include/exec/ram_addr.h
>index a7c81bdb32..4765435fb8 100644
>--- a/include/exec/ram_addr.h
>+++ b/include/exec/ram_addr.h
>@@ -72,6 +72,7 @@ static inline unsigned long int ramblock_recv_bitmap_offset(void *host_addr,
> }
> 
> bool ramblock_is_pmem(RAMBlock *rb);
>+bool ramblock_is_ignored(RAMBlock *rb);
> 
> long qemu_getrampagesize(void);
> 
>@@ -117,6 +118,7 @@ int qemu_ram_resize(RAMBlock *block, ram_addr_t newsize, Error **errp);
> 
> #define DIRTY_CLIENTS_ALL     ((1 << DIRTY_MEMORY_NUM) - 1)
> #define DIRTY_CLIENTS_NOCODE  (DIRTY_CLIENTS_ALL & ~(1 << DIRTY_MEMORY_CODE))
>+#define DIRTY_CLIENTS_NOMIG   (DIRTY_CLIENTS_ALL & ~(1 << DIRTY_MEMORY_MIGRATION))
> 
> void tb_invalidate_phys_range(ram_addr_t start, ram_addr_t end);
> 
>diff --git a/migration/ram.c b/migration/ram.c
>index 1def8122e9..44525e3816 100644
>--- a/migration/ram.c
>+++ b/migration/ram.c
>@@ -159,7 +159,7 @@ out:
>     return ret;
> }
> 
>-static bool ramblock_is_ignored(RAMBlock *block)
>+bool ramblock_is_ignored(RAMBlock *block)
> {
>     return !qemu_ram_is_migratable(block) ||
>            (migrate_ignore_shared() && qemu_ram_is_shared(block));
>-- 
>2.19.1
diff mbox series

Patch

diff --git a/exec.c b/exec.c
index 86a38d3b3b..97da155c12 100644
--- a/exec.c
+++ b/exec.c
@@ -2192,6 +2192,8 @@  static void ram_block_add(RAMBlock *new_block, Error **errp, bool shared)
     RAMBlock *last_block = NULL;
     ram_addr_t old_ram_size, new_ram_size;
     Error *err = NULL;
+    uint8_t dirty_memory_clients = ramblock_is_ignored(new_block) ?
+                         DIRTY_CLIENTS_NOMIG : DIRTY_CLIENTS_ALL;
 
     old_ram_size = last_ram_page();
 
@@ -2252,7 +2254,7 @@  static void ram_block_add(RAMBlock *new_block, Error **errp, bool shared)
 
     cpu_physical_memory_set_dirty_range(new_block->offset,
                                         new_block->used_length,
-                                        DIRTY_CLIENTS_ALL);
+                                        dirty_memory_clients);
 
     if (new_block->host) {
         qemu_ram_setup_dump(new_block->host, new_block->max_length);
diff --git a/include/exec/ram_addr.h b/include/exec/ram_addr.h
index a7c81bdb32..4765435fb8 100644
--- a/include/exec/ram_addr.h
+++ b/include/exec/ram_addr.h
@@ -72,6 +72,7 @@  static inline unsigned long int ramblock_recv_bitmap_offset(void *host_addr,
 }
 
 bool ramblock_is_pmem(RAMBlock *rb);
+bool ramblock_is_ignored(RAMBlock *rb);
 
 long qemu_getrampagesize(void);
 
@@ -117,6 +118,7 @@  int qemu_ram_resize(RAMBlock *block, ram_addr_t newsize, Error **errp);
 
 #define DIRTY_CLIENTS_ALL     ((1 << DIRTY_MEMORY_NUM) - 1)
 #define DIRTY_CLIENTS_NOCODE  (DIRTY_CLIENTS_ALL & ~(1 << DIRTY_MEMORY_CODE))
+#define DIRTY_CLIENTS_NOMIG   (DIRTY_CLIENTS_ALL & ~(1 << DIRTY_MEMORY_MIGRATION))
 
 void tb_invalidate_phys_range(ram_addr_t start, ram_addr_t end);
 
diff --git a/migration/ram.c b/migration/ram.c
index 1def8122e9..44525e3816 100644
--- a/migration/ram.c
+++ b/migration/ram.c
@@ -159,7 +159,7 @@  out:
     return ret;
 }
 
-static bool ramblock_is_ignored(RAMBlock *block)
+bool ramblock_is_ignored(RAMBlock *block)
 {
     return !qemu_ram_is_migratable(block) ||
            (migrate_ignore_shared() && qemu_ram_is_shared(block));