[PATCH v2] COLO: Move some trace code behind qemu_mutex_unlock_iothread()

Rao, Lei posted 1 patch 4 years, 1 month ago
Test checkpatch passed
Patches applied successfully (tree, apply log)
git fetch https://github.com/patchew-project/qemu tags/patchew/20211214171945.217843-1-lei.rao@intel.com
Maintainers: Hailiang Zhang <zhang.zhanghailiang@huawei.com>, "Dr. David Alan Gilbert" <dgilbert@redhat.com>, Juan Quintela <quintela@redhat.com>
migration/colo.c | 6 +++---
1 file changed, 3 insertions(+), 3 deletions(-)
[PATCH v2] COLO: Move some trace code behind qemu_mutex_unlock_iothread()
Posted by Rao, Lei 4 years, 1 month ago
There is no need to put some trace code in the critical section.
So, moving it behind qemu_mutex_unlock_iothread() can reduce the
lock time.

Signed-off-by: Lei Rao <lei.rao@intel.com>
---
 migration/colo.c | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

diff --git a/migration/colo.c b/migration/colo.c
index 2415325262..3ccacb29c8 100644
--- a/migration/colo.c
+++ b/migration/colo.c
@@ -683,8 +683,8 @@ static void colo_incoming_process_checkpoint(MigrationIncomingState *mis,
 
     qemu_mutex_lock_iothread();
     vm_stop_force_state(RUN_STATE_COLO);
-    trace_colo_vm_state_change("run", "stop");
     qemu_mutex_unlock_iothread();
+    trace_colo_vm_state_change("run", "stop");
 
     /* FIXME: This is unnecessary for periodic checkpoint mode */
     colo_send_message(mis->to_src_file, COLO_MESSAGE_CHECKPOINT_REPLY,
@@ -786,8 +786,8 @@ static void colo_incoming_process_checkpoint(MigrationIncomingState *mis,
 
     vmstate_loading = false;
     vm_start();
-    trace_colo_vm_state_change("stop", "run");
     qemu_mutex_unlock_iothread();
+    trace_colo_vm_state_change("stop", "run");
 
     if (failover_get_state() == FAILOVER_STATUS_RELAUNCH) {
         return;
@@ -870,8 +870,8 @@ void *colo_process_incoming_thread(void *opaque)
         abort();
 #endif
     vm_start();
-    trace_colo_vm_state_change("stop", "run");
     qemu_mutex_unlock_iothread();
+    trace_colo_vm_state_change("stop", "run");
 
     colo_send_message(mis->to_src_file, COLO_MESSAGE_CHECKPOINT_READY,
                       &local_err);
-- 
2.32.0


Re: [PATCH v2] COLO: Move some trace code behind qemu_mutex_unlock_iothread()
Posted by Juan Quintela 4 years, 1 month ago
"Rao, Lei" <lei.rao@intel.com> wrote:
> There is no need to put some trace code in the critical section.
> So, moving it behind qemu_mutex_unlock_iothread() can reduce the
> lock time.
>
> Signed-off-by: Lei Rao <lei.rao@intel.com>

Reviewed-by: Juan Quintela <quintela@redhat.com>

queued for 7.0

> ---
>  migration/colo.c | 6 +++---
>  1 file changed, 3 insertions(+), 3 deletions(-)
>
> diff --git a/migration/colo.c b/migration/colo.c
> index 2415325262..3ccacb29c8 100644
> --- a/migration/colo.c
> +++ b/migration/colo.c
> @@ -683,8 +683,8 @@ static void colo_incoming_process_checkpoint(MigrationIncomingState *mis,
>  
>      qemu_mutex_lock_iothread();
>      vm_stop_force_state(RUN_STATE_COLO);
> -    trace_colo_vm_state_change("run", "stop");
>      qemu_mutex_unlock_iothread();
> +    trace_colo_vm_state_change("run", "stop");
>  
>      /* FIXME: This is unnecessary for periodic checkpoint mode */
>      colo_send_message(mis->to_src_file, COLO_MESSAGE_CHECKPOINT_REPLY,
> @@ -786,8 +786,8 @@ static void colo_incoming_process_checkpoint(MigrationIncomingState *mis,
>  
>      vmstate_loading = false;
>      vm_start();
> -    trace_colo_vm_state_change("stop", "run");
>      qemu_mutex_unlock_iothread();
> +    trace_colo_vm_state_change("stop", "run");
>  
>      if (failover_get_state() == FAILOVER_STATUS_RELAUNCH) {
>          return;
> @@ -870,8 +870,8 @@ void *colo_process_incoming_thread(void *opaque)
>          abort();
>  #endif
>      vm_start();
> -    trace_colo_vm_state_change("stop", "run");
>      qemu_mutex_unlock_iothread();
> +    trace_colo_vm_state_change("stop", "run");
>  
>      colo_send_message(mis->to_src_file, COLO_MESSAGE_CHECKPOINT_READY,
>                        &local_err);