diff mbox series

[V2,5/8] ram/colo: only record bitmap of dirty pages in COLO stage

Message ID 20200224065414.36524-6-zhang.zhanghailiang@huawei.com (mailing list archive)
State New, archived
Headers show
Series None | expand

Commit Message

Zhanghailiang Feb. 24, 2020, 6:54 a.m. UTC
It is only need to record bitmap of dirty pages while goes
into COLO stage.

Signed-off-by: zhanghailiang <zhang.zhanghailiang@huawei.com>
---
 migration/ram.c | 9 +++++----
 1 file changed, 5 insertions(+), 4 deletions(-)

Comments

Dr. David Alan Gilbert March 12, 2020, 6:55 p.m. UTC | #1
* zhanghailiang (zhang.zhanghailiang@huawei.com) wrote:
> It is only need to record bitmap of dirty pages while goes
> into COLO stage.
> 
> Signed-off-by: zhanghailiang <zhang.zhanghailiang@huawei.com>

Reviewed-by: Dr. David Alan Gilbert <dgilbert@redhat.com>

and queued

> ---
>  migration/ram.c | 9 +++++----
>  1 file changed, 5 insertions(+), 4 deletions(-)
> 
> diff --git a/migration/ram.c b/migration/ram.c
> index ebf9e6ba51..1b3f423351 100644
> --- a/migration/ram.c
> +++ b/migration/ram.c
> @@ -2735,7 +2735,7 @@ static inline void *host_from_ram_block_offset(RAMBlock *block,
>  }
>  
>  static inline void *colo_cache_from_block_offset(RAMBlock *block,
> -                                                 ram_addr_t offset)
> +                             ram_addr_t offset, bool record_bitmap)
>  {
>      if (!offset_in_ramblock(block, offset)) {
>          return NULL;
> @@ -2751,7 +2751,8 @@ static inline void *colo_cache_from_block_offset(RAMBlock *block,
>      * It help us to decide which pages in ram cache should be flushed
>      * into VM's RAM later.
>      */
> -    if (!test_and_set_bit(offset >> TARGET_PAGE_BITS, block->bmap)) {
> +    if (record_bitmap &&
> +        !test_and_set_bit(offset >> TARGET_PAGE_BITS, block->bmap)) {
>          ram_state->migration_dirty_pages++;
>      }
>      return block->colo_cache + offset;
> @@ -3408,13 +3409,13 @@ static int ram_load_precopy(QEMUFile *f)
>              if (migration_incoming_colo_enabled()) {
>                  if (migration_incoming_in_colo_state()) {
>                      /* In COLO stage, put all pages into cache temporarily */
> -                    host = colo_cache_from_block_offset(block, addr);
> +                    host = colo_cache_from_block_offset(block, addr, true);
>                  } else {
>                     /*
>                      * In migration stage but before COLO stage,
>                      * Put all pages into both cache and SVM's memory.
>                      */
> -                    host_bak = colo_cache_from_block_offset(block, addr);
> +                    host_bak = colo_cache_from_block_offset(block, addr, false);
>                  }
>              }
>              if (!host) {
> -- 
> 2.21.0
> 
> 
--
Dr. David Alan Gilbert / dgilbert@redhat.com / Manchester, UK
diff mbox series

Patch

diff --git a/migration/ram.c b/migration/ram.c
index ebf9e6ba51..1b3f423351 100644
--- a/migration/ram.c
+++ b/migration/ram.c
@@ -2735,7 +2735,7 @@  static inline void *host_from_ram_block_offset(RAMBlock *block,
 }
 
 static inline void *colo_cache_from_block_offset(RAMBlock *block,
-                                                 ram_addr_t offset)
+                             ram_addr_t offset, bool record_bitmap)
 {
     if (!offset_in_ramblock(block, offset)) {
         return NULL;
@@ -2751,7 +2751,8 @@  static inline void *colo_cache_from_block_offset(RAMBlock *block,
     * It help us to decide which pages in ram cache should be flushed
     * into VM's RAM later.
     */
-    if (!test_and_set_bit(offset >> TARGET_PAGE_BITS, block->bmap)) {
+    if (record_bitmap &&
+        !test_and_set_bit(offset >> TARGET_PAGE_BITS, block->bmap)) {
         ram_state->migration_dirty_pages++;
     }
     return block->colo_cache + offset;
@@ -3408,13 +3409,13 @@  static int ram_load_precopy(QEMUFile *f)
             if (migration_incoming_colo_enabled()) {
                 if (migration_incoming_in_colo_state()) {
                     /* In COLO stage, put all pages into cache temporarily */
-                    host = colo_cache_from_block_offset(block, addr);
+                    host = colo_cache_from_block_offset(block, addr, true);
                 } else {
                    /*
                     * In migration stage but before COLO stage,
                     * Put all pages into both cache and SVM's memory.
                     */
-                    host_bak = colo_cache_from_block_offset(block, addr);
+                    host_bak = colo_cache_from_block_offset(block, addr, false);
                 }
             }
             if (!host) {