@@ -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;
}
@@ -997,7 +998,7 @@ static void qemu_tcg_wait_io_event(CPUState *cpu)
while (all_cpu_threads_idle()) {
/* Start accounting real time to the virtual clock if the CPUs
are idle. */
- qemu_clock_warp(QEMU_CLOCK_VIRTUAL);
+ qemu_clock_warp(QEMU_CLOCK_VIRTUAL, true);
qemu_cond_wait(cpu->halt_cond, &qemu_global_mutex);
}
@@ -1490,7 +1491,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;
@@ -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:
@@ -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,
@@ -508,7 +508,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;
@@ -393,7 +393,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);
}
@@ -1,7 +1,7 @@
#include "qemu-common.h"
#include "qemu/timer.h"
-void qemu_clock_warp(QEMUClockType type)
+void qemu_clock_warp(QEMUClockType type, bool in_tcg)
{
}
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 | 9 +++++---- 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, 11 insertions(+), 8 deletions(-)