]> xenbits.xensource.com Git - qemu-xen.git/commitdiff
replay: ptimer
authorPavel Dovgalyuk <Pavel.Dovgaluk@ispras.ru>
Thu, 17 Sep 2015 16:24:56 +0000 (19:24 +0300)
committerPaolo Bonzini <pbonzini@redhat.com>
Fri, 6 Nov 2015 09:16:03 +0000 (10:16 +0100)
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>
Message-Id: <20150917162456.8676.83366.stgit@PASHA-ISP.def.inno>
Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
Signed-off-by: Pavel Dovgalyuk <Pavel.Dovgaluk@ispras.ru>
hw/core/ptimer.c
include/sysemu/replay.h
replay/replay-events.c
replay/replay-internal.h

index 8437bd6e8bf9ed9ab2a23fca40c09985ed8aa8d0..edf077cfd0a8ebdf42d5acdafd3d7153b8bda19f 100644 (file)
@@ -9,6 +9,7 @@
 #include "qemu/timer.h"
 #include "hw/ptimer.h"
 #include "qemu/host-utils.h"
+#include "sysemu/replay.h"
 
 struct ptimer_state
 {
@@ -27,7 +28,7 @@ struct ptimer_state
 static void ptimer_trigger(ptimer_state *s)
 {
     if (s->bh) {
-        qemu_bh_schedule(s->bh);
+        replay_bh_schedule_event(s->bh);
     }
 }
 
index e2696fe3968f60549dbb4664d122cd540650e6d4..fdf46f80898b7a666ce0b49113d6ec48a6dfeb45 100644 (file)
@@ -15,6 +15,7 @@
 #include <stdbool.h>
 #include <stdint.h>
 #include "qapi-types.h"
+#include "qemu/typedefs.h"
 
 /* replay clock kinds */
 enum ReplayClockKind {
@@ -97,5 +98,7 @@ bool replay_checkpoint(ReplayCheckpoint checkpoint);
 void replay_disable_events(void);
 /*! Returns true when saving events is enabled */
 bool replay_events_enabled(void);
+/*! Adds bottom half event to the queue */
+void replay_bh_schedule_event(QEMUBH *bh);
 
 #endif
index 8dcc96d51e5775dd8a22955fb3df42664059f122..8db2c7ace01c9611b7d09d1f12245dfdffe39614 100644 (file)
@@ -13,6 +13,7 @@
 #include "qemu/error-report.h"
 #include "sysemu/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_BH:
+        aio_bh_call(event->opaque);
+        break;
     default:
         error_report("Replay: invalid async event ID (%d) in the queue",
                     event->event_kind);
@@ -89,7 +93,6 @@ void replay_clear_events(void)
 }
 
 /*! Adds specified async event to the queue */
-#if 0
 static void replay_add_event(ReplayAsyncEventKind event_kind,
                              void *opaque,
                              void *opaque2, uint64_t id)
@@ -117,7 +120,16 @@ static void replay_add_event(ReplayAsyncEventKind event_kind,
     QTAILQ_INSERT_TAIL(&events_list, event, events);
     replay_mutex_unlock();
 }
-#endif
+
+void replay_bh_schedule_event(QEMUBH *bh)
+{
+    if (replay_mode != REPLAY_MODE_NONE) {
+        uint64_t id = replay_get_current_step();
+        replay_add_event(REPLAY_ASYNC_EVENT_BH, bh, NULL, id);
+    } else {
+        qemu_bh_schedule(bh);
+    }
+}
 
 static void replay_save_event(Event *event, int checkpoint)
 {
@@ -129,10 +141,12 @@ static void replay_save_event(Event *event, int checkpoint)
 
         /* save event-specific data */
         switch (event->event_kind) {
+        case REPLAY_ASYNC_EVENT_BH:
+            replay_put_qword(event->id);
+            break;
         default:
             error_report("Unknown ID %d of replay event", read_event_kind);
             exit(1);
-            break;
         }
     }
 }
@@ -168,6 +182,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_BH:
+        if (read_id == -1) {
+            read_id = replay_get_qword();
+        }
+        break;
     default:
         error_report("Unknown ID %d of replay event", read_event_kind);
         exit(1);
index bf64be54d7d3abc4c74a388ea68ea0d73881e935..7ba60642e1235e6b5f946e5ae4874692c6665c86 100644 (file)
@@ -39,6 +39,7 @@ enum ReplayEvents {
 /* Asynchronous events IDs */
 
 enum ReplayAsyncEventKind {
+    REPLAY_ASYNC_EVENT_BH,
     REPLAY_ASYNC_COUNT
 };