Commit b99dc0d1a4d395bad649ef25abe21c5f076787a5
1 parent
b01bcae6
Redundant timer rearm optimisation by Anders Melchiorsen.
git-svn-id: svn://svn.savannah.nongnu.org/qemu/trunk@3823 c046a42c-6fe2-441c-8c8c-71466251a162
Showing
1 changed file
with
11 additions
and
1 deletions
vl.c
... | ... | @@ -822,6 +822,7 @@ struct qemu_alarm_timer { |
822 | 822 | }; |
823 | 823 | |
824 | 824 | #define ALARM_FLAG_DYNTICKS 0x1 |
825 | +#define ALARM_FLAG_MODIFIED 0x2 | |
825 | 826 | |
826 | 827 | static inline int alarm_has_dynticks(struct qemu_alarm_timer *t) |
827 | 828 | { |
... | ... | @@ -833,6 +834,11 @@ static void qemu_rearm_alarm_timer(struct qemu_alarm_timer *t) |
833 | 834 | if (!alarm_has_dynticks(t)) |
834 | 835 | return; |
835 | 836 | |
837 | + if (!(t->flags & ALARM_FLAG_MODIFIED)) | |
838 | + return; | |
839 | + | |
840 | + t->flags &= ~(ALARM_FLAG_MODIFIED); | |
841 | + | |
836 | 842 | t->rearm(t); |
837 | 843 | } |
838 | 844 | |
... | ... | @@ -995,6 +1001,8 @@ void qemu_del_timer(QEMUTimer *ts) |
995 | 1001 | { |
996 | 1002 | QEMUTimer **pt, *t; |
997 | 1003 | |
1004 | + alarm_timer->flags |= ALARM_FLAG_MODIFIED; | |
1005 | + | |
998 | 1006 | /* NOTE: this code must be signal safe because |
999 | 1007 | qemu_timer_expired() can be called from a signal. */ |
1000 | 1008 | pt = &active_timers[ts->clock->type]; |
... | ... | @@ -1067,7 +1075,6 @@ static void qemu_run_timers(QEMUTimer **ptimer_head, int64_t current_time) |
1067 | 1075 | /* run the callback (the timer list can be modified) */ |
1068 | 1076 | ts->cb(ts->opaque); |
1069 | 1077 | } |
1070 | - qemu_rearm_alarm_timer(alarm_timer); | |
1071 | 1078 | } |
1072 | 1079 | |
1073 | 1080 | int64_t qemu_get_clock(QEMUClock *clock) |
... | ... | @@ -1187,6 +1194,7 @@ static void host_alarm_handler(int host_signum) |
1187 | 1194 | CPUState *env = next_cpu; |
1188 | 1195 | |
1189 | 1196 | if (env) { |
1197 | + alarm_timer->flags |= ALARM_FLAG_MODIFIED; | |
1190 | 1198 | /* stop the currently executing cpu because a timer occured */ |
1191 | 1199 | cpu_interrupt(env, CPU_INTERRUPT_EXIT); |
1192 | 1200 | #ifdef USE_KQEMU |
... | ... | @@ -7364,6 +7372,8 @@ void main_loop_wait(int timeout) |
7364 | 7372 | qemu_run_timers(&active_timers[QEMU_TIMER_REALTIME], |
7365 | 7373 | qemu_get_clock(rt_clock)); |
7366 | 7374 | |
7375 | + qemu_rearm_alarm_timer(alarm_timer); | |
7376 | + | |
7367 | 7377 | /* Check bottom-halves last in case any of the earlier events triggered |
7368 | 7378 | them. */ |
7369 | 7379 | qemu_bh_poll(); | ... | ... |