diff mbox

[COLO-Frame,v6,12/31] arch_init: Start to trace dirty pages of SVM

Message ID 1434617935-6924-13-git-send-email-zhang.zhanghailiang@huawei.com
State New
Headers show

Commit Message

Zhanghailiang June 18, 2015, 8:58 a.m. UTC
we will use this dirty bitmap together with VM's cache RAM dirty bitmap
to decide which page in cache should be flushed into VM's RAM.

Signed-off-by: zhanghailiang <zhang.zhanghailiang@huawei.com>
Signed-off-by: Li Zhijian <lizhijian@cn.fujitsu.com>
---
 migration/ram.c | 16 ++++++++++++++++
 1 file changed, 16 insertions(+)
diff mbox

Patch

diff --git a/migration/ram.c b/migration/ram.c
index ded13f8..8c9edf0 100644
--- a/migration/ram.c
+++ b/migration/ram.c
@@ -1621,6 +1621,7 @@  static int ram_load(QEMUFile *f, void *opaque, int version_id)
 int create_and_init_ram_cache(void)
 {
     RAMBlock *block;
+    int64_t ram_cache_pages = last_ram_offset() >> TARGET_PAGE_BITS;
 
     rcu_read_lock();
     QLIST_FOREACH_RCU(block, &ram_list.blocks, next) {
@@ -1632,6 +1633,15 @@  int create_and_init_ram_cache(void)
     }
     rcu_read_unlock();
     ram_cache_enable = true;
+    /*
+    * Start dirty log for Secondary VM, we use this dirty bitmap together with
+    * VM's cache RAM dirty bitmap to decide which page in cache should be
+    * flushed into VM's RAM.
+    */
+    migration_bitmap = bitmap_new(ram_cache_pages);
+    migration_dirty_pages = 0;
+    memory_global_dirty_log_start();
+
     return 0;
 
 out_locked:
@@ -1652,6 +1662,12 @@  void release_ram_cache(void)
 
     ram_cache_enable = false;
 
+    if (migration_bitmap) {
+        memory_global_dirty_log_stop();
+        g_free(migration_bitmap);
+        migration_bitmap = NULL;
+    }
+
     rcu_read_lock();
     QLIST_FOREACH_RCU(block, &ram_list.blocks, next) {
         if (block->host_cache) {