From patchwork Tue Feb 9 05:55:18 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Pavel Dovgalyuk X-Patchwork-Id: 8258731 Return-Path: X-Original-To: patchwork-qemu-devel@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork2.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.29.136]) by patchwork2.web.kernel.org (Postfix) with ESMTP id 7D576BEEE5 for ; Tue, 9 Feb 2016 05:57:02 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id BE3CB2027D for ; Tue, 9 Feb 2016 05:57:01 +0000 (UTC) Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) (using TLSv1 with cipher AES256-SHA (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id E34B620272 for ; Tue, 9 Feb 2016 05:57:00 +0000 (UTC) Received: from localhost ([::1]:52166 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1aT1IK-0001SY-Dv for patchwork-qemu-devel@patchwork.kernel.org; Tue, 09 Feb 2016 00:57:00 -0500 Received: from eggs.gnu.org ([2001:4830:134:3::10]:59553) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1aT1Gi-0007TA-A3 for qemu-devel@nongnu.org; Tue, 09 Feb 2016 00:55:21 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1aT1Gh-0005fE-9M for qemu-devel@nongnu.org; Tue, 09 Feb 2016 00:55:20 -0500 Received: from mail.ispras.ru ([83.149.199.45]:46364) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1aT1Gg-0005f9-SU for qemu-devel@nongnu.org; Tue, 09 Feb 2016 00:55:19 -0500 Received: from [10.10.150.115] (unknown [85.142.117.224]) by mail.ispras.ru (Postfix) with ESMTPSA id F372E54006E; Tue, 9 Feb 2016 08:55:17 +0300 (MSK) To: qemu-devel@nongnu.org From: Pavel Dovgalyuk Date: Tue, 09 Feb 2016 08:55:18 +0300 Message-ID: <20160209055518.8208.88007.stgit@PASHA-ISP> In-Reply-To: <20160209055506.8208.67.stgit@PASHA-ISP> References: <20160209055506.8208.67.stgit@PASHA-ISP> User-Agent: StGit/0.16 MIME-Version: 1.0 X-detected-operating-system: by eggs.gnu.org: GNU/Linux 3.x X-Received-From: 83.149.199.45 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 2/3] replay: introduce new checkpoint for icount warp X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+patchwork-qemu-devel=patchwork.kernel.org@nongnu.org Sender: qemu-devel-bounces+patchwork-qemu-devel=patchwork.kernel.org@nongnu.org X-Spam-Status: No, score=-6.9 required=5.0 tests=BAYES_00, RCVD_IN_DNSWL_HI, UNPARSEABLE_RELAY autolearn=unavailable version=3.3.1 X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on mail.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP 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 --- 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(-) diff --git a/cpus.c b/cpus.c index ea29584..6276eed 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; } @@ -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; 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 5877615..9787425 100644 --- a/main-loop.c +++ b/main-loop.c @@ -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; diff --git a/qemu-timer.c b/qemu-timer.c index f16e422..aafe7d7 100644 --- a/qemu-timer.c +++ b/qemu-timer.c @@ -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); } diff --git a/stubs/clock-warp.c b/stubs/clock-warp.c index 5565118..4fb89f5 100644 --- a/stubs/clock-warp.c +++ b/stubs/clock-warp.c @@ -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) { }