[Qemu-devel] [PATCH 4/5] qemu-timer: Remove function alarm_has_dynticks
Some time ago, the last time which did not have dynticks was removed, so now all timers have dynticks. I also removed a misleading error message for the dynticks timer. If timer_create fails, there is already an error message, and QEMU will use the unix timer which also provides dynamic ticks, therefore dynamic ticks are not disabled. Signed-off-by: Stefan Weil s...@weilnetz.de --- qemu-timer.c | 31 ++- 1 files changed, 6 insertions(+), 25 deletions(-) diff --git a/qemu-timer.c b/qemu-timer.c index 73ffe25..1fbc2df 100644 --- a/qemu-timer.c +++ b/qemu-timer.c @@ -87,11 +87,6 @@ static bool qemu_timer_expired_ns(QEMUTimer *timer_head, int64_t current_time) return timer_head (timer_head-expire_time = current_time); } -static inline int alarm_has_dynticks(struct qemu_alarm_timer *t) -{ -return !!t-rearm; -} - static int64_t qemu_next_alarm_deadline(void) { int64_t delta; @@ -124,7 +119,6 @@ static int64_t qemu_next_alarm_deadline(void) static void qemu_rearm_alarm_timer(struct qemu_alarm_timer *t) { int64_t nearest_delta_ns; -assert(alarm_has_dynticks(t)); if (!rt_clock-active_timers !vm_clock-active_timers !host_clock-active_timers) { @@ -483,9 +477,8 @@ static void host_alarm_handler(int host_signum) if (!t) return; -if (alarm_has_dynticks(t) || -qemu_next_alarm_deadline () = 0) { -t-expired = alarm_has_dynticks(t); +if (qemu_next_alarm_deadline() = 0) { +t-expired = true; t-pending = true; qemu_notify_event(); } @@ -524,10 +517,6 @@ static int dynticks_start_timer(struct qemu_alarm_timer *t) if (timer_create(CLOCK_REALTIME, ev, host_timer)) { perror(timer_create); - -/* disable dynticks */ -fprintf(stderr, Dynamic Ticks disabled\n); - return -1; } @@ -636,8 +625,8 @@ static void CALLBACK mm_alarm_handler(UINT uTimerID, UINT uMsg, if (!t) { return; } -if (alarm_has_dynticks(t) || qemu_next_alarm_deadline() = 0) { -t-expired = alarm_has_dynticks(t); +if (qemu_next_alarm_deadline() = 0) { +t-expired = true; t-pending = true; qemu_notify_event(); } @@ -646,7 +635,6 @@ static void CALLBACK mm_alarm_handler(UINT uTimerID, UINT uMsg, static int mm_start_timer(struct qemu_alarm_timer *t) { TIMECAPS tc; -UINT flags; memset(tc, 0, sizeof(tc)); timeGetDevCaps(tc, sizeof(tc)); @@ -654,18 +642,11 @@ static int mm_start_timer(struct qemu_alarm_timer *t) mm_period = tc.wPeriodMin; timeBeginPeriod(mm_period); -flags = TIME_CALLBACK_FUNCTION; -if (alarm_has_dynticks(t)) { -flags |= TIME_ONESHOT; -} else { -flags |= TIME_PERIODIC; -} - mm_timer = timeSetEvent(1, /* interval (ms) */ mm_period, /* resolution */ mm_alarm_handler, /* function */ (DWORD_PTR)t, /* parameter */ -flags); +TIME_ONESHOT | TIME_CALLBACK_FUNCTION); if (!mm_timer) { fprintf(stderr, Failed to initialize win32 alarm timer: %ld\n, @@ -720,7 +701,7 @@ static int win32_start_timer(struct qemu_alarm_timer *t) host_alarm_handler, t, 1, - alarm_has_dynticks(t) ? 360 : 1, + 360, WT_EXECUTEINTIMERTHREAD); if (!success) { -- 1.7.9
Re: [Qemu-devel] [PATCH 4/5] qemu-timer: Remove function alarm_has_dynticks
Il 20/04/2012 12:03, Stefan Weil ha scritto: Some time ago, the last time which did not have dynticks was removed, so now all timers have dynticks. I also removed a misleading error message for the dynticks timer. If timer_create fails, there is already an error message, and QEMU will use the unix timer which also provides dynamic ticks, therefore dynamic ticks are not disabled. Signed-off-by: Stefan Weil s...@weilnetz.de --- qemu-timer.c | 31 ++- 1 files changed, 6 insertions(+), 25 deletions(-) diff --git a/qemu-timer.c b/qemu-timer.c index 73ffe25..1fbc2df 100644 --- a/qemu-timer.c +++ b/qemu-timer.c @@ -87,11 +87,6 @@ static bool qemu_timer_expired_ns(QEMUTimer *timer_head, int64_t current_time) return timer_head (timer_head-expire_time = current_time); } -static inline int alarm_has_dynticks(struct qemu_alarm_timer *t) -{ -return !!t-rearm; -} - static int64_t qemu_next_alarm_deadline(void) { int64_t delta; @@ -124,7 +119,6 @@ static int64_t qemu_next_alarm_deadline(void) static void qemu_rearm_alarm_timer(struct qemu_alarm_timer *t) { int64_t nearest_delta_ns; -assert(alarm_has_dynticks(t)); if (!rt_clock-active_timers !vm_clock-active_timers !host_clock-active_timers) { @@ -483,9 +477,8 @@ static void host_alarm_handler(int host_signum) if (!t) return; -if (alarm_has_dynticks(t) || -qemu_next_alarm_deadline () = 0) { -t-expired = alarm_has_dynticks(t); +if (qemu_next_alarm_deadline() = 0) { This is actually if (true). +t-expired = true; t-pending = true; qemu_notify_event(); } @@ -524,10 +517,6 @@ static int dynticks_start_timer(struct qemu_alarm_timer *t) if (timer_create(CLOCK_REALTIME, ev, host_timer)) { perror(timer_create); - -/* disable dynticks */ -fprintf(stderr, Dynamic Ticks disabled\n); - return -1; } @@ -636,8 +625,8 @@ static void CALLBACK mm_alarm_handler(UINT uTimerID, UINT uMsg, if (!t) { return; } -if (alarm_has_dynticks(t) || qemu_next_alarm_deadline() = 0) { -t-expired = alarm_has_dynticks(t); +if (qemu_next_alarm_deadline() = 0) { +t-expired = true; t-pending = true; qemu_notify_event(); } This too. Otherwise the series look good, thanks! Paolo @@ -646,7 +635,6 @@ static void CALLBACK mm_alarm_handler(UINT uTimerID, UINT uMsg, static int mm_start_timer(struct qemu_alarm_timer *t) { TIMECAPS tc; -UINT flags; memset(tc, 0, sizeof(tc)); timeGetDevCaps(tc, sizeof(tc)); @@ -654,18 +642,11 @@ static int mm_start_timer(struct qemu_alarm_timer *t) mm_period = tc.wPeriodMin; timeBeginPeriod(mm_period); -flags = TIME_CALLBACK_FUNCTION; -if (alarm_has_dynticks(t)) { -flags |= TIME_ONESHOT; -} else { -flags |= TIME_PERIODIC; -} - mm_timer = timeSetEvent(1, /* interval (ms) */ mm_period, /* resolution */ mm_alarm_handler, /* function */ (DWORD_PTR)t, /* parameter */ -flags); +TIME_ONESHOT | TIME_CALLBACK_FUNCTION); if (!mm_timer) { fprintf(stderr, Failed to initialize win32 alarm timer: %ld\n, @@ -720,7 +701,7 @@ static int win32_start_timer(struct qemu_alarm_timer *t) host_alarm_handler, t, 1, - alarm_has_dynticks(t) ? 360 : 1, + 360, WT_EXECUTEINTIMERTHREAD); if (!success) {