[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Qemu-devel] [PATCHv12 17/31] aio / timers: On timer modification, qemu_
From: |
Alex Bligh |
Subject: |
[Qemu-devel] [PATCHv12 17/31] aio / timers: On timer modification, qemu_notify or aio_notify |
Date: |
Fri, 16 Aug 2013 19:29:58 +0100 |
On qemu_mod_timer_ns, ensure qemu_notify or aio_notify is called to
end the appropriate poll(), irrespective of use_icount value.
On qemu_clock_enable, ensure qemu_notify or aio_notify is called for
all QEMUTimerLists attached to the QEMUClock.
main-loop.c produces a (possibly spurious) warning about
multiple iterations. Adapt the way this works for a signed
timeout and make the warning a bit safer.
Signed-off-by: Alex Bligh <address@hidden>
---
include/qemu/timer.h | 9 +++++++++
main-loop.c | 6 +++---
qemu-timer.c | 13 ++++++++++---
3 files changed, 22 insertions(+), 6 deletions(-)
diff --git a/include/qemu/timer.h b/include/qemu/timer.h
index 843dfe1..619b7a2 100644
--- a/include/qemu/timer.h
+++ b/include/qemu/timer.h
@@ -136,6 +136,15 @@ bool qemu_clock_use_for_deadline(QEMUClock *clock);
QEMUTimerList *qemu_clock_get_main_loop_timerlist(QEMUClock *clock);
/**
+ * qemu_clock_nofify:
+ * @clock: the clock to operate on
+ *
+ * Call the notifier callback connected with the default timer
+ * list linked to the clock, or qemu_notify() if none.
+ */
+void qemu_clock_notify(QEMUClock *clock);
+
+/**
* timerlist_new:
* @type: the clock type to associate with the timerlist
* @cb: the callback to call on notification
diff --git a/main-loop.c b/main-loop.c
index 1cb5968..2866d95 100644
--- a/main-loop.c
+++ b/main-loop.c
@@ -209,7 +209,7 @@ static int os_host_main_loop_wait(int64_t timeout)
* print a message to the screen. If we run into this condition, create
* a fake timeout in order to give the VCPU threads a chance to run.
*/
- if (spin_counter > MAX_MAIN_LOOP_SPIN) {
+ if (!timeout && (spin_counter > MAX_MAIN_LOOP_SPIN)) {
static bool notified;
if (!notified) {
@@ -222,7 +222,7 @@ static int os_host_main_loop_wait(int64_t timeout)
timeout = SCALE_MS;
}
- if (timeout > 0) {
+ if (timeout) {
spin_counter = 0;
qemu_mutex_unlock_iothread();
} else {
@@ -231,7 +231,7 @@ static int os_host_main_loop_wait(int64_t timeout)
ret = qemu_poll_ns((GPollFD *)gpollfds->data, gpollfds->len, timeout);
- if (timeout > 0) {
+ if (timeout) {
qemu_mutex_lock_iothread();
}
diff --git a/qemu-timer.c b/qemu-timer.c
index c1de3d3..ec25bcc 100644
--- a/qemu-timer.c
+++ b/qemu-timer.c
@@ -304,11 +304,20 @@ bool qemu_clock_use_for_deadline(QEMUClock *clock)
return !(use_icount && (clock->type == QEMU_CLOCK_VIRTUAL));
}
+void qemu_clock_notify(QEMUClock *clock)
+{
+ QEMUTimerList *timer_list;
+ QLIST_FOREACH(timer_list, &clock->timerlists, list) {
+ timerlist_notify(timer_list);
+ }
+}
+
void qemu_clock_enable(QEMUClock *clock, bool enabled)
{
bool old = clock->enabled;
clock->enabled = enabled;
if (enabled && !old) {
+ qemu_clock_notify(clock);
qemu_rearm_alarm_timer(alarm_timer);
}
}
@@ -522,9 +531,7 @@ void qemu_mod_timer_ns(QEMUTimer *ts, int64_t expire_time)
}
/* Interrupt execution to force deadline recalculation. */
qemu_clock_warp(ts->timer_list->clock);
- if (use_icount) {
- timerlist_notify(ts->timer_list);
- }
+ timerlist_notify(ts->timer_list);
}
}
--
1.7.9.5
- [Qemu-devel] [PATCHv12 07/31] aio / timers: Make qemu_run_timers and qemu_run_all_timers return progress, (continued)
- [Qemu-devel] [PATCHv12 07/31] aio / timers: Make qemu_run_timers and qemu_run_all_timers return progress, Alex Bligh, 2013/08/16
- [Qemu-devel] [PATCHv12 05/31] aio / timers: add ppoll support with qemu_poll_ns, Alex Bligh, 2013/08/16
- [Qemu-devel] [PATCHv12 10/31] aio / timers: Add QEMUTimerListGroup and helper functions, Alex Bligh, 2013/08/16
- [Qemu-devel] [PATCHv12 13/31] aio / timers: aio_ctx_prepare sets timeout from AioContext timers, Alex Bligh, 2013/08/16
- [Qemu-devel] [PATCHv12 11/31] aio / timers: Add QEMUTimerListGroup to AioContext, Alex Bligh, 2013/08/16
- [Qemu-devel] [PATCHv12 14/31] aio / timers: Add aio_timer_init & aio_timer_new wrappers, Alex Bligh, 2013/08/16
- [Qemu-devel] [PATCHv12 12/31] aio / timers: Add a notify callback to QEMUTimerList, Alex Bligh, 2013/08/16
- [Qemu-devel] [PATCHv12 16/31] aio / timers: Convert mainloop to use timeout, Alex Bligh, 2013/08/16
- [Qemu-devel] [PATCHv12 15/31] aio / timers: Convert aio_poll to use AioContext timers' deadline, Alex Bligh, 2013/08/16
- [Qemu-devel] [PATCHv12 18/31] aio / timers: Introduce new API timer_new and friends, Alex Bligh, 2013/08/16
- [Qemu-devel] [PATCHv12 17/31] aio / timers: On timer modification, qemu_notify or aio_notify,
Alex Bligh <=
- [Qemu-devel] [PATCHv12 22/31] aio / timers: Remove legacy qemu_clock_deadline & qemu_timerlist_deadline, Alex Bligh, 2013/08/16
- [Qemu-devel] [PATCHv12 09/31] aio / timers: Untangle include files, Alex Bligh, 2013/08/16
- [Qemu-devel] [PATCHv12 23/31] aio / timers: Add qemu_clock_get_ms and qemu_clock_get_ms, Alex Bligh, 2013/08/16
- [Qemu-devel] [PATCHv12 19/31] aio / timers: Use all timerlists in icount warp calculations, Alex Bligh, 2013/08/16
- [Qemu-devel] [PATCHv12 20/31] aio / timers: Add documentation and new format calls, Alex Bligh, 2013/08/16
- [Qemu-devel] [PATCHv12 25/31] aio / timers: Remove main_loop_timerlist, Alex Bligh, 2013/08/16
- [Qemu-devel] [PATCHv12 27/31] aio / timers: convert block_job_sleep_ns and co_sleep_ns to new API, Alex Bligh, 2013/08/16
- [Qemu-devel] [PATCHv12 08/31] aio / timers: Split QEMUClock into QEMUClock and QEMUTimerList, Alex Bligh, 2013/08/16
- [Qemu-devel] [PATCHv12 21/31] aio / timers: Remove alarm timers, Alex Bligh, 2013/08/16
- [Qemu-devel] [PATCHv12 29/31] aio / timers: Add scripts/switch-timer-api, Alex Bligh, 2013/08/16