qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
From: Pavel Dovgalyuk <pavel.dovgalyuk@ispras.ru>
To: qemu-devel@nongnu.org
Cc: pavel.dovgalyuk@ispras.ru, pbonzini@redhat.com,
	alex.bennee@linaro.org, crosa@redhat.com, f4bug@amsat.org
Subject: [PATCH v2 2/9] replay: notify vCPU when BH is scheduled
Date: Wed, 04 May 2022 12:39:00 +0300	[thread overview]
Message-ID: <165165714007.1062896.13693480594668205608.stgit@pasha-ThinkPad-X280> (raw)
In-Reply-To: <165165712922.1062896.3966737516733314504.stgit@pasha-ThinkPad-X280>

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>

--

v2: changed first_cpu to current_cpu (suggested by Richard Henderson)
---
 include/sysemu/cpu-timers.h |    1 +
 softmmu/icount.c            |    8 ++++++++
 stubs/icount.c              |    4 ++++
 util/async.c                |    8 ++++++++
 4 files changed, 21 insertions(+)

diff --git a/include/sysemu/cpu-timers.h b/include/sysemu/cpu-timers.h
index ed6ee5c46c..2e786fe7fb 100644
--- a/include/sysemu/cpu-timers.h
+++ b/include/sysemu/cpu-timers.h
@@ -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
diff --git a/softmmu/icount.c b/softmmu/icount.c
index 5ca271620d..1cafec5014 100644
--- a/softmmu/icount.c
+++ b/softmmu/icount.c
@@ -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);
+    }
+}
diff --git a/stubs/icount.c b/stubs/icount.c
index f13c43568b..6df8c2bf7d 100644
--- a/stubs/icount.c
+++ b/stubs/icount.c
@@ -43,3 +43,7 @@ void icount_account_warp_timer(void)
 {
     abort();
 }
+
+void icount_notify_exit(void)
+{
+}
diff --git a/util/async.c b/util/async.c
index 2ea1172f3e..c376b6c2b4 100644
--- a/util/async.c
+++ b/util/async.c
@@ -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"
 
 /***********************************************************/
@@ -185,6 +186,13 @@ void qemu_bh_schedule_idle(QEMUBH *bh)
 void qemu_bh_schedule(QEMUBH *bh)
 {
     aio_bh_enqueue(bh, BH_SCHEDULED);
+    /*
+     * 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();
 }
 
 /* This func is async.



  parent reply	other threads:[~2022-05-04 10:42 UTC|newest]

Thread overview: 12+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-05-04  9:38 [PATCH v2 0/9] Record/replay refactoring and stuff Pavel Dovgalyuk
2022-05-04  9:38 ` [PATCH v2 1/9] replay: fix event queue flush for qemu shutdown Pavel Dovgalyuk
2022-05-04  9:39 ` Pavel Dovgalyuk [this message]
2022-05-04 15:38   ` [PATCH v2 2/9] replay: notify vCPU when BH is scheduled Richard Henderson
2022-05-04  9:39 ` [PATCH v2 3/9] replay: rewrite async event handling Pavel Dovgalyuk
2022-05-04  9:39 ` [PATCH v2 4/9] replay: simplify async event processing Pavel Dovgalyuk
2022-05-04 15:39   ` Richard Henderson
2022-05-04  9:39 ` [PATCH v2 5/9] docs: convert docs/devel/replay page to rst Pavel Dovgalyuk
2022-05-04  9:39 ` [PATCH v2 6/9] docs: move replay docs to docs/system/replay.rst Pavel Dovgalyuk
2022-05-04  9:39 ` [PATCH v2 7/9] tests/avocado: update replay_linux test Pavel Dovgalyuk
2022-05-04  9:39 ` [PATCH v2 8/9] tests/avocado: add replay Linux tests for virtio machine Pavel Dovgalyuk
2022-05-04  9:39 ` [PATCH v2 9/9] tests/avocado: add replay Linux test for Aarch64 machines Pavel Dovgalyuk

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=165165714007.1062896.13693480594668205608.stgit@pasha-ThinkPad-X280 \
    --to=pavel.dovgalyuk@ispras.ru \
    --cc=alex.bennee@linaro.org \
    --cc=crosa@redhat.com \
    --cc=f4bug@amsat.org \
    --cc=pbonzini@redhat.com \
    --cc=qemu-devel@nongnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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).