diff mbox

[COLO-Frame,v8,30/34] COLO: Improve checkpoint efficiency by do additional periodic checkpoint

Message ID 1438159544-6224-31-git-send-email-zhang.zhanghailiang@huawei.com
State New
Headers show

Commit Message

Zhanghailiang July 29, 2015, 8:45 a.m. UTC
Besides normal checkpoint which according to the result of net packets
comparing, We do additional checkpoint periodically, it will reduce the number
of dirty pages when do one checkpoint, if we don't do checkpoint for a long
time (This is a special case when the net packets is always consistent).

Signed-off-by: zhanghailiang <zhang.zhanghailiang@huawei.com>
Signed-off-by: Yang Hongyang <yanghy@cn.fujitsu.com>
---
 migration/colo.c | 29 +++++++++++++++++++++--------
 1 file changed, 21 insertions(+), 8 deletions(-)
diff mbox

Patch

diff --git a/migration/colo.c b/migration/colo.c
index f9f2156..f5bb668 100644
--- a/migration/colo.c
+++ b/migration/colo.c
@@ -10,6 +10,7 @@ 
  * later.  See the COPYING file in the top-level directory.
  */
 
+#include "qemu/timer.h"
 #include "sysemu/sysemu.h"
 #include "migration/colo.h"
 #include "trace.h"
@@ -26,6 +27,13 @@ 
 */
 #define CHECKPOINT_MIN_PERIOD 100  /* unit: ms */
 
+/*
+ * force checkpoint timer: unit ms
+ * this is large because COLO checkpoint will mostly depend on
+ * COLO compare module.
+ */
+#define CHECKPOINT_MAX_PEROID 10000
+
 /* Fix me: Convert to use QAPI */
 typedef enum COLOCommand {
     COLO_CHECPOINT_READY = 0x46,
@@ -394,14 +402,7 @@  static void *colo_thread(void *opaque)
         proxy_checkpoint_req = colo_proxy_compare();
         if (proxy_checkpoint_req < 0) {
             goto out;
-        } else if (!proxy_checkpoint_req) {
-            /*
-             * No checkpoint is needed, wait for 1ms and then
-             * check if we need checkpoint again
-             */
-            g_usleep(1000);
-            continue;
-        } else {
+        } else if (proxy_checkpoint_req) {
             int64_t interval;
 
             current_time = qemu_clock_get_ms(QEMU_CLOCK_HOST);
@@ -410,8 +411,20 @@  static void *colo_thread(void *opaque)
                 /* Limit the min time between two checkpoint */
                 g_usleep((1000*(CHECKPOINT_MIN_PERIOD - interval)));
             }
+            goto do_checkpoint;
+        }
+
+        /*
+         * No proxy checkpoint is request, wait for 100ms
+         * and then check if we need checkpoint again.
+         */
+        current_time = qemu_clock_get_ms(QEMU_CLOCK_HOST);
+        if (current_time - checkpoint_time < CHECKPOINT_MAX_PEROID) {
+            g_usleep(100000);
+            continue;
         }
 
+do_checkpoint:
         /* start a colo checkpoint */
         if (colo_do_checkpoint_transaction(s, colo_control)) {
             goto out;