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, batuzovk@ispras.ru,
maria.klimushenkova@ispras.ru, pavel.dovgaluk@ispras.ru,
pbonzini@redhat.com, hines@cert.org, fred.konrad@greensocs.com
Subject: [Qemu-devel] [PATCH v18 16/21] replay: ptimer
Date: Thu, 17 Sep 2015 19:24:56 +0300 [thread overview]
Message-ID: <20150917162456.8676.83366.stgit@PASHA-ISP.def.inno> (raw)
In-Reply-To: <20150917162322.8676.29314.stgit@PASHA-ISP.def.inno>
This patch adds deterministic replay for hardware periodic countdown timers.
ptimer uses bottom halves layer to execute such an asynchronous callback.
We put this callback into the replay queue instead of bottom halves one.
When checkpoint is met by main loop thread, the replay queue is processed
and callback is executed. Binding callback moment to one of the checkpoints
makes it deterministic.
Signed-off-by: Pavel Dovgalyuk <pavel.dovgaluk@ispras.ru>
---
hw/core/ptimer.c | 7 ++++++-
replay/replay-events.c | 18 +++++++++++++++++-
replay/replay-internal.h | 1 +
replay/replay.h | 2 ++
4 files changed, 26 insertions(+), 2 deletions(-)
diff --git a/hw/core/ptimer.c b/hw/core/ptimer.c
index 8437bd6..c56078d 100644
--- a/hw/core/ptimer.c
+++ b/hw/core/ptimer.c
@@ -9,6 +9,7 @@
#include "qemu/timer.h"
#include "hw/ptimer.h"
#include "qemu/host-utils.h"
+#include "replay/replay.h"
struct ptimer_state
{
@@ -27,7 +28,11 @@ struct ptimer_state
static void ptimer_trigger(ptimer_state *s)
{
if (s->bh) {
- qemu_bh_schedule(s->bh);
+ if (replay_mode != REPLAY_MODE_NONE) {
+ replay_add_ptimer_event(s->bh, replay_get_current_step());
+ } else {
+ qemu_bh_schedule(s->bh);
+ }
}
}
diff --git a/replay/replay-events.c b/replay/replay-events.c
index f973cb0..f356493 100755
--- a/replay/replay-events.c
+++ b/replay/replay-events.c
@@ -13,6 +13,7 @@
#include "qemu/error-report.h"
#include "replay.h"
#include "replay-internal.h"
+#include "block/aio.h"
typedef struct Event {
ReplayAsyncEventKind event_kind;
@@ -35,6 +36,9 @@ static bool events_enabled;
static void replay_run_event(Event *event)
{
switch (event->event_kind) {
+ case REPLAY_ASYNC_EVENT_PTIMER:
+ aio_bh_call(event->opaque);
+ break;
default:
error_report("Replay: invalid async event ID (%d) in the queue",
event->event_kind);
@@ -117,6 +121,11 @@ static void replay_add_event(ReplayAsyncEventKind event_kind,
replay_mutex_unlock();
}
+void replay_add_ptimer_event(void *bh, uint64_t id)
+{
+ replay_add_event(REPLAY_ASYNC_EVENT_PTIMER, bh, NULL, id);
+}
+
static void replay_save_event(Event *event, int checkpoint)
{
if (replay_mode != REPLAY_MODE_PLAY) {
@@ -127,10 +136,12 @@ static void replay_save_event(Event *event, int checkpoint)
/* save event-specific data */
switch (event->event_kind) {
+ case REPLAY_ASYNC_EVENT_PTIMER:
+ replay_put_qword(event->id);
+ break;
default:
error_report("Unknown ID %d of replay event", read_event_kind);
exit(1);
- break;
}
}
}
@@ -166,6 +177,11 @@ static Event *replay_read_event(int checkpoint)
/* Events that has not to be in the queue */
switch (read_event_kind) {
+ case REPLAY_ASYNC_EVENT_PTIMER:
+ if (read_id == -1) {
+ read_id = replay_get_qword();
+ }
+ break;
default:
error_report("Unknown ID %d of replay event", read_event_kind);
exit(1);
diff --git a/replay/replay-internal.h b/replay/replay-internal.h
index bf64be5..89c1dc7 100755
--- a/replay/replay-internal.h
+++ b/replay/replay-internal.h
@@ -39,6 +39,7 @@ enum ReplayEvents {
/* Asynchronous events IDs */
enum ReplayAsyncEventKind {
+ REPLAY_ASYNC_EVENT_PTIMER,
REPLAY_ASYNC_COUNT
};
diff --git a/replay/replay.h b/replay/replay.h
index e2696fe..c7de964 100755
--- a/replay/replay.h
+++ b/replay/replay.h
@@ -97,5 +97,7 @@ bool replay_checkpoint(ReplayCheckpoint checkpoint);
void replay_disable_events(void);
/*! Returns true when saving events is enabled */
bool replay_events_enabled(void);
+/*! Adds ptimer event to the queue */
+void replay_add_ptimer_event(void *bh, uint64_t id);
#endif
next prev parent reply other threads:[~2015-09-17 16:24 UTC|newest]
Thread overview: 34+ messages / expand[flat|nested] mbox.gz Atom feed top
2015-09-17 16:23 [Qemu-devel] [PATCH v18 00/21] Deterministic replay core Pavel Dovgalyuk
2015-09-17 16:23 ` [Qemu-devel] [PATCH v18 01/21] i386: partial revert of interrupt poll fix Pavel Dovgalyuk
2015-09-17 16:23 ` [Qemu-devel] [PATCH v18 02/21] replay: global variables and function stubs Pavel Dovgalyuk
2015-09-17 16:23 ` [Qemu-devel] [PATCH v18 03/21] replay: internal functions for replay log Pavel Dovgalyuk
2015-09-17 16:23 ` [Qemu-devel] [PATCH v18 04/21] replay: introduce mutex to protect the " Pavel Dovgalyuk
2015-09-17 16:23 ` [Qemu-devel] [PATCH v18 05/21] replay: introduce icount event Pavel Dovgalyuk
2015-09-17 16:23 ` [Qemu-devel] [PATCH v18 06/21] cpu-exec: allow temporary disabling icount Pavel Dovgalyuk
2015-09-17 16:24 ` [Qemu-devel] [PATCH v18 07/21] cpu: replay instructions sequence Pavel Dovgalyuk
2015-09-17 16:24 ` [Qemu-devel] [PATCH v18 08/21] i386: interrupt poll processing Pavel Dovgalyuk
2015-09-17 16:24 ` [Qemu-devel] [PATCH v18 09/21] replay: interrupts and exceptions Pavel Dovgalyuk
2015-09-17 16:24 ` [Qemu-devel] [PATCH v18 10/21] replay: asynchronous events infrastructure Pavel Dovgalyuk
2015-09-17 16:24 ` [Qemu-devel] [PATCH v18 11/21] replay: recording and replaying clock ticks Pavel Dovgalyuk
2015-09-22 13:15 ` Paolo Bonzini
2015-09-23 7:09 ` Pavel Dovgaluk
2015-09-17 16:24 ` [Qemu-devel] [PATCH v18 12/21] replay: shutdown event Pavel Dovgalyuk
2015-09-17 16:24 ` [Qemu-devel] [PATCH v18 13/21] icount: improve counting for record/replay Pavel Dovgalyuk
2015-09-22 13:15 ` Paolo Bonzini
2015-09-23 7:22 ` Pavel Dovgaluk
[not found] ` <1946.37127356163$1442992987@news.gmane.org>
2015-09-23 8:08 ` Paolo Bonzini
2015-09-23 8:42 ` Pavel Dovgaluk
2015-09-17 16:24 ` [Qemu-devel] [PATCH v18 14/21] replay: checkpoints Pavel Dovgalyuk
2015-09-17 16:24 ` [Qemu-devel] [PATCH v18 15/21] bottom halves: introduce bh call function Pavel Dovgalyuk
2015-09-17 16:24 ` Pavel Dovgalyuk [this message]
2015-09-17 16:25 ` [Qemu-devel] [PATCH v18 17/21] typedef: add typedef for QemuOpts Pavel Dovgalyuk
2015-09-17 16:25 ` [Qemu-devel] [PATCH v18 18/21] replay: initialization and deinitialization Pavel Dovgalyuk
2015-09-17 16:25 ` [Qemu-devel] [PATCH v18 19/21] replay: replay blockers for devices Pavel Dovgalyuk
2015-10-06 20:15 ` Eric Blake
2015-09-17 16:25 ` [Qemu-devel] [PATCH v18 20/21] replay: command line options Pavel Dovgalyuk
2015-09-17 16:25 ` [Qemu-devel] [PATCH v18 21/21] replay: recording of the user input Pavel Dovgalyuk
2015-09-21 7:12 ` [Qemu-devel] [PATCH v18 00/21] Deterministic replay core Pavel Dovgaluk
2015-09-22 13:13 ` Paolo Bonzini
[not found] ` <13403.5645904534$1442819578@news.gmane.org>
2015-10-06 15:09 ` Paolo Bonzini
2015-10-06 16:38 ` Paolo Bonzini
[not found] ` <CAPnv1P+PMm7stf-TUoWBX9+frHHOWzz=LB-Errn6_=fBO_QxNQ@mail.gmail.com>
[not found] ` <CAPnv1PKaYDZQeMxK33e1U3mWcsNQiufPnDxLZgiFxXAktxzktA@mail.gmail.com>
2015-11-04 10:57 ` Igor R
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=20150917162456.8676.83366.stgit@PASHA-ISP.def.inno \
--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=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 \
/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).