qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
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 v17 16/21] replay: ptimer
Date: Mon, 07 Sep 2015 11:41:39 +0300	[thread overview]
Message-ID: <20150907084139.1664.60553.stgit@PASHA-ISP> (raw)
In-Reply-To: <20150907084005.1664.19540.stgit@PASHA-ISP>

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

  parent reply	other threads:[~2015-09-07  8:41 UTC|newest]

Thread overview: 24+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2015-09-07  8:40 [Qemu-devel] [PATCH v17 00/21] Deterministic replay core Pavel Dovgalyuk
2015-09-07  8:40 ` [Qemu-devel] [PATCH v17 01/21] i386: partial revert of interrupt poll fix Pavel Dovgalyuk
2015-09-07  8:40 ` [Qemu-devel] [PATCH v17 02/21] replay: global variables and function stubs Pavel Dovgalyuk
2015-09-07  8:40 ` [Qemu-devel] [PATCH v17 03/21] replay: internal functions for replay log Pavel Dovgalyuk
2015-09-07  8:40 ` [Qemu-devel] [PATCH v17 04/21] replay: introduce mutex to protect the " Pavel Dovgalyuk
2015-09-07  8:40 ` [Qemu-devel] [PATCH v17 05/21] replay: introduce icount event Pavel Dovgalyuk
2015-09-07  8:40 ` [Qemu-devel] [PATCH v17 06/21] cpu-exec: allow temporary disabling icount Pavel Dovgalyuk
2015-09-07  8:40 ` [Qemu-devel] [PATCH v17 07/21] cpu: replay instructions sequence Pavel Dovgalyuk
2015-09-07  8:40 ` [Qemu-devel] [PATCH v17 08/21] i386: interrupt poll processing Pavel Dovgalyuk
2015-09-07  8:40 ` [Qemu-devel] [PATCH v17 09/21] replay: interrupts and exceptions Pavel Dovgalyuk
2015-09-07  8:41 ` [Qemu-devel] [PATCH v17 10/21] replay: asynchronous events infrastructure Pavel Dovgalyuk
2015-09-07  8:41 ` [Qemu-devel] [PATCH v17 11/21] replay: recording and replaying clock ticks Pavel Dovgalyuk
2015-09-07  8:41 ` [Qemu-devel] [PATCH v17 12/21] replay: shutdown event Pavel Dovgalyuk
2015-09-07  8:41 ` [Qemu-devel] [PATCH v17 13/21] icount: improve counting for record/replay Pavel Dovgalyuk
2015-09-07  8:41 ` [Qemu-devel] [PATCH v17 14/21] replay: checkpoints Pavel Dovgalyuk
2015-09-07  8:41 ` [Qemu-devel] [PATCH v17 15/21] bottom halves: introduce bh call function Pavel Dovgalyuk
2015-09-07  8:41 ` Pavel Dovgalyuk [this message]
2015-09-07  8:41 ` [Qemu-devel] [PATCH v17 17/21] typedef: add typedef for QemuOpts Pavel Dovgalyuk
2015-09-07  8:41 ` [Qemu-devel] [PATCH v17 18/21] replay: initialization and deinitialization Pavel Dovgalyuk
2015-09-07  8:41 ` [Qemu-devel] [PATCH v17 19/21] replay: replay blockers for devices Pavel Dovgalyuk
2015-09-07  8:42 ` [Qemu-devel] [PATCH v17 20/21] replay: command line options Pavel Dovgalyuk
2015-09-07  8:42 ` [Qemu-devel] [PATCH v17 21/21] replay: recording of the user input Pavel Dovgalyuk
2015-09-11  5:52 ` [Qemu-devel] [PATCH v17 00/21] Deterministic replay core Pavel Dovgaluk
     [not found] ` <45193.409038666$1441951862@news.gmane.org>
2015-09-11  6:31   ` Paolo Bonzini

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=20150907084139.1664.60553.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=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).