qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
* [Qemu-devel] [PATCH] replay: don't synchronize memory operations in replay mode
@ 2019-09-17  9:54 Pavel Dovgalyuk
  2019-09-17 10:44 ` Paolo Bonzini
  0 siblings, 1 reply; 2+ messages in thread
From: Pavel Dovgalyuk @ 2019-09-17  9:54 UTC (permalink / raw)
  To: qemu-devel; +Cc: pbonzini, richard.henderson, pavel.dovgaluk, dovgaluk

Commit 9458a9a1df1a4c719e24512394d548c1fc7abd22 added synchronization
of vCPU and migration operations through calling run_on_cpu operation.
However, in replay mode this synchronization is unneeded, because
I/O and vCPU threads are already synchronized.
This patch disables such synchronization for record/replay mode.

Signed-off-by: Pavel Dovgalyuk <Pavel.Dovgaluk@ispras.ru>
---
 exec.c |   13 +++++++++++--
 1 file changed, 11 insertions(+), 2 deletions(-)

diff --git a/exec.c b/exec.c
index be8b2b7c06..a69745811f 100644
--- a/exec.c
+++ b/exec.c
@@ -3177,8 +3177,17 @@ static void tcg_log_global_after_sync(MemoryListener *listener)
      * by pushing the migration thread's memory read after the vCPU thread has
      * written the memory.
      */
-    cpuas = container_of(listener, CPUAddressSpace, tcg_as_listener);
-    run_on_cpu(cpuas->cpu, do_nothing, RUN_ON_CPU_NULL);
+    if (replay_mode == REPLAY_MODE_NONE) {
+        /*
+         * VGA can make calls to this function while updating the screen.
+         * In record/replay mode this causes a deadlock, because
+         * run_on_cpu waits for rr mutex. Therefore no races are possible
+         * in this case and no need for making run_on_cpu when
+         * record/replay is not enabled.
+         */
+        cpuas = container_of(listener, CPUAddressSpace, tcg_as_listener);
+        run_on_cpu(cpuas->cpu, do_nothing, RUN_ON_CPU_NULL);
+    }
 }
 
 static void tcg_commit(MemoryListener *listener)



^ permalink raw reply related	[flat|nested] 2+ messages in thread

* Re: [Qemu-devel] [PATCH] replay: don't synchronize memory operations in replay mode
  2019-09-17  9:54 [Qemu-devel] [PATCH] replay: don't synchronize memory operations in replay mode Pavel Dovgalyuk
@ 2019-09-17 10:44 ` Paolo Bonzini
  0 siblings, 0 replies; 2+ messages in thread
From: Paolo Bonzini @ 2019-09-17 10:44 UTC (permalink / raw)
  To: Pavel Dovgalyuk, qemu-devel; +Cc: dovgaluk, richard.henderson, pavel.dovgaluk

On 17/09/19 11:54, Pavel Dovgalyuk wrote:
> Commit 9458a9a1df1a4c719e24512394d548c1fc7abd22 added synchronization
> of vCPU and migration operations through calling run_on_cpu operation.
> However, in replay mode this synchronization is unneeded, because
> I/O and vCPU threads are already synchronized.
> This patch disables such synchronization for record/replay mode.
> 
> Signed-off-by: Pavel Dovgalyuk <Pavel.Dovgaluk@ispras.ru>
> ---
>  exec.c |   13 +++++++++++--
>  1 file changed, 11 insertions(+), 2 deletions(-)
> 
> diff --git a/exec.c b/exec.c
> index be8b2b7c06..a69745811f 100644
> --- a/exec.c
> +++ b/exec.c
> @@ -3177,8 +3177,17 @@ static void tcg_log_global_after_sync(MemoryListener *listener)
>       * by pushing the migration thread's memory read after the vCPU thread has
>       * written the memory.
>       */
> -    cpuas = container_of(listener, CPUAddressSpace, tcg_as_listener);
> -    run_on_cpu(cpuas->cpu, do_nothing, RUN_ON_CPU_NULL);
> +    if (replay_mode == REPLAY_MODE_NONE) {
> +        /*
> +         * VGA can make calls to this function while updating the screen.
> +         * In record/replay mode this causes a deadlock, because
> +         * run_on_cpu waits for rr mutex. Therefore no races are possible
> +         * in this case and no need for making run_on_cpu when
> +         * record/replay is not enabled.
> +         */
> +        cpuas = container_of(listener, CPUAddressSpace, tcg_as_listener);
> +        run_on_cpu(cpuas->cpu, do_nothing, RUN_ON_CPU_NULL);
> +    }
>  }
>  
>  static void tcg_commit(MemoryListener *listener)
> 

Looks good.

Paolo



^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2019-09-17 10:51 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2019-09-17  9:54 [Qemu-devel] [PATCH] replay: don't synchronize memory operations in replay mode Pavel Dovgalyuk
2019-09-17 10:44 ` Paolo Bonzini

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).