History | View | Annotate | Download (15.8 kB)
timer: add timer_mod_anticipate and timer_mod_anticipate_ns
These let a user anticipate the deadline of a timer, atomically withother sites that call the function. This helps avoiding complicatedlock hierarchies.
Reviewed-by: Alex Bligh <alex@alex.org.uk>...
timer: extract timer_mod_ns_locked and timerlist_rearm
These will be reused in timer_mod_anticipate functions.
Reviewed-by: Alex Bligh <alex@alex.org.uk>Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
timer: make qemu_clock_enable sync between disable and timer's cb
After disabling the QemuClock, we should make sure that no QemuTimersare still in flight. To implement that with light overhead, we resortto QemuEvent. The caller of disabling will wait on QemuEvent of each...
qemu-timer: drop outdated signal safety comments
host_alarm_handler() is invoked from the signal processing thread(currently the iothread). Previously we did processing in a real signalhandler with signalfd and therefore needed signal-safe timer code....
qemu-timer: make qemu_timer_mod_ns() and qemu_timer_del() thread-safe
Introduce QEMUTimerList->active_timers_lock to protect the linked listof active timers. This allows qemu_timer_mod_ns() to be called from anythread.
Note that vm_clock is not thread-safe and its use of...
qemu-timer: do not take the lock in timer_pending
We can deduce the result from expire_time, by making it always -1 ifthe timer is not in the active_timers list. We need to check againstnegative times passed to timer_mod_ns; clamping them to zero is not...
aio / timers: Rearrange timer.h & make legacy functions call non-legacy
Rearrange timer.h so it is in order by function type.
Make legacy functions call non-legacy functions rather than vice-versa.
Convert cpus.c to use new API.
Signed-off-by: Alex Bligh <alex@alex.org.uk>...
aio / timers: Remove main_loop_timerlist
Now we have timerlistgroups implemented and main_loop_tlg, weno longer need the concept of a default timer list associatedwith each clock. Remove it and simplify initialisation ofclocks and timer lists.
aio / timers: Remove legacy interface
Remove the legacy interface from include/qemu/timers.h.
Ensure struct QEMUClock is not exposed at all.
Signed-off-by: Alex Bligh <alex@alex.org.uk>Signed-off-by: Stefan Hajnoczi <stefanha@redhat.com>
aio / timers: Remove alarm timers
Remove alarm timers from qemu-timers.c now we use g_poll / ppollinstead.
aio / timers: Remove legacy qemu_clock_deadline & qemu_timerlist_deadline
Remove qemu_clock_deadline and qemu_timerlist_deadline now we are usingthe ns functions throughout.
aio / timers: Add a notify callback to QEMUTimerList
Add a notify pointer to QEMUTimerList so it knows what to notifyon a timer change.
aio / timers: On timer modification, qemu_notify or aio_notify
On qemu_mod_timer_ns, ensure qemu_notify or aio_notify is called toend the appropriate poll(), irrespective of use_icount value.
On qemu_clock_enable, ensure qemu_notify or aio_notify is called for...
aio / timers: Use all timerlists in icount warp calculations
Notify all timerlists derived from vm_clock in icount warpcalculations.
When calculating timer delay based on vm_clock deadline, useall timerlists.
For compatibility, maintain an apparent bug where when using...
aio / timers: Add prctl(PR_SET_TIMERSLACK, 1, ...) to reduce timer slack
Where supported, called prctl(PR_SET_TIMERSLACK, 1, ...) toset one nanosecond timer slack to increase precision of timercalls.
aio / timers: Make qemu_run_timers and qemu_run_all_timers return progress
Make qemu_run_timers and qemu_run_all_timers return progressso that aio_poll etc. can determine whether a timer has beenrun.
aio / timers: Split QEMUClock into QEMUClock and QEMUTimerList
Split QEMUClock into QEMUClock and QEMUTimerList so that we canhave more than one QEMUTimerList associated with the same clock.
Introduce a main_loop_timerlist concept and make existingqemu_clock_* calls that actually should operate on a QEMUTimerList...
aio / timers: Add QEMUTimerListGroup and helper functions
Add QEMUTimerListGroup and helper functions, to representa QEMUTimerList associated with each clock. Add a defaultQEMUTimerListGroup representing the default timer listswhich are not associated with any other object (e.g....
aio / timers: add ppoll support with qemu_poll_ns
Add qemu_poll_ns which works like g_poll but takes a nanosecondtimeout.
aio / timers: Rename qemu_timer_* functions
Rename four functions in preparation for new API.
Rename qemu_timer_expired to timer_expiredRename qemu_timer_expire_time_ns to timer_expire_time_nsRename qemu_timer_pending to timer_pendingRename qemu_timer_expired_ns to timer_expired_ns...
aio / timers: Rename qemu_new_clock and expose clock types
Rename qemu_new_clock to qemu_clock_new.
Expose clock types.
aio / timers: add qemu-timer.c utility functions
Add utility functions to qemu-timer.c for nanosecond timing.
Add qemu_clock_deadline_ns to calculate deadlines tonanosecond accuracy.
Add utility function qemu_soonest_timeout to calculate soonest deadline....
aio / timers: Consistent treatment of disabled clocks for deadlines
Make treatment of disabled clocks consistent in deadline calculation
qemu-timer: move timeBeginPeriod/timeEndPeriod to os-win32
These are needed for any of the Win32 alarm timer implementations.They are not tied to mmtimer exclusively.
Jacob tested this patch with both mmtimer and Win32 timers.
Cc: qemu-stable@nongnu.org...
softmmu: move include files to include/sysemu/
Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
misc: move include files to include/qemu/
monitor: move include files to include/monitor/
ui: move files to ui/ and include/ui/
net: do not include net.h everywhere
qemu-timer: Fix compilation for non-POSIX hosts
A compiler warning is caused by the unused local function reinit_timerson non-POSIX hosts. Include that function only for POSIX hosts.
Signed-off-by: Stefan Weil <sw@weilnetz.de>Signed-off-by: Blue Swirl <blauwirbel@gmail.com>
build: pthread_atfork() needs include of pthread.h
Cc: Paolo Bonzini <pbonzini@redhat.com>Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
qemu-timer: reinitialize timers after fork
Timers are not inherited by the child of a fork(2), so just usepthread_atfork to reinstate them after daemonize.
Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
Merge remote-tracking branch 'origin/master' into threadpool
qemu-timer: make initialization functions idempotent
qemu-timer: Check for usable fields for SIGEV_THREAD_ID
Older glibc (RHEL 5.x, Debian 5.x) does not have the _sigev_un._tidmember in its structure definition, while the accompanying kernelheaders do define SIGEV_THREAD_ID. We need configure to check for...
qemu-timer: simplify qemu_run_timers
ptimer_head is an invariant pointer to clock->active_timers.Remove it, and just reference clock->active_timers directly.
Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>Signed-off-by: Stefan Hajnoczi <stefanha@gmail.com>
qemu-timer: properly arm alarm timer for timers set by device initialization
QEMU will hang when fed the following command-line
qemu-system-mips -kernel vmlinux-2.6.32-5-4kc-malta -append "console=ttyS0" -nographic -net none
The -net none is important otherwise it seems some events are generated...
qemu_rearm_alarm_timer: do not call rearm if the next deadline is INT64_MAX
qemu_rearm_alarm_timer partially duplicates the code inqemu_next_alarm_deadline to figure out if it needs to rearm the timer.If it calls qemu_next_alarm_deadline, it always rearms the timer even if...
Support 'help' as a synonym for '?' in command line options
For command line options which permit '?' meaning 'please list thepermitted values', add support for 'help' as a synonym, by abstractingthe check out into a helper function.
This change means that in some cases where we were being lazy in...
qemu-timer: Fix wrong error message
Function timeSetEvent returns 0 when it fails, but it does not setan error code which can be retrieved by GetLastError.
Therefore calling GetLastError is useless.
Signed-off-by: Stefan Weil <sw@weilnetz.de>
qemu-timer: Move include for __FreeBSD_version to header
sys/param.h is needed for __FreeBSD_version.Pointed out by Juergen, thanks.
Signed-off-by: Andreas Faerber <andreas.faerber@web.de>Cc: Juergen Lock <nox@jelal.kn-bremen.de>Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
qemu-timer: Fix limits for w32 mmtimer
timeSetEvent only accepts delays in the range which is returned bytimeGetDevCaps.
The lower limit is typically 1 (= 1 ms), so the constant value of 1in the old code usually worked.
The upper limit can be as low as 10000 ms, so the latest changes in...
qemu-timer: Remove redundant include statements
qemu-timer.h includes qemu-common.h which already includes time.h,sys/time.h, windows.h, unistd.h, fcntl.h, errno.h and signal.h.
Therefore those include statements are redundant and can be removed.
Reviewed-by: Paolo Bonzini <pbonzini@redhat.com>...
qemu-timer: Remove unused function qemu_alarm_pending
The last user of this function was removed by commit12d4536f7d911b6d87a766ad7300482ea663cea2.
Reviewed-by: Paolo Bonzini <pbonzini@redhat.com>Signed-off-by: Stefan Weil <sw@weilnetz.de>
qemu-timer: Use bool, false, true for boolean values
This avoids conversions between int and bool / char.
It also makes the code more readable.
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-timer: Optimize data structures
Remove all holes which were found by pahole on Linux x86_64(and replace "struct QEMUTimer" by "QEMUTimer").
qemu_next_alarm_deadline: check the expire time of a clock only if it is enabled
Also delta in qemu_next_alarm_deadline is a 64 bit value so set thedefault to INT64_MAX instead of INT32_MAX.
Signed-off-by: Stefano Stabellini <stefano.stabellini@eu.citrix.com>...
main_loop_wait: block indefinitely
- remove qemu_calculate_timeout;
- explicitly size timeout to uint32_t;
- introduce slirp_update_timeout;
- pass NULL as timeout argument to select in case timeout is the maximumvalue;
timers: the rearm function should be able to handle delta = INT64_MAX
Fix win32_rearm_timer and mm_rearm_timer: they should be able to handleINT64_MAX as a delta parameter without overflowing.Also, the next deadline in ms should be calculated rounding down rather...
qemu-timer.c: Remove 250us timeouts
Basically, the main wait loop calls qemu_run_all_timers() unconditionally. Thefirst thing this routine used to do is to see if a timer had been serviced,and then reset the loop timeout to the next deadline.
However, the new deadlines had not been calculated at that point, as...
qtest: add clock management
This patch combines qtest and -icount together to turn the vm_clockinto a source that can be fully managed by the client. To this end newcommands clock_step and clock_set are added. Hooking them with libqtestis left as an exercise to the reader....
notifier: switch to QLIST
Notifiers do not need to access both ends of the list, and usinga QLIST also simplifies the API.
remove #if 0 code for timers
Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>Signed-off-by: Stefan Hajnoczi <stefanha@linux.vnet.ibm.com>
win32: remove broken timers
The non-dynticks timer variations are broken, so they can beremoved.
qemu-timer: move common code to qemu_rearm_alarm_timer
Reviewed-by: Anthony Liguori <aliguori@us.ibm.com>Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
qemu-timer: more clock functions
These will be used when moving icount accounting to cpus.c.
qemu-timer: move icount to cpus.c
None of this is needed by tools, and most of it can even be made staticinside cpus.c.
qemu-timer: do not refer to runstate_is_running()
qemu-timer: use atexit for quit_timers
qemu-timer: move more stuff out of qemu-timer.c
qemu-timer: do not use RunState change handlers
qemu-timer: remove active_timers array
Embed the list in the QEMUClock instead.
Replace the VMSTOP macros with a proper state type
Today, when notifying a VM state change with vm_state_notify(),we pass a VMSTOP macro as the 'reason' argument. This is not idealbecause the VMSTOP macros tell why qemu stopped and not exactlywhat the current VM state is....
Drop the vm_running global variable
Use runstate_is_running() instead, which is introduced by this commit.
Signed-off-by: Luiz Capitulino <lcapitulino@redhat.com>
main: force enabling of I/O thread
Enabling the I/O thread by default seems like an important part of declaring1.0. Besides allowing true SMP support with KVM, the I/O thread means that theTCG VCPU doesn't have to multiplex itself with the I/O dispatch routines which...
Use glib memory allocation and free functions
qemu_malloc/qemu_free no longer exist after this commit.
Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
qemu-timer: Introduce clock reset notifier
QEMU_CLOCK_HOST is based on the system time which may jump backward incase the admin or NTP adjusts it. RTC emulations and other device modelscan suffer in this case as timers will stall for the period the clock...
Register Linux dyntick timer as per-thread signal
Derived from kvm-tool patchhttp://thread.gmane.org/gmane.comp.emulators.kvm.devel/74309
Ingo Molnar pointed out that sending the timer signal to the wholeprocess, just blocking it everywhere, is suboptimal with an increasing...
qemu-timer: change unix timer to dynticks
A timer that wakes up every millisecond puts a lot of stress on theiothread. The large amount of IPIs causes very high context switchactivity, making emulation slow and the UI unusable. This is by theway the same reason why the Windows timers were switched to dynticks....
timer: drop HPET and RTC
dynticks will provide equally good timer granularity on all modern Linuxsystems. This is more or less dead code these days.
qemu-timer: Add and use new function qemu_timer_expired_ns
This simply moves code which is used three timesinto a new function thus improving readability.
Signed-off-by: Stefan Weil <weil@mail.berlios.de>
qemu-timer: Avoid type casts
The type casts are no longer needed after some small changesin struct qemu_alarm_timer. This also improves readabilityof the code.
qemu-timer: Fix timers for w32
Commit 68c23e5520e8286d79d96ab47c0ea722ceb75041 removed themultimedia timer, but this timer is needed for certainLinux kernels. Otherwise Linux boot stops with this error:
MP-BIOS bug: 8254 timer not connected to IO-APIC...
enable vm_clock to "warp" in the iothread+icount case
The previous patch however is not enough, because if the virtual CPUgoes to sleep waiting for a future timer interrupt to wake it up, qemudeadlocks. The timer interrupt never comes because time is driven by...
Revert wrong fixes for -icount in the iothread case
This reverts commits 225d02cd and c9f7383c. While some parts ofthe latter could be saved, I preferred a smooth, complete revert.
Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>Tested-by: Edgar E. Iglesias <edgar.iglesias@gmail.com>...
qemu_next_deadline should not consider host-time timers
It is purely for icount-based virtual timers. And now that we got thecode right, rename the function to clarify the intended scope.
change all rt_clock references to use millisecond resolution accessors
This was done with:
sed -i '/get_clock\>.*rt_clock/s/get_clock\>/get_clock_ms/' \ $(git grep -l 'get_clock\>.*rt_clock' ) sed -i '/new_timer\>.*rt_clock/s/new_timer\>/new_timer_ms/' \...
change all other clock references to use nanosecond resolution accessors
sed -i 's/qemu_get_clock\>/qemu_get_clock_ns/' \ $(git grep -l 'qemu_get_clock\>' ) sed -i 's/qemu_new_timer\>/qemu_new_timer_ns/' \ $(git grep -l 'qemu_new_timer\>' )...
add a generic scaling mechanism for timers
This enables rt_clock timers to use nanosecond resolution, just byusing the _ns functions; there is really no reason to forbid that.
Migrated timers are all using vm_clock (of course; but I checked thatanyway) so the timers in the savevm files are already in nanosecond...
remove qemu_get_clock
These patches are already not doing a great service to out-of-treemodifications to QEMU. However, at least we can warn them by gettingrid of the old confusing functions, or otherwise causing compilationerrors. This patch removes qemu_get_clock; the previous one changed...
implement win32 dynticks timer
Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>Signed-off-by: Blue Swirl <blauwirbel@gmail.com>
use win32 timer queues
Multimedia timers are only useful for compatibility with Windows NT 4.0and earlier. Plus, the implementation in Wine is extremely heavyweight.
do not use qemu_icount_delta in the !use_icount case
The !use_icount code is the same for iothread and non-iothread,except that the timeout is different. Since the timeout might aswell be infinite and is only masking bugs, use the higher value.With this change the !use_icount code is handled equivalently...
qemu-timer: Fix compilation of new timer code for w32, w64
qemu_next_alarm_deadline() is needed by MinGW, too.
Cc: Paolo Bonzini <pbonzini@redhat.com>Cc: Anthony Liguori <aliguori@us.ibm.com>Acked-by: Paolo Bonzini <pbonzini@redhat.com>Signed-off-by: Stefan Weil <weil@mail.berlios.de>...
use nanoseconds everywhere for timeout computation
Suggested by Aurelien Jarno.
Correct alarm deadline computation
When the QEMU_CLOCK_HOST clock was added, computation of itsdeadline was added to qemu_next_deadline, which is correct butincomplete.
I noticed this by reading the very convoluted rules wherebyqemu_next_deadline_dyntick is computed, which miss QEMU_CLOCK_HOST...
Unify alarm deadline computation
This patch shows how using the correct formula forqemu_next_deadline_dyntick can simplify the code ofhost_alarm_handler and eliminate useless duplication.
Avoid deadlock whith iothread and icount
When using the iothread together with icount, make sure theqemu_icount counter makes forward progress when the vcpu isidle to avoid deadlocks.
Signed-off-by: Edgar E. Iglesias <edgar.iglesias@gmail.com>
qemu-timer: move commonly used timer code to qemu-timer-common
Move timer init functions to a new file, qemu-timer-common.c. Make othercritical timer functions inlined to preserve performance inqemu-timer.c, also move muldiv64() (used by the inline functions)...
savevm: Add DeviceState param
When available, we'd like to be able to access the DeviceStatewhen registering a savevm. For buses with a get_dev_path()function, this will allow us to create more unique savevmid strings.
Signed-off-by: Alex Williamson <alex.williamson@redhat.com>...
Compile qemu-timer only once
Arrange various declarations so that also non-CPU code can accessthem, adjust users.
Move CPU specific code to cpus.c.
Signed-off-by: Blue Swirl <blauwirbel@gmail.com>
Add a missing #include for FreeBSD hosts
Signed-off-by: Juergen Lock <nox@jelal.kn-bremen.de>Signed-off-by: Aurelien Jarno <aurelien@aurel32.net>
fix race between timer firing vs. alarm_timer->pending = 0
The period for Win32 timers is very short and always the sameindependent of dynticks, so it's possible that the timer firesbefore qemu_run_all_timers has reset alarm_timer->pending to zero.Reset alarm_timer->pending before rearming....
split out qemu-timer.c