]> xenbits.xensource.com Git - people/aperard/qemu-dm.git/commitdiff
replay: notify vCPU when BH is scheduled
authorPavel Dovgalyuk <pavel.dovgalyuk@ispras.ru>
Fri, 27 May 2022 10:46:13 +0000 (13:46 +0300)
committerPaolo Bonzini <pbonzini@redhat.com>
Mon, 6 Jun 2022 07:26:53 +0000 (09:26 +0200)
vCPU execution should be suspended when new BH is scheduled.
This is needed to avoid guest timeouts caused by the long cycles
of the execution. In replay mode execution may hang when
vCPU sleeps and block event comes to the queue.
This patch adds notification which wakes up vCPU or interrupts
execution of guest code.

Signed-off-by: Pavel Dovgalyuk <Pavel.Dovgalyuk@ispras.ru>
Reviewed-by: Richard Henderson <richard.henderson@linaro.org>
--

v2: changed first_cpu to current_cpu (suggested by Richard Henderson)
v4: moved vCPU notification to aio_bh_enqueue (suggested by Paolo Bonzini)
Message-Id: <165364837317.688121.17680519919871405281.stgit@pasha-ThinkPad-X280>
Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
include/sysemu/cpu-timers.h
softmmu/icount.c
stubs/icount.c
util/async.c

index ed6ee5c46ccdc74428aa63b3e196138654dd2ef5..2e786fe7fb1440d3cae1e14fd2cabd300f31126b 100644 (file)
@@ -59,6 +59,7 @@ int64_t icount_round(int64_t count);
 /* if the CPUs are idle, start accounting real time to virtual clock. */
 void icount_start_warp_timer(void);
 void icount_account_warp_timer(void);
+void icount_notify_exit(void);
 
 /*
  * CPU Ticks and Clock
index 5ca271620db6b8398d67acc123204ee08230c63d..1cafec5014c4d873ea8d76f5f89a860cada9447d 100644 (file)
@@ -486,3 +486,11 @@ void icount_configure(QemuOpts *opts, Error **errp)
                    qemu_clock_get_ns(QEMU_CLOCK_VIRTUAL) +
                    NANOSECONDS_PER_SECOND / 10);
 }
+
+void icount_notify_exit(void)
+{
+    if (icount_enabled() && current_cpu) {
+        qemu_cpu_kick(current_cpu);
+        qemu_clock_notify(QEMU_CLOCK_VIRTUAL);
+    }
+}
index f13c43568bceca6a8bb1b3982da5c7078c6744ed..6df8c2bf7d4488b9d2682a6d5e4787a4f7db2430 100644 (file)
@@ -43,3 +43,7 @@ void icount_account_warp_timer(void)
 {
     abort();
 }
+
+void icount_notify_exit(void)
+{
+}
index 554ba70cca2186138748077987873592d2676c30..63434ddae40ca65fe21718f37a44b4d45c38517f 100644 (file)
@@ -33,6 +33,7 @@
 #include "block/raw-aio.h"
 #include "qemu/coroutine_int.h"
 #include "qemu/coroutine-tls.h"
+#include "sysemu/cpu-timers.h"
 #include "trace.h"
 
 /***********************************************************/
@@ -84,6 +85,13 @@ static void aio_bh_enqueue(QEMUBH *bh, unsigned new_flags)
     }
 
     aio_notify(ctx);
+    /*
+     * Workaround for record/replay.
+     * vCPU execution should be suspended when new BH is set.
+     * This is needed to avoid guest timeouts caused
+     * by the long cycles of the execution.
+     */
+    icount_notify_exit();
 }
 
 /* Only called from aio_bh_poll() and aio_ctx_finalize() */