migration/colo: Optimize COLO start code path
PATCH 1/2 migration/colo: Optimize COLO start code path
There is no need to start COLO through MIGRATION_STATUS_ACTIVE.
--- migration/colo.c | 2 -- migration/migration.c | 18 +++++++++++------- 2 files changed, 11 insertions(+), 9 deletions(-)
migration/colo.c +0 -2
@@ -667,8 +667,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 +11 -7
@@ -3222,7 +3222,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 ); }
@@ -3607,12 +3610,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__);
@@ -3622,6 +3620,12 @@ 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. */ +/* Fallthrough */ +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.25.1
PATCH 2/2 migration/colo: More accurate update checkpoint time
Previous operation(like vm_start and replication_start_all) will consume extra time before update the timer, so reduce time in this patch.
--- migration/colo.c | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-)
migration/colo.c +2 -3
@@ -530,7 +530,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;
@@ -578,8 +577,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.25.1
Re: [PATCH 2/2] migration/colo: More accurate update checkpoint time
Quoted 4 lines · Zhang Chen
Previous
operation(like vm_start and replication_start_all)will consume extra time before update the timer, so reduce time in this patch.Signed-off-by Zhang Chen <[email protected]>
Queued for 7.0.
Quoted 1 line · Zhang Chen
There is no need to start COLO through
MIGRATION_STATUS_ACTIVE.
Hi
I don't understand what you are trying to do. In my reading, at least the commit message is wrong:
void migrate_start_colo_process(MigrationState *s)
{
...
migrate_set_state(&s->state, MIGRATION_STATUS_ACTIVE,
MIGRATION_STATUS_COLO);
...
}and
void *colo_process_incoming_thread(void *opaque)
{
...
migrate_set_state(&mis->state, MIGRATION_STATUS_ACTIVE,
MIGRATION_STATUS_COLO);So colo starts with MIGRATION_STATUS_ACTIVE.
Quoted 25 lines
Signed-off-by Zhang Chen <[email protected]>--- migration/colo.c | 2 -- migration/migration.c | 18 +++++++++++------- 2 files changed, 11 insertions(+), 9 deletions(-)migration/colo.c +0
-2@@ -667,8 +667,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 +0
-0@@ -3222,7 +3222,10 @@ static void migration_completion(MigrationState *s) goto fail_invalidate;
migration/migration.c static void migration_completion(MigrationState *s) · line 3231
Quoted 10 lines
migration/migration.c +4
-1} -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 ); }
This moves the setup to MIGRATION_STATUS_COLO to completion time instead of the beggining of the process. I have no clue why. I guess you can put a comment/commit message to say what you ar.e trynig to do.
Quoted 17 lines
migration/migration.c +1
-6@@ -3607,12 +3610,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__);@@ -3622,6 +3620,12 @@ 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 static void migration_iteration_finish(MigrationState *s) · line 3631
Quoted 10 lines
migration/migration.c +6
-0*/ +/* Fallthrough */ +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 :
I guess this change is related to the previous one, but I don't understand colo enough to review it.
Later, Juan.
Quoted 25 lines
-----Original Message-----
From: Juan Quintela <[email protected]>
Sent: Wednesday, November 17, 2021 12:28 AM
To: Zhang, Chen <[email protected]>
Cc: Hailiang Zhang <[email protected]>; Dr . David Alan Gilbert <[email protected]>; qemu-dev <[email protected]>
Subject: Re: [PATCH 1/2] migration/colo: Optimize COLO start code pathQuoted 1 line · Zhang Chen
There is no need to start COLO through
MIGRATION_STATUS_ACTIVE.Hi
I don't understand what you are trying to do. In my reading, at least the commit message is wrong:
void migrate_start_colo_process(MigrationState *s) { ... migrate_set_state(&s->state, MIGRATION_STATUS_ACTIVE, MIGRATION_STATUS_COLO); ... }
Quoted 8 lines
and
void *colo_process_incoming_thread(void *opaque) { ... migrate_set_state(&mis->state, MIGRATION_STATUS_ACTIVE, MIGRATION_STATUS_COLO);So colo starts with
MIGRATION_STATUS_ACTIVE.
Yes, this patch just optimized COLO primary code path(migrate_start_colo_process()). We can see this patch removed the
migrate_set_state(&s->state, MIGRATION_STATUS_ACTIVE,
MIGRATION_STATUS_COLO);
In the migrate_start_colo_process().
Current COLO status path:
MIGRATION_STATUS_XXX ---> MIGRATION_STATUS_ACTIVE ---> MIGRATION_STATUS_COLO ---> MIGRATION_STATUS_COMPLETED
This patch try to remove redundant " MIGRATION_STATUS_ACTIVE " in COLO start.MIGRATION_STATUS_XXX ---> MIGRATION_STATUS_COLO ---> MIGRATION_STATUS_COMPLETED
Actually COLO primary code did nothing when running on "MIGRATION_STATUS_ACTIVE".
But for COLO secondary (void *colo_process_incoming_thread()), it shared some code with normal migration. No need to do this.
So, I will fix commit message to:
Optimize COLO primary start path to:MIGRATION_STATUS_XXX ---> MIGRATION_STATUS_COLO ---> MIGRATION_STATUS_COMPLETED
No need to start primary COLO through "MIGRATION_STATUS_ACTIVE".
How about it?
Quoted 39 lines
migration/migration.c static void migration_completion(MigrationState
Quoted 26 lines
Signed-off-by Zhang Chen <[email protected]>--- migration/colo.c | 2 -- migration/migration.c | 18 +++++++++++------- 2 files changed, 11 insertions(+), 9 deletions(-)migration/colo.c index renamed from migration/colo.c +0
-02415325262..ad1a4426b3 100644
migration/colo.c +0
-2@@ -667,8 +667,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
abaf6f9e3d..4c8662a839100644migration/migration.c +0
-0@@ -3222,7 +3222,10 @@ static void migration_completion(MigrationState*s)
migration/migration.c static void migration_completion(MigrationState *s) · line 3231
Quoted 11 lines
migration/migration.c +4
-1goto 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 ); }
Quoted 3 lines
This moves the setup to
MIGRATION_STATUS_COLOto completion time instead of the beggining of the process. I have no clue why. I guess you can put a comment/commit message to say what you ar.e trynig to do.
You are right, no need to setup here.
I will remove this in next version.
Quoted 30 lines
migration/migration.c static void
Quoted 2 lines
migration/migration.c +0
-0@@ -3607,12 +3610,7 @@ static void
migration_iteration_finish(MigrationState *s)Quoted 16 lines
migration/migration.c +2
-6migration_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__); @@ -3622,6 +3620,12 @@ 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 static void
Quoted 10 lines
migration/migration.c +6
-0*/ +/* Fallthrough */ +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 :
Quoted 2 lines
I guess this change is related to the previous one, but I don't understand colo enough to review it.
I think this patch is the general code, little background needed.
You can simple understand COLO is two VMs(primary node and secondary node) entered a state of cyclic migration. Thanks your comments.
Thanks
Chen
Quoted 2 lines
Later, Juan.
Quoted 47 lines · Chen
Quoted 23 lines
-----Original Message-----
From: Juan Quintela <[email protected]>
Sent: Wednesday, November 17, 2021 12:28 AM
To: Zhang, Chen <[email protected]>
Cc: Hailiang Zhang <[email protected]>; Dr . David Alan Gilbert <[email protected]>; qemu-dev <[email protected]>
Subject: Re: [PATCH 1/2] migration/colo: Optimize COLO start code pathQuoted 1 line · Zhang Chen
There is no need to start COLO through
MIGRATION_STATUS_ACTIVE.Hi
I don't understand what you are trying to do. In my reading, at least the commit message is wrong:
void migrate_start_colo_process(MigrationState *s) { ... migrate_set_state(&s->state, MIGRATION_STATUS_ACTIVE, MIGRATION_STATUS_COLO); ... }Quoted 8 lines
and
void *colo_process_incoming_thread(void *opaque) { ... migrate_set_state(&mis->state, MIGRATION_STATUS_ACTIVE, MIGRATION_STATUS_COLO);So colo starts with
MIGRATION_STATUS_ACTIVE.Yes, this patch just optimized COLO primary code path(migrate_start_colo_process()). We can see this patch removed the
migrate_set_state(&s->state,MIGRATION_STATUS_ACTIVE,MIGRATION_STATUS_COLO);In the
migrate_start_colo_process().Current COLO status path:
MIGRATION_STATUS_XXX--->MIGRATION_STATUS_ACTIVE--->MIGRATION_STATUS_COLO--->MIGRATION_STATUS_COMPLETEDThis patch try to remove redundant "
MIGRATION_STATUS_ACTIVE" in COLO start.MIGRATION_STATUS_XXX--->MIGRATION_STATUS_COLO--->MIGRATION_STATUS_COMPLETEDActually COLO primary code did nothing when running on "
MIGRATION_STATUS_ACTIVE".
But for COLO secondary (void*colo_process_incoming_thread()), it shared some code with normal migration. No need to do this.
Quoted 6 lines
So, I will fix commit message to:
Optimize COLO primary start path to:MIGRATION_STATUS_XXX--->MIGRATION_STATUS_COLO--->MIGRATION_STATUS_COMPLETED
No need to start primary COLO through "MIGRATION_STATUS_ACTIVE".How about it?
Much better, thank.s
Quoted 37 lines
Quoted 37 lines
migration/migration.c static void migration_completion(MigrationState
Quoted 24 lines
Signed-off-by Zhang Chen <[email protected]>--- migration/colo.c | 2 -- migration/migration.c | 18 +++++++++++------- 2 files changed, 11 insertions(+), 9 deletions(-)migration/colo.c index renamed from migration/colo.c +0
-02415325262..ad1a4426b3 100644
migration/colo.c +0
-2@@ -667,8 +667,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
abaf6f9e3d..4c8662a839100644migration/migration.c +0
-0@@ -3222,7 +3222,10 @@ static void migration_completion(MigrationState*s)
Quoted 11 lines
migration/migration.c +4
-1goto 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 ); }
Quoted 6 lines
Quoted 3 lines
This moves the setup to
MIGRATION_STATUS_COLOto completion time instead of the beggining of the process. I have no clue why. I guess you can put a comment/commit message to say what you ar.e trynig to do.You are right, no need to setup here.
I will remove this in next version.
Thanks.
Quoted 29 lines
Quoted 29 lines
migration/migration.c static void
Quoted 1 line
migration/migration.c +0
-0@@ -3607,12 +3610,7 @@ static void
migration_iteration_finish(MigrationState *s)Quoted 26 lines
migration/migration.c +8
-6migration_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__); @@ -3622,6 +3620,12 @@ 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. */ +/* Fallthrough */ +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 :
Quoted 6 lines
Quoted 2 lines
I guess this change is related to the previous one, but I don't understand colo enough to review it.
I think this patch is the general code, little background needed.
You can simple understand COLO is two VMs(primary node and secondary node) entered a state of cyclic migration. Thanks your comments.
Later, Juan.