migration/colo: Optimize COLO framework code
cover migration/colo: Optimize COLO framework code
From: Zhang Chen <[email protected]>
This series optimize some code of COLO, please review.
Zhang Chen (3):
migration/colo: Optimize COLO boot code path migration/colo: Update checkpoint time lately migration/colo: Merge multi checkpoint request into one.
migration/colo.c | 29 ++++++++++++++++++----------- migration/migration.c | 17 ++++++++++------- 2 files changed, 28 insertions(+), 18 deletions(-)
Signature · 1 line
2.17.1
PATCH 1/3 migration/colo: Optimize COLO boot code path
From: Zhang Chen <[email protected]>
No need to reuse MIGRATION_STATUS_ACTIVE boot COLO.
--- migration/colo.c | 2 -- migration/migration.c | 17 ++++++++++------- 2 files changed, 10 insertions(+), 9 deletions(-)
migration/colo.c +0 -2
@@ -669,8 +669,6 @@ void migrate_start_colo_process(MigrationState *s) colo_checkpoint_notify, s);qemu_sem_init (&s->colo_exit_sem,0 ); -migrate_set_state (&s->state,MIGRATION_STATUS_ACTIVE , -MIGRATION_STATUS_COLO );colo_process_checkpoint (s);qemu_mutex_lock_iothread (); }
migration/migration.c +10 -7
@@ -2972,7 +2972,10 @@ static void migration_completion(MigrationState *s) goto fail_invalidate; } -if (!migrate_colo_enabled ()) { +if (migrate_colo_enabled ()) { +migrate_set_state (&s->state, current_active_state, +MIGRATION_STATUS_COLO ); + }else {migrate_set_state (&s->state, current_active_state,MIGRATION_STATUS_COMPLETED ); }
@@ -3304,12 +3307,7 @@ static void migration_iteration_finish(MigrationState *s)migration_calculate_complete (s);runstate_set (RUN_STATE_POSTMIGRATE );break ; - -case MIGRATION_STATUS_ACTIVE : -/* -* We should really assert here, but since it's during -* migration, let's try to reduce the usage of assertions. -*/ +case MIGRATION_STATUS_COLO :if (!migrate_colo_enabled ()) {error_report ("%s: critical error: calling COLO code without " "COLO enabled" , __func__);
@@ -3319,6 +3317,11 @@ static void migration_iteration_finish(MigrationState *s)* Fixme: we will run VM in COLO no matter its old running state. * After exited COLO, we will keep running. */ +case MIGRATION_STATUS_ACTIVE : +/* +* We should really assert here, but since it's during +* migration, let's try to reduce the usage of assertions. +*/ s->vm_was_running = true;/* Fallthrough */ case MIGRATION_STATUS_FAILED :
Signature · 1 line
2.17.1
RE: [PATCH 1/3] migration/colo: Optimize COLO boot code path
Quoted 79 lines
-----Original Message-----
From: Zhang Chen [mailto:[email protected]]
Sent: Friday, May 15, 2020 12:28 PM
To: Dr . David Alan Gilbert <[email protected]>; Juan Quintela <[email protected]>; Zhanghailiang <[email protected]>; qemu-dev <[email protected]>
Cc: Zhang Chen <[email protected]>; Jason Wang <[email protected]>; Zhang Chen <[email protected]>
Subject: [PATCH 1/3] migration/colo: Optimize COLO boot code pathFrom: Zhang Chen <[email protected]>
No need to reuse
MIGRATION_STATUS_ACTIVEboot COLO.Signed-off-by Zhang Chen <[email protected]>--- migration/colo.c | 2 -- migration/migration.c | 17 ++++++++++------- 2 files changed, 10 insertions(+), 9 deletions(-)migration/colo.c index renamed from migration/colo.c +0
-0
d015d4f84e..5ef69b885d100644migration/colo.c +0
-2@@ -669,8 +669,6 @@ void migrate_start_colo_process(MigrationState *s) colo_checkpoint_notify, s);qemu_sem_init (&s->colo_exit_sem,0 ); -migrate_set_state (&s->state,MIGRATION_STATUS_ACTIVE , -MIGRATION_STATUS_COLO );colo_process_checkpoint (s);qemu_mutex_lock_iothread (); }migration/migration.c index renamed from migration/migration.c +0
-0
0bb042a0f7..c889ef6eb7100644migration/migration.c +4
-1@@ -2972,7 +2972,10 @@ static void migration_completion(MigrationState *s) goto fail_invalidate; } -if (!migrate_colo_enabled ()) { +if (migrate_colo_enabled ()) { +migrate_set_state (&s->state, current_active_state, +MIGRATION_STATUS_COLO ); + }else {migrate_set_state (&s->state, current_active_state,MIGRATION_STATUS_COMPLETED );}migration/migration.c +1
-6@@ -3304,12 +3307,7 @@ static void migration_iteration_finish(MigrationState *s)migration_calculate_complete (s);runstate_set (RUN_STATE_POSTMIGRATE );break ; - -case MIGRATION_STATUS_ACTIVE : -/* -* We should really assert here, but since it's during -* migration, let's try to reduce the usage of assertions. -*/ +case MIGRATION_STATUS_COLO :if (!migrate_colo_enabled ()) { error_report("%s: critical error: calling COLO code without ""COLO enabled", __func__); @@ -3319,6+3317,11 @@ static void
migration_iteration_finish(MigrationState *s)
* Fixme: we will run VM in COLO no matter its old running state.
* After exited COLO, we will keep running.
*/migration/migration.c +5
-1+case MIGRATION_STATUS_ACTIVE : +/* +* We should really assert here, but since it's during +* migration, let's try to reduce the usage of assertions. +*/ s->vm_was_running = true;/* Fallthrough */ case MIGRATION_STATUS_FAILED : --2.17.1
PATCH 2/3 migration/colo: Update checkpoint time lately
In reply to Zhang ChenFrom: Zhang Chen <[email protected]>
Previous operation(like vm_start and replication_start_all) will consume extra time for first forced synchronization, so reduce it in this patch.
--- migration/colo.c | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-)
migration/colo.c +2 -3
@@ -531,7 +531,6 @@ static void colo_process_checkpoint(MigrationState *s) {QIOChannelBuffer *bioc;QEMUFile *fb =NULL ; -int64_t current_time =qemu_clock_get_ms (QEMU_CLOCK_HOST );Error *local_err =NULL ;int ret;
@@ -580,8 +579,8 @@ static void colo_process_checkpoint(MigrationState *s)qemu_mutex_unlock_iothread ();trace_colo_vm_state_change ("stop" ,"run" ); -timer_mod (s->colo_delay_timer, - current_time + s->parameters.x_checkpoint_delay); +timer_mod (s->colo_delay_timer,qemu_clock_get_ms (QEMU_CLOCK_HOST ) + + s->parameters.x_checkpoint_delay);while (s->state ==MIGRATION_STATUS_COLO ) {if (failover_get_state () !=FAILOVER_STATUS_NONE ) {
Signature · 1 line
2.17.1
RE: [PATCH 2/3] migration/colo: Update checkpoint time lately
Hmm, How much time it spends on preparing before COLO process ?
Quoted 47 lines
-----Original Message-----
From: Zhang Chen [mailto:[email protected]]
Sent: Friday, May 15, 2020 12:28 PM
To: Dr . David Alan Gilbert <[email protected]>; Juan Quintela <[email protected]>; Zhanghailiang <[email protected]>; qemu-dev <[email protected]>
Cc: Zhang Chen <[email protected]>; Jason Wang <[email protected]>; Zhang Chen <[email protected]>
Subject: [PATCH 2/3] migration/colo: Update checkpoint time latelyFrom: Zhang Chen <[email protected]>
Previous
operation(like vm_start and replication_start_all)will consume extra time for first forced synchronization, so reduce it in this patch.Signed-off-by Zhang Chen <[email protected]>--- migration/colo.c | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-)migration/colo.c index renamed from migration/colo.c +0
-0
5ef69b885d..d5bced22cb100644migration/colo.c +1
-3@@ -531,7 +531,6 @@ static void colo_process_checkpoint(MigrationState *s) {QIOChannelBuffer *bioc;QEMUFile *fb =NULL ; -int64_t current_time =qemu_clock_get_ms (QEMU_CLOCK_HOST );Error *local_err =NULL ;int ret;@@ -580,8 +579,8 @@ static void colo_process_checkpoint(MigrationState *s)qemu_mutex_unlock_iothread ();trace_colo_vm_state_change ("stop" ,"run" ); -timer_mod (s->colo_delay_timer, - current_time + s->parameters.x_checkpoint_delay); + timer_mod(s->colo_delay_timer,
qemu_clock_get_ms(QEMU_CLOCK_HOST)+
+s->parameters.x_checkpoint_delay);while (s->state == MIGRATION_STATUS_COLO) { if (failover_get_state() != FAILOVER_STATUS_NONE) {--
2.17.1
PATCH 3/3 migration/colo: Merge multi checkpoint request into one.
In reply to Zhang ChenFrom: Zhang Chen <[email protected]>
When COLO guest occur issues, COLO-compare will catch lots of different network packet and trigger notification multi times, force periodic may happen at the same time. So this can be efficient merge checkpoint request within COLO_CHECKPOINT_INTERVAL.
--- migration/colo.c | 22 ++++++++++++++++------ 1 file changed, 16 insertions(+), 6 deletions(-)
migration/colo.c +16 -6
@@ -47,6 +47,9 @@ static COLOMode last_colo_mode;#define COLO_BUFFER_BASE_SIZE (4 * 1024 * 1024) +/* Default COLO_CHECKPOINT_INTERVAL is 1000 ms */ +#define COLO_CHECKPOINT_INTERVAL 1000 +bool migration_in_colo_state (void ) {MigrationState *s =migrate_get_current ();
@@ -651,13 +654,20 @@ out:void colo_checkpoint_notify (void *opaque) {MigrationState *s = opaque; -int64_t next_notify_time; +int64_t now =qemu_clock_get_ms (QEMU_CLOCK_HOST ); -qemu_sem_post (&s->colo_checkpoint_sem); - s->colo_checkpoint_time =qemu_clock_get_ms (QEMU_CLOCK_HOST ); - next_notify_time = s->colo_checkpoint_time + - s->parameters.x_checkpoint_delay; -timer_mod (s->colo_delay_timer, next_notify_time); +/* +* When COLO guest occur issues, COLO-compare will catch lots of +* different network packet and trigger notification multi times, +* force periodic may happen at the same time. So this can be +* efficient merge checkpoint request within COLO_CHECKPOINT_INTERVAL. +*/ +if (now > s->colo_checkpoint_time +COLO_CHECKPOINT_INTERVAL ) { +qemu_sem_post (&s->colo_checkpoint_sem); +timer_mod (s->colo_delay_timer, now + + s->parameters.x_checkpoint_delay); + s->colo_checkpoint_time = now; + } }void migrate_start_colo_process (MigrationState *s)
Signature · 1 line
2.17.1
RE: [PATCH 3/3] migration/colo: Merge multi checkpoint request into one.
Quoted 56 lines
-----Original Message-----
From: Zhang Chen [mailto:[email protected]]
Sent: Friday, May 15, 2020 12:28 PM
To: Dr . David Alan Gilbert <[email protected]>; Juan Quintela <[email protected]>; Zhanghailiang <[email protected]>; qemu-dev <[email protected]>
Cc: Zhang Chen <[email protected]>; Jason Wang <[email protected]>; Zhang Chen <[email protected]>
Subject: [PATCH 3/3] migration/colo: Merge multi checkpoint request into one.From: Zhang Chen <[email protected]>
When COLO guest occur issues, COLO-compare will catch lots of different network packet and trigger notification multi times, force periodic may happen at the same time. So this can be efficient merge checkpoint request within
COLO_CHECKPOINT_INTERVAL.Signed-off-by Zhang Chen <[email protected]>--- migration/colo.c | 22 ++++++++++++++++------ 1 file changed, 16 insertions(+), 6 deletions(-)migration/colo.c index renamed from migration/colo.c +0
-0
d5bced22cb..e6a7d8c6e2100644migration/colo.c +3
-0@@ -47,6 +47,9 @@ static COLOMode last_colo_mode;#define COLO_BUFFER_BASE_SIZE (4 * 1024 * 1024) +/* Default COLO_CHECKPOINT_INTERVAL is 1000 ms */ #define +COLO_CHECKPOINT_INTERVAL 1000 +bool migration_in_colo_state (void ) { MigrationState *s = migrate_get_current(); @@ -651,13 +654,20 @@out:
void colo_checkpoint_notify(void *opaque) { MigrationState *s = opaque;migration/colo.c +6
-6-int64_t next_notify_time; +int64_t now =qemu_clock_get_ms (QEMU_CLOCK_HOST ); -qemu_sem_post (&s->colo_checkpoint_sem); - s->colo_checkpoint_time =qemu_clock_get_ms (QEMU_CLOCK_HOST ); - next_notify_time = s->colo_checkpoint_time + - s->parameters.x_checkpoint_delay; -timer_mod (s->colo_delay_timer, next_notify_time); +/* +* When COLO guest occur issues, COLO-compare will catch lots of +* different network packet and trigger notification multi times, +* force periodic may happen at the same time. So this can be +* efficient merge checkpoint request within
COLO_CHECKPOINT_INTERVAL.
migration/colo.c out: · line 666
Quoted 3 lines
migration/colo.c +3
-0+*/ +if (now > s->colo_checkpoint_time +COLO_CHECKPOINT_INTERVAL ) { +qemu_sem_post (&s->colo_checkpoint_sem);
It is not right here, this notification should not be controlled by the interval time, I got what happened here, when multiple checkpoint requires come, this Colo_delay_time will be added every time and it will be a big value which is not what we want.
Besides, please update this patch based on [PATCH 0/6] colo: migration related bugfixes series which Has modified the same place.
Quoted 9 lines
migration/colo.c +4
-1+timer_mod (s->colo_delay_timer, now + + s->parameters.x_checkpoint_delay); + s->colo_checkpoint_time = now; + } }void migrate_start_colo_process (MigrationState *s) --2.17.1
RE: [PATCH 3/3] migration/colo: Merge multi checkpoint request into one.
Quoted 70 lines
-----Original Message-----
From: Zhanghailiang <[email protected]>
Sent: Tuesday, June 2, 2020 2:59 PM
To: Zhang, Chen <[email protected]>; Dr . David Alan Gilbert <[email protected]>; Juan Quintela <[email protected]>; qemu-dev <[email protected]>
Cc: Zhang Chen <[email protected]>; Jason Wang <[email protected]>
Subject: RE: [PATCH 3/3] migration/colo: Merge multi checkpoint request into one.Quoted 5 lines
-----Original Message-----
From: Zhang Chen [mailto:[email protected]]
Sent: Friday, May 15, 2020 12:28 PM
To: Dr . David Alan Gilbert <[email protected]>; Juan Quintela <[email protected]>; ZhanghailiangQuoted 49 lines
qemu-dev <[email protected]>
Cc: Zhang Chen <[email protected]>; Jason Wang <[email protected]>; Zhang Chen <[email protected]>
Subject: [PATCH 3/3] migration/colo: Merge multi checkpoint request into one.From: Zhang Chen <[email protected]>
When COLO guest occur issues, COLO-compare will catch lots of different network packet and trigger notification multi times, force periodic may happen at the same time. So this can be efficient merge checkpoint request within
COLO_CHECKPOINT_INTERVAL.Signed-off-by Zhang Chen <[email protected]>--- migration/colo.c | 22 ++++++++++++++++------ 1 file changed, 16 insertions(+), 6 deletions(-)migration/colo.c index renamed from migration/colo.c +0
-0
d5bced22cb..e6a7d8c6e2100644migration/colo.c +3
-0@@ -47,6 +47,9 @@ static COLOMode last_colo_mode;#define COLO_BUFFER_BASE_SIZE (4 * 1024 * 1024) +/* Default COLO_CHECKPOINT_INTERVAL is 1000 ms */ #define +COLO_CHECKPOINT_INTERVAL 1000 +bool migration_in_colo_state (void ) { MigrationState *s = migrate_get_current(); @@ -651,13 +654,20 @@out:
void colo_checkpoint_notify(void *opaque) { MigrationState *s = opaque;migration/colo.c +6
-6-int64_t next_notify_time; +int64_t now =qemu_clock_get_ms (QEMU_CLOCK_HOST ); -qemu_sem_post (&s->colo_checkpoint_sem); - s->colo_checkpoint_time =qemu_clock_get_ms (QEMU_CLOCK_HOST ); - next_notify_time = s->colo_checkpoint_time + - s->parameters.x_checkpoint_delay; -timer_mod (s->colo_delay_timer, next_notify_time); +/* +* When COLO guest occur issues, COLO-compare will catch lots of +* different network packet and trigger notification multi times, +* force periodic may happen at the same time. So this can be +* efficient merge checkpoint request within
COLO_CHECKPOINT_INTERVAL.
Quoted 8 lines
migration/colo.c out: · line 666
Quoted 3 lines
migration/colo.c +3
-0+*/ +if (now > s->colo_checkpoint_time +COLO_CHECKPOINT_INTERVAL ) { +qemu_sem_post (&s->colo_checkpoint_sem);It is not right here, this notification should not be controlled by the interval time, I got what happened here, when multiple checkpoint requires come, this
Colo_delay_timewill be added every time and it will be a big value which is not what we want.
Not just this, multi checkpoint will spend lots of resource to sync memory from PVM to SVM, It will make VM stop/start multi times, but for the results are same with one checkpoint. So in short time just need one checkpoint, because do checkpoint still need some time...
Thanks
Zhang Chen
Quoted 15 lines
Besides, please update this patch based on [PATCH 0/6] colo: migration related bugfixes series which Has modified the same place.
Quoted 9 lines
migration/colo.c +4
-1+timer_mod (s->colo_delay_timer, now + + s->parameters.x_checkpoint_delay); + s->colo_checkpoint_time = now; + } }void migrate_start_colo_process (MigrationState *s) --2.17.1
RE: [PATCH 3/3] migration/colo: Merge multi checkpoint request into one.
Quoted 93 lines
-----Original Message-----
From: Zhang, Chen [mailto:[email protected]]
Sent: Wednesday, June 3, 2020 5:11 PM
To: Zhanghailiang <[email protected]>; Dr . David Alan Gilbert <[email protected]>; Juan Quintela <[email protected]>; qemu-dev <[email protected]>
Cc: Zhang Chen <[email protected]>; Jason Wang <[email protected]>
Subject: RE: [PATCH 3/3] migration/colo: Merge multi checkpoint request into one.Quoted 7 lines
-----Original Message-----
From: Zhanghailiang <[email protected]>
Sent: Tuesday, June 2, 2020 2:59 PM
To: Zhang, Chen <[email protected]>; Dr . David Alan Gilbert <[email protected]>; Juan Quintela <[email protected]>; qemu-dev <[email protected]>
Cc: Zhang Chen <[email protected]>; Jason WangQuoted 50 lines
Subject: RE: [PATCH 3/3] migration/colo: Merge multi checkpoint request into one.
Quoted 5 lines
-----Original Message-----
From: Zhang Chen [mailto:[email protected]]
Sent: Friday, May 15, 2020 12:28 PM
To: Dr . David Alan Gilbert <[email protected]>; Juan Quintela <[email protected]>; ZhanghailiangQuoted 39 lines
qemu-dev <[email protected]>
Cc: Zhang Chen <[email protected]>; Jason Wang <[email protected]>; Zhang Chen <[email protected]>
Subject: [PATCH 3/3] migration/colo: Merge multi checkpoint request into one.From: Zhang Chen <[email protected]>
When COLO guest occur issues, COLO-compare will catch lots of different network packet and trigger notification multi times, force periodic may happen at the same time. So this can be efficient merge checkpoint request within
COLO_CHECKPOINT_INTERVAL.Signed-off-by Zhang Chen <[email protected]>--- migration/colo.c | 22 ++++++++++++++++------ 1 file changed, 16 insertions(+), 6 deletions(-)migration/colo.c index renamed from migration/colo.c +0
-0
d5bced22cb..e6a7d8c6e2100644migration/colo.c +3
-0@@ -47,6 +47,9 @@ static COLOMode last_colo_mode;#define COLO_BUFFER_BASE_SIZE (4 * 1024 * 1024) +/* Default COLO_CHECKPOINT_INTERVAL is 1000 ms */ #define +COLO_CHECKPOINT_INTERVAL 1000 +bool migration_in_colo_state (void ) { MigrationState *s = migrate_get_current(); @@ -651,13 +654,20@@
out:void colo_checkpoint_notify(void *opaque) { MigrationState *s = opaque;migration/colo.c +1
-1-int64_t next_notify_time; +int64_t now =qemu_clock_get_ms (QEMU_CLOCK_HOST );Quoted 2 lines
migration/colo.c
Quoted 2 lines
migration/colo.c +0
-2-qemu_sem_post (&s->colo_checkpoint_sem); - s->colo_checkpoint_time =
qemu_clock_get_ms(QEMU_CLOCK_HOST);Quoted 11 lines
migration/colo.c
Quoted 11 lines
migration/colo.c +5
-3- next_notify_time = s->colo_checkpoint_time + - s->parameters.x_checkpoint_delay; -timer_mod (s->colo_delay_timer, next_notify_time); +/* +* When COLO guest occur issues, COLO-compare will catch lots of +* different network packet and trigger notification multi times, +* force periodic may happen at the same time. So this can be +* efficient merge checkpoint request within
COLO_CHECKPOINT_INTERVAL.migration/colo.c +2
-0+*/ +if (now > s->colo_checkpoint_time +COLO_CHECKPOINT_INTERVAL ){
Quoted 6 lines
Quoted 1 line
+
qemu_sem_post(&s->colo_checkpoint_sem);It is not right here, this notification should not be controlled by the interval time, I got what happened here, when multiple checkpoint requires come, this
Colo_delay_timewill be added every time and it will be a big value which is not what we want.
Quoted 6 lines
Not just this, multi checkpoint will spend lots of resource to sync memory from PVM to SVM, It will make VM stop/start multi times, but for the results are same with one checkpoint.
So in short time just need one checkpoint, because do checkpoint still need some time...
Yes, this because we use semaphore here, it will be increased multiple times,
And I think Lukas's patch 'migration/colo.c: Use event instead of semaphore' has fixed this problem. Did you try the qemu upstream which has merged this patch ?
Quoted 18 lines
Thanks
Zhang ChenQuoted 15 lines
Besides, please update this patch based on [PATCH 0/6] colo: migration related bugfixes series which Has modified the same place.
Quoted 9 lines
migration/colo.c +4
-1+timer_mod (s->colo_delay_timer, now + + s->parameters.x_checkpoint_delay); + s->colo_checkpoint_time = now; + } }void migrate_start_colo_process (MigrationState *s) --2.17.1
RE: [PATCH 3/3] migration/colo: Merge multi checkpoint request into one.
Quoted 114 lines
-----Original Message-----
From: Zhanghailiang <[email protected]>
Sent: Wednesday, June 3, 2020 5:39 PM
To: Zhang, Chen <[email protected]>; Dr . David Alan Gilbert <[email protected]>; Juan Quintela <[email protected]>; qemu-dev <[email protected]>
Cc: Zhang Chen <[email protected]>; Jason Wang <[email protected]>
Subject: RE: [PATCH 3/3] migration/colo: Merge multi checkpoint request into one.Quoted 7 lines
-----Original Message-----
From: Zhang, Chen [mailto:[email protected]]
Sent: Wednesday, June 3, 2020 5:11 PM
To: Zhanghailiang <[email protected]>; Dr . David Alan Gilbert <[email protected]>; Juan Quintela <[email protected]>; qemu-dev <[email protected]>
Cc: Zhang Chen <[email protected]>; Jason WangQuoted 10 lines
Subject: RE: [PATCH 3/3] migration/colo: Merge multi checkpoint request into one.
Quoted 5 lines
-----Original Message-----
From: Zhanghailiang <[email protected]>
Sent: Tuesday, June 2, 2020 2:59 PM
To: Zhang, Chen <[email protected]>; Dr . David Alan Gilbert <[email protected]>; Juan Quintela <[email protected]>; qemu-dev
Quoted 26 lines
Quoted 2 lines
<[email protected]>
Cc: Zhang Chen <[email protected]>; Jason WangQuoted 23 lines
Subject: RE: [PATCH 3/3] migration/colo: Merge multi checkpoint request into one.
Quoted 5 lines
-----Original Message-----
From: Zhang Chen [mailto:[email protected]]
Sent: Friday, May 15, 2020 12:28 PM
To: Dr . David Alan Gilbert <[email protected]>; Juan Quintela <[email protected]>; ZhanghailiangQuoted 12 lines
qemu-dev <[email protected]>
Cc: Zhang Chen <[email protected]>; Jason Wang <[email protected]>; Zhang Chen <[email protected]>
Subject: [PATCH 3/3] migration/colo: Merge multi checkpoint request into one.From: Zhang Chen <[email protected]>
When COLO guest occur issues, COLO-compare will catch lots of different network packet and trigger notification multi times, force periodic may happen at the same time. So this can be efficient merge checkpoint request within
COLO_CHECKPOINT_INTERVAL.Quoted 48 lines
Quoted 26 lines
Quoted 26 lines
Signed-off-by Zhang Chen <[email protected]>--- migration/colo.c | 22 ++++++++++++++++------ 1 file changed, 16 insertions(+), 6 deletions(-)migration/colo.c index renamed from migration/colo.c +0
-0
d5bced22cb..e6a7d8c6e2100644migration/colo.c +3
-0@@ -47,6 +47,9 @@ static COLOMode last_colo_mode;#define COLO_BUFFER_BASE_SIZE (4 * 1024 * 1024) +/* Default COLO_CHECKPOINT_INTERVAL is 1000 ms */ #define +COLO_CHECKPOINT_INTERVAL 1000 +bool migration_in_colo_state (void ) { MigrationState *s = migrate_get_current(); @@ -651,13 +654,20@@
out:void colo_checkpoint_notify(void *opaque) { MigrationState *s = opaque;migration/colo.c +1
-1-int64_t next_notify_time; +int64_t now =qemu_clock_get_ms (QEMU_CLOCK_HOST );Quoted 2 lines
migration/colo.c
Quoted 2 lines
migration/colo.c +0
-2-qemu_sem_post (&s->colo_checkpoint_sem); - s->colo_checkpoint_time =
qemu_clock_get_ms(QEMU_CLOCK_HOST);Quoted 11 lines
migration/colo.c
Quoted 11 lines
migration/colo.c +5
-3- next_notify_time = s->colo_checkpoint_time + - s->parameters.x_checkpoint_delay; -timer_mod (s->colo_delay_timer, next_notify_time); +/* +* When COLO guest occur issues, COLO-compare will catch lots of +* different network packet and trigger notification multi times, +* force periodic may happen at the same time. So this can be +* efficient merge checkpoint request within
COLO_CHECKPOINT_INTERVAL.migration/colo.c +2
-0+*/ +if (now > s->colo_checkpoint_time +COLO_CHECKPOINT_INTERVAL ){
Quoted 6 lines
Quoted 1 line
+
qemu_sem_post(&s->colo_checkpoint_sem);It is not right here, this notification should not be controlled by the interval time, I got what happened here, when multiple checkpoint requires come, this
Colo_delay_timewill be added every time and it will be a big value which is not what we want.Quoted 6 lines
Not just this, multi checkpoint will spend lots of resource to sync memory from PVM to SVM, It will make VM stop/start multi times, but for the results are same with one checkpoint.
So in short time just need one checkpoint, because do checkpoint still need some time...
Quoted 4 lines
Yes, this because we use semaphore here, it will be increased multiple times, And I think Lukas's patch '
migration/colo.c: Use event instead of semaphore' has fixed this problem.
Did you try the qemu upstream which has merged this patch ?
Oh, Thanks reminder, I will drop this patch and rebase on upstream for V2.
Thank
Zhang Chen
Quoted 19 lines
Quoted 19 lines
Thanks
Zhang ChenQuoted 15 lines
Besides, please update this patch based on [PATCH 0/6] colo:
migration related bugfixes series which Has modified the same place.Quoted 9 lines
migration/colo.c +4
-1+timer_mod (s->colo_delay_timer, now + + s->parameters.x_checkpoint_delay); + s->colo_checkpoint_time = now; + } }void migrate_start_colo_process (MigrationState *s) --2.17.1