From: Pavel Dovgalyuk <Pavel.Dovgaluk@ispras.ru>
To: qemu-devel@nongnu.org
Cc: edgar.iglesias@xilinx.com, peter.maydell@linaro.org,
igor.rubinov@gmail.com, alex.bennee@linaro.org,
mark.burton@greensocs.com, real@ispras.ru, hines@cert.org,
batuzovk@ispras.ru, maria.klimushenkova@ispras.ru,
pavel.dovgaluk@ispras.ru, pbonzini@redhat.com, kwolf@redhat.com,
stefanha@redhat.com, fred.konrad@greensocs.com
Subject: [Qemu-devel] [PATCH v3 3/5] replay: introduce new checkpoint for icount warp
Date: Tue, 01 Mar 2016 14:07:52 +0300 [thread overview]
Message-ID: <20160301110752.10104.65295.stgit@PASHA-ISP> (raw)
In-Reply-To: <20160301110732.10104.2019.stgit@PASHA-ISP>
qemu_clock_warp function is called to update virtual clock when CPU
is sleeping. This function includes replay checkpoint to make execution
deterministic in icount mode.
Record/replay module flushes async event queue at checkpoints.
Some of the events (e.g., block devices operations) include interaction
with hardware. E.g., APIC polled by block devices sets one of IRQ flags.
Flag to be set depends on currently executed thread (CPU or iothread).
Therefore in replay mode we have to process the checkpoints in the same thread
as they were recorded.
qemu_clock_warp function (and its checkpoint) may be called from different
thread. This patch introduces new checkpoint which distinguished warp
checkpoint calls from different threads.
Signed-off-by: Pavel Dovgalyuk <pavel.dovgaluk@ispras.ru>
---
cpus.c | 7 ++++---
include/qemu/timer.h | 3 ++-
include/sysemu/replay.h | 1 +
main-loop.c | 2 +-
qemu-timer.c | 2 +-
stubs/clock-warp.c | 2 +-
6 files changed, 10 insertions(+), 7 deletions(-)
diff --git a/cpus.c b/cpus.c
index 01c9809..c2d9cfe 100644
--- a/cpus.c
+++ b/cpus.c
@@ -396,7 +396,7 @@ void qtest_clock_warp(int64_t dest)
qemu_clock_notify(QEMU_CLOCK_VIRTUAL);
}
-void qemu_clock_warp(QEMUClockType type)
+void qemu_clock_warp(QEMUClockType type, bool in_tcg)
{
int64_t clock;
int64_t deadline;
@@ -418,7 +418,8 @@ void qemu_clock_warp(QEMUClockType type)
}
/* warp clock deterministically in record/replay mode */
- if (!replay_checkpoint(CHECKPOINT_CLOCK_WARP)) {
+ if (!replay_checkpoint(in_tcg ? CHECKPOINT_CLOCK_WARP_TCG
+ : CHECKPOINT_CLOCK_WARP)) {
return;
}
@@ -1496,7 +1497,7 @@ static void tcg_exec_all(void)
int r;
/* Account partial waits to QEMU_CLOCK_VIRTUAL. */
- qemu_clock_warp(QEMU_CLOCK_VIRTUAL);
+ qemu_clock_warp(QEMU_CLOCK_VIRTUAL, true);
if (next_cpu == NULL) {
next_cpu = first_cpu;
diff --git a/include/qemu/timer.h b/include/qemu/timer.h
index d0946cb..c58192c 100644
--- a/include/qemu/timer.h
+++ b/include/qemu/timer.h
@@ -212,10 +212,11 @@ void qemu_clock_enable(QEMUClockType type, bool enabled);
/**
* qemu_clock_warp:
* @type: the clock type
+ * @in_tcg: true if function is called from TCG CPU thread
*
* Warp a clock to a new value
*/
-void qemu_clock_warp(QEMUClockType type);
+void qemu_clock_warp(QEMUClockType type, bool in_tcg);
/**
* qemu_clock_register_reset_notifier:
diff --git a/include/sysemu/replay.h b/include/sysemu/replay.h
index 3c4a988..c879231 100644
--- a/include/sysemu/replay.h
+++ b/include/sysemu/replay.h
@@ -31,6 +31,7 @@ typedef enum ReplayClockKind ReplayClockKind;
/* IDs of the checkpoints */
enum ReplayCheckpoint {
CHECKPOINT_CLOCK_WARP,
+ CHECKPOINT_CLOCK_WARP_TCG,
CHECKPOINT_RESET_REQUESTED,
CHECKPOINT_SUSPEND_REQUESTED,
CHECKPOINT_CLOCK_VIRTUAL,
diff --git a/main-loop.c b/main-loop.c
index 19beae7..cd8415f 100644
--- a/main-loop.c
+++ b/main-loop.c
@@ -509,7 +509,7 @@ int main_loop_wait(int nonblocking)
/* CPU thread can infinitely wait for event after
missing the warp */
- qemu_clock_warp(QEMU_CLOCK_VIRTUAL);
+ qemu_clock_warp(QEMU_CLOCK_VIRTUAL, false);
qemu_clock_run_all_timers();
return ret;
diff --git a/qemu-timer.c b/qemu-timer.c
index e98ecc9..980fe7e 100644
--- a/qemu-timer.c
+++ b/qemu-timer.c
@@ -394,7 +394,7 @@ static bool timer_mod_ns_locked(QEMUTimerList *timer_list,
static void timerlist_rearm(QEMUTimerList *timer_list)
{
/* Interrupt execution to force deadline recalculation. */
- qemu_clock_warp(timer_list->clock->type);
+ qemu_clock_warp(timer_list->clock->type, false);
timerlist_notify(timer_list);
}
diff --git a/stubs/clock-warp.c b/stubs/clock-warp.c
index 5ae32b9..24ae0f8 100644
--- a/stubs/clock-warp.c
+++ b/stubs/clock-warp.c
@@ -2,7 +2,7 @@
#include "qemu-common.h"
#include "qemu/timer.h"
-void qemu_clock_warp(QEMUClockType type)
+void qemu_clock_warp(QEMUClockType type, bool in_tcg)
{
}
next prev parent reply other threads:[~2016-03-01 11:07 UTC|newest]
Thread overview: 14+ messages / expand[flat|nested] mbox.gz Atom feed top
2016-03-01 11:07 [Qemu-devel] [PATCH v3 0/5] Deterministic replay extensions Pavel Dovgalyuk
2016-03-01 11:07 ` [Qemu-devel] [PATCH v3 1/5] replay: character devices Pavel Dovgalyuk
2016-03-01 11:07 ` [Qemu-devel] [PATCH v3 2/5] icount: remove obsolete warp call Pavel Dovgalyuk
2016-03-09 12:05 ` Paolo Bonzini
2016-03-01 11:07 ` Pavel Dovgalyuk [this message]
2016-03-09 12:03 ` [Qemu-devel] [PATCH v3 3/5] replay: introduce new checkpoint for icount warp Paolo Bonzini
2016-03-10 9:10 ` Pavel Dovgalyuk
2016-03-10 10:24 ` Paolo Bonzini
2016-03-01 11:07 ` [Qemu-devel] [PATCH v3 4/5] block: add flush callback Pavel Dovgalyuk
2016-03-09 11:25 ` Kevin Wolf
2016-03-01 11:08 ` [Qemu-devel] [PATCH v3 5/5] replay: introduce block devices record/replay Pavel Dovgalyuk
2016-03-09 11:43 ` Kevin Wolf
2016-03-10 6:15 ` Pavel Dovgalyuk
2016-03-07 7:21 ` [Qemu-devel] [PATCH v3 0/5] Deterministic replay extensions dovgaluk
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=20160301110752.10104.65295.stgit@PASHA-ISP \
--to=pavel.dovgaluk@ispras.ru \
--cc=alex.bennee@linaro.org \
--cc=batuzovk@ispras.ru \
--cc=edgar.iglesias@xilinx.com \
--cc=fred.konrad@greensocs.com \
--cc=hines@cert.org \
--cc=igor.rubinov@gmail.com \
--cc=kwolf@redhat.com \
--cc=maria.klimushenkova@ispras.ru \
--cc=mark.burton@greensocs.com \
--cc=pbonzini@redhat.com \
--cc=peter.maydell@linaro.org \
--cc=qemu-devel@nongnu.org \
--cc=real@ispras.ru \
--cc=stefanha@redhat.com \
/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).