From: Paolo Bonzini <pbonzini@redhat.com>
To: qemu-devel@nongnu.org
Cc: Pavel Dovgalyuk <pavel.dovgaluk@ispras.ru>
Subject: [Qemu-devel] [PULL 14/18] replay: ptimer
Date: Wed, 4 Nov 2015 17:17:52 +0100 [thread overview]
Message-ID: <1446653876-116008-15-git-send-email-pbonzini@redhat.com> (raw)
In-Reply-To: <1446653876-116008-1-git-send-email-pbonzini@redhat.com>
From: Pavel Dovgalyuk <Pavel.Dovgaluk@ispras.ru>
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>
---
hw/core/ptimer.c | 3 ++-
include/sysemu/replay.h | 2 ++
replay/replay-events.c | 23 ++++++++++++++++++++++-
replay/replay-internal.h | 1 +
4 files changed, 27 insertions(+), 2 deletions(-)
diff --git a/hw/core/ptimer.c b/hw/core/ptimer.c
index 8437bd6..edf077c 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 "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);
}
}
diff --git a/include/sysemu/replay.h b/include/sysemu/replay.h
index e2696fe..e963a0b 100644
--- a/include/sysemu/replay.h
+++ b/include/sysemu/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 bottom half event to the queue */
+void replay_bh_schedule_event(QEMUBH *bh);
#endif
diff --git a/replay/replay-events.c b/replay/replay-events.c
index 7634882..8db2c7a 100644
--- a/replay/replay-events.c
+++ b/replay/replay-events.c
@@ -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);
@@ -117,6 +121,16 @@ static void replay_add_event(ReplayAsyncEventKind event_kind,
replay_mutex_unlock();
}
+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)
{
if (replay_mode != REPLAY_MODE_PLAY) {
@@ -127,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;
}
}
}
@@ -166,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);
diff --git a/replay/replay-internal.h b/replay/replay-internal.h
index bf64be5..7ba6064 100644
--- a/replay/replay-internal.h
+++ b/replay/replay-internal.h
@@ -39,6 +39,7 @@ enum ReplayEvents {
/* Asynchronous events IDs */
enum ReplayAsyncEventKind {
+ REPLAY_ASYNC_EVENT_BH,
REPLAY_ASYNC_COUNT
};
--
1.8.3.1
next prev parent reply other threads:[~2015-11-04 16:18 UTC|newest]
Thread overview: 23+ messages / expand[flat|nested] mbox.gz Atom feed top
2015-11-04 16:17 [Qemu-devel] [PULL 00/18] Record/replay core for QEMU 2.4-rc1 Paolo Bonzini
2015-11-04 16:17 ` [Qemu-devel] [PULL 01/18] replay: global variables and function stubs Paolo Bonzini
2015-11-04 16:17 ` [Qemu-devel] [PULL 02/18] replay: internal functions for replay log Paolo Bonzini
2015-11-04 16:17 ` [Qemu-devel] [PULL 03/18] replay: introduce mutex to protect the " Paolo Bonzini
2015-11-04 16:17 ` [Qemu-devel] [PULL 04/18] replay: introduce icount event Paolo Bonzini
2015-11-04 16:17 ` [Qemu-devel] [PULL 05/18] cpu-exec: allow temporary disabling icount Paolo Bonzini
2015-11-04 16:17 ` [Qemu-devel] [PULL 06/18] cpu: replay instructions sequence Paolo Bonzini
2015-11-04 16:17 ` [Qemu-devel] [PULL 07/18] replay: interrupts and exceptions Paolo Bonzini
2015-11-04 16:17 ` [Qemu-devel] [PULL 08/18] replay: asynchronous events infrastructure Paolo Bonzini
2015-11-04 16:17 ` [Qemu-devel] [PULL 09/18] replay: recording and replaying clock ticks Paolo Bonzini
2015-11-04 16:17 ` [Qemu-devel] [PULL 10/18] replay: shutdown event Paolo Bonzini
2015-11-04 16:17 ` [Qemu-devel] [PULL 11/18] icount: improve counting for record/replay Paolo Bonzini
2015-11-04 16:17 ` [Qemu-devel] [PULL 12/18] replay: checkpoints Paolo Bonzini
2015-11-04 16:17 ` [Qemu-devel] [PULL 13/18] bottom halves: introduce bh call function Paolo Bonzini
2015-11-04 16:17 ` Paolo Bonzini [this message]
2015-11-04 16:17 ` [Qemu-devel] [PULL 15/18] replay: initialization and deinitialization Paolo Bonzini
2015-11-04 16:17 ` [Qemu-devel] [PULL 16/18] replay: replay blockers for devices Paolo Bonzini
2015-11-04 16:17 ` [Qemu-devel] [PULL 17/18] replay: command line options Paolo Bonzini
2015-11-04 16:17 ` [Qemu-devel] [PULL 18/18] replay: recording of the user input Paolo Bonzini
2015-11-04 18:11 ` [Qemu-devel] [PULL 00/18] Record/replay core for QEMU 2.4-rc1 Alex Bennée
2015-11-05 10:52 ` Peter Maydell
2015-11-05 11:18 ` Paolo Bonzini
-- strict thread matches above, loose matches on Subject: below --
2015-11-05 12:13 [Qemu-devel] [PULL 00/18] Record/replay core for 2.5-rc1 Paolo Bonzini
2015-11-05 12:13 ` [Qemu-devel] [PULL 14/18] replay: ptimer 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=1446653876-116008-15-git-send-email-pbonzini@redhat.com \
--to=pbonzini@redhat.com \
--cc=pavel.dovgaluk@ispras.ru \
--cc=qemu-devel@nongnu.org \
/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).