summaryrefslogtreecommitdiff
path: root/vl.c
diff options
context:
space:
mode:
authorbalrog <balrog@c046a42c-6fe2-441c-8c8c-71466251a162>2007-12-16 13:17:12 +0000
committerbalrog <balrog@c046a42c-6fe2-441c-8c8c-71466251a162>2007-12-16 13:17:12 +0000
commitb99dc0d1a4d395bad649ef25abe21c5f076787a5 (patch)
tree275c968f68c4e2822b0ba060ed502436fdccd919 /vl.c
parentb01bcae61cef515797a3f353aaff9f55b27ee0d1 (diff)
downloadqemu-b99dc0d1a4d395bad649ef25abe21c5f076787a5.tar.gz
qemu-b99dc0d1a4d395bad649ef25abe21c5f076787a5.tar.bz2
qemu-b99dc0d1a4d395bad649ef25abe21c5f076787a5.zip
Redundant timer rearm optimisation by Anders Melchiorsen.
git-svn-id: svn://svn.savannah.nongnu.org/qemu/trunk@3823 c046a42c-6fe2-441c-8c8c-71466251a162
Diffstat (limited to 'vl.c')
-rw-r--r--vl.c12
1 files changed, 11 insertions, 1 deletions
diff --git a/vl.c b/vl.c
index 2ed3254345..a1616cf9cf 100644
--- a/vl.c
+++ b/vl.c
@@ -822,6 +822,7 @@ struct qemu_alarm_timer {
};
#define ALARM_FLAG_DYNTICKS 0x1
+#define ALARM_FLAG_MODIFIED 0x2
static inline int alarm_has_dynticks(struct qemu_alarm_timer *t)
{
@@ -833,6 +834,11 @@ static void qemu_rearm_alarm_timer(struct qemu_alarm_timer *t)
if (!alarm_has_dynticks(t))
return;
+ if (!(t->flags & ALARM_FLAG_MODIFIED))
+ return;
+
+ t->flags &= ~(ALARM_FLAG_MODIFIED);
+
t->rearm(t);
}
@@ -995,6 +1001,8 @@ void qemu_del_timer(QEMUTimer *ts)
{
QEMUTimer **pt, *t;
+ alarm_timer->flags |= ALARM_FLAG_MODIFIED;
+
/* NOTE: this code must be signal safe because
qemu_timer_expired() can be called from a signal. */
pt = &active_timers[ts->clock->type];
@@ -1067,7 +1075,6 @@ static void qemu_run_timers(QEMUTimer **ptimer_head, int64_t current_time)
/* run the callback (the timer list can be modified) */
ts->cb(ts->opaque);
}
- qemu_rearm_alarm_timer(alarm_timer);
}
int64_t qemu_get_clock(QEMUClock *clock)
@@ -1187,6 +1194,7 @@ static void host_alarm_handler(int host_signum)
CPUState *env = next_cpu;
if (env) {
+ alarm_timer->flags |= ALARM_FLAG_MODIFIED;
/* stop the currently executing cpu because a timer occured */
cpu_interrupt(env, CPU_INTERRUPT_EXIT);
#ifdef USE_KQEMU
@@ -7364,6 +7372,8 @@ void main_loop_wait(int timeout)
qemu_run_timers(&active_timers[QEMU_TIMER_REALTIME],
qemu_get_clock(rt_clock));
+ qemu_rearm_alarm_timer(alarm_timer);
+
/* Check bottom-halves last in case any of the earlier events triggered
them. */
qemu_bh_poll();