summaryrefslogtreecommitdiffstats
path: root/qemu-timer.c
Commit message (Collapse)AuthorAgeFilesLines
* win32: remove broken timersPaolo Bonzini2011-11-091-3/+1
| | | | | | | | The non-dynticks timer variations are broken, so they can be removed. Signed-off-by: Paolo Bonzini <pbonzini@redhat.com> Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
* qemu-timer: do not use RunState change handlersPaolo Bonzini2011-10-211-8/+4
| | | | Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
* qemu-timer: move more stuff out of qemu-timer.cPaolo Bonzini2011-10-211-31/+4
| | | | Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
* qemu-timer: use atexit for quit_timersPaolo Bonzini2011-10-211-7/+8
| | | | Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
* qemu-timer: do not refer to runstate_is_running()Paolo Bonzini2011-10-211-4/+1
| | | | Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
* qemu-timer: move icount to cpus.cPaolo Bonzini2011-10-211-279/+0
| | | | | | | None of this is needed by tools, and most of it can even be made static inside cpus.c. Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
* qemu-timer: more clock functionsPaolo Bonzini2011-10-211-0/+25
| | | | | | | These will be used when moving icount accounting to cpus.c. Reviewed-by: Anthony Liguori <aliguori@us.ibm.com> Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
* qemu-timer: move common code to qemu_rearm_alarm_timerPaolo Bonzini2011-10-211-76/+53
| | | | | Reviewed-by: Anthony Liguori <aliguori@us.ibm.com> Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
* qemu-timer: remove active_timers arrayPaolo Bonzini2011-10-211-31/+28
| | | | | | | Embed the list in the QEMUClock instead. Reviewed-by: Anthony Liguori <aliguori@us.ibm.com> Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
* Drop the vm_running global variableLuiz Capitulino2011-09-151-3/+3
| | | | | | Use runstate_is_running() instead, which is introduced by this commit. Signed-off-by: Luiz Capitulino <lcapitulino@redhat.com>
* Replace the VMSTOP macros with a proper state typeLuiz Capitulino2011-09-151-1/+2
| | | | | | | | | | | | | | | Today, when notifying a VM state change with vm_state_notify(), we pass a VMSTOP macro as the 'reason' argument. This is not ideal because the VMSTOP macros tell why qemu stopped and not exactly what the current VM state is. One example to demonstrate this problem is that vm_start() calls vm_state_notify() with reason=0, which turns out to be VMSTOP_USER. This commit fixes that by replacing the VMSTOP macros with a proper state type called RunState. Signed-off-by: Luiz Capitulino <lcapitulino@redhat.com>
* main: force enabling of I/O threadAnthony Liguori2011-09-021-53/+0
| | | | | | | | | | | | | | | | Enabling the I/O thread by default seems like an important part of declaring 1.0. Besides allowing true SMP support with KVM, the I/O thread means that the TCG VCPU doesn't have to multiplex itself with the I/O dispatch routines which currently requires a (racey) signal based alarm system. I know there have been concerns about performance. I think so far the ones that have come up (virtio-net) are most likely due to secondary reasons like decreased batching. I think we ought to force enabling I/O thread early in 1.0 development and commit to resolving any lingering issues. Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
* Use glib memory allocation and free functionsAnthony Liguori2011-08-201-5/+5
| | | | | | qemu_malloc/qemu_free no longer exist after this commit. Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
* Register Linux dyntick timer as per-thread signalJan Kiszka2011-07-231-0/+8
| | | | | | | | | | | | | | | | | | Derived from kvm-tool patch http://thread.gmane.org/gmane.comp.emulators.kvm.devel/74309 Ingo Molnar pointed out that sending the timer signal to the whole process, just blocking it everywhere, is suboptimal with an increasing number of threads. QEMU is also using this pattern so far. Linux provides a (non-portable) way to restrict the signal to a single thread: We can use SIGEV_THREAD_ID unless we are forced to emulate signalfd via an additional thread. That case could theoretically be optimized as well, but it doesn't look worth bothering. Reviewed-by: Richard Henderson <rth@twiddle.net> Signed-off-by: Jan Kiszka <jan.kiszka@siemens.com> Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
* qemu-timer: Introduce clock reset notifierJan Kiszka2011-07-231-1/+28
| | | | | | | | | | | | | | | QEMU_CLOCK_HOST is based on the system time which may jump backward in case the admin or NTP adjusts it. RTC emulations and other device models can suffer in this case as timers will stall for the period the clock was tuned back. This adds a detection mechanism that checks on every host clock readout if the new time is before the last result. If that is the case a notifier list is informed. Device models interested in this event can register a notifier with the clock. Signed-off-by: Jan Kiszka <jan.kiszka@siemens.com> Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
* qemu-timer: change unix timer to dynticksPaolo Bonzini2011-07-231-12/+28
| | | | | | | | | | | A timer that wakes up every millisecond puts a lot of stress on the iothread. The large amount of IPIs causes very high context switch activity, making emulation slow and the UI unusable. This is by the way the same reason why the Windows timers were switched to dynticks. Signed-off-by: Paolo Bonzini <pbonzini@redhat.com> Tested-by: Alexander Graf <agraf@suse.de> Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
* timer: drop HPET and RTCAnthony Liguori2011-06-061-120/+0
| | | | | | | dynticks will provide equally good timer granularity on all modern Linux systems. This is more or less dead code these days. Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
* qemu-timer: Fix timers for w32Stefan Weil2011-04-271-0/+96
| | | | | | | | | | | | | Commit 68c23e5520e8286d79d96ab47c0ea722ceb75041 removed the multimedia timer, but this timer is needed for certain Linux kernels. Otherwise Linux boot stops with this error: MP-BIOS bug: 8254 timer not connected to IO-APIC So the multimedia timer is added again here. Cc: Paolo Bonzini <pbonzini@redhat.com> Signed-off-by: Stefan Weil <weil@mail.berlios.de>
* qemu-timer: Avoid type castsStefan Weil2011-04-271-20/+22
| | | | | | | | The type casts are no longer needed after some small changes in struct qemu_alarm_timer. This also improves readability of the code. Signed-off-by: Stefan Weil <weil@mail.berlios.de>
* qemu-timer: Add and use new function qemu_timer_expired_nsStefan Weil2011-04-271-7/+10
| | | | | | | This simply moves code which is used three times into a new function thus improving readability. Signed-off-by: Stefan Weil <weil@mail.berlios.de>
* qemu_next_deadline should not consider host-time timersPaolo Bonzini2011-04-151-9/+4
| | | | | | | | | It is purely for icount-based virtual timers. And now that we got the code right, rename the function to clarify the intended scope. Signed-off-by: Paolo Bonzini <pbonzini@redhat.com> Tested-by: Edgar E. Iglesias <edgar.iglesias@gmail.com> Signed-off-by: Edgar E. Iglesias <edgar.iglesias@gmail.com>
* Revert wrong fixes for -icount in the iothread casePaolo Bonzini2011-04-151-30/+36
| | | | | | | | | This reverts commits 225d02cd and c9f7383c. While some parts of the 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> Signed-off-by: Edgar E. Iglesias <edgar.iglesias@gmail.com>
* enable vm_clock to "warp" in the iothread+icount casePaolo Bonzini2011-04-151-1/+93
| | | | | | | | | | | | | | | | | | | | | | | | | | The previous patch however is not enough, because if the virtual CPU goes to sleep waiting for a future timer interrupt to wake it up, qemu deadlocks. The timer interrupt never comes because time is driven by icount, but the vCPU doesn't run any insns. You could say that VCPUs should never go to sleep in icount mode if there is a pending vm_clock timer; rather time should just warp to the next vm_clock event with no sleep ever taking place. Even better, you can sleep for some time related to the time left until the next event, to avoid that the warps are too visible externally; for example, you could be sending network packets continously instead of every 100ms. This is what this patch implements. qemu_clock_warp is called: 1) whenever a vm_clock timer is adjusted, to ensure the warp_timer is synchronized; 2) at strategic points in the CPU thread, to make sure the insn counter is synchronized before the CPU starts running. In any case, the warp_timer is disabled while the CPU is running, because the insn counter will then be making progress on its own. Signed-off-by: Paolo Bonzini <pbonzini@redhat.com> Tested-by: Edgar E. Iglesias <edgar.iglesias@gmail.com> Signed-off-by: Edgar E. Iglesias <edgar.iglesias@gmail.com>
* remove qemu_get_clockPaolo Bonzini2011-03-211-17/+0
| | | | | | | | | | These patches are already not doing a great service to out-of-tree modifications to QEMU. However, at least we can warn them by getting rid of the old confusing functions, or otherwise causing compilation errors. This patch removes qemu_get_clock; the previous one changed qemu_new_timer's signature. Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
* add a generic scaling mechanism for timersPaolo Bonzini2011-03-211-8/+17
| | | | | | | | | | | This enables rt_clock timers to use nanosecond resolution, just by using the _ns functions; there is really no reason to forbid that. Migrated timers are all using vm_clock (of course; but I checked that anyway) so the timers in the savevm files are already in nanosecond resolution. So this patch makes no change to the migration format. Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
* change all other clock references to use nanosecond resolution accessorsPaolo Bonzini2011-03-211-6/+6
| | | | | | | | | | | | | | | | | | | | | | This was done with: 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\>' ) after checking that get_clock and new_timer never occur twice on the same line. There were no missed occurrences; however, even if there had been, they would have been caught by the compiler. There was exactly one false positive in qemu_run_timers: - current_time = qemu_get_clock (clock); + current_time = qemu_get_clock_ns (clock); which is of course not in this patch. Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
* change all rt_clock references to use millisecond resolution accessorsPaolo Bonzini2011-03-211-3/+3
| | | | | | | | | | | | | | | 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/' \ $(git grep -l 'new_timer\>.*rt_clock' ) after checking that get_clock and new_timer never occur twice on the same line. There were no missed occurrences; however, even if there had been, they would have been caught by the compiler. Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
* use win32 timer queuesPaolo Bonzini2011-03-131-51/+35
| | | | | | | | Multimedia timers are only useful for compatibility with Windows NT 4.0 and earlier. Plus, the implementation in Wine is extremely heavyweight. Signed-off-by: Paolo Bonzini <pbonzini@redhat.com> Signed-off-by: Blue Swirl <blauwirbel@gmail.com>
* implement win32 dynticks timerPaolo Bonzini2011-03-131-1/+6
| | | | | Signed-off-by: Paolo Bonzini <pbonzini@redhat.com> Signed-off-by: Blue Swirl <blauwirbel@gmail.com>
* do not use qemu_icount_delta in the !use_icount casePaolo Bonzini2011-02-231-34/+25
| | | | | | | | | | | | The !use_icount code is the same for iothread and non-iothread, except that the timeout is different. Since the timeout might as well be infinite and is only masking bugs, use the higher value. With this change the !use_icount code is handled equivalently in qemu_icount_delta and qemu_calculate_timeout, and we rip it out of the former. Signed-off-by: Paolo Bonzini <pbonzini@redhat.com> Signed-off-by: Edgar E. Iglesias <edgar.iglesias@petalogix.com>
* qemu-timer: Fix compilation of new timer code for w32, w64Stefan Weil2011-02-071-2/+2
| | | | | | | | | | 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> Signed-off-by: Blue Swirl <blauwirbel@gmail.com>
* Unify alarm deadline computationPaolo Bonzini2011-02-041-17/+11
| | | | | | | | | This patch shows how using the correct formula for qemu_next_deadline_dyntick can simplify the code of host_alarm_handler and eliminate useless duplication. Signed-off-by: Paolo Bonzini <pbonzini@redhat.com> Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
* Correct alarm deadline computationPaolo Bonzini2011-02-041-4/+11
| | | | | | | | | | | | | | | | When the QEMU_CLOCK_HOST clock was added, computation of its deadline was added to qemu_next_deadline, which is correct but incomplete. I noticed this by reading the very convoluted rules whereby qemu_next_deadline_dyntick is computed, which miss QEMU_CLOCK_HOST when use_icount is true. This patch inlines qemu_next_deadline into qemu_next_deadline_dyntick, and then corrects the logic to skip only QEMU_CLOCK_VIRTUAL when use_icount is true. Signed-off-by: Paolo Bonzini <pbonzini@redhat.com> Cc: Jan Kiszka <jan.kiszka@siemens.com> Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
* use nanoseconds everywhere for timeout computationPaolo Bonzini2011-02-041-16/+16
| | | | | | | Suggested by Aurelien Jarno. Signed-off-by: Paolo Bonzini <pbonzini@redhat.com> Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
* Avoid deadlock whith iothread and icountEdgar E. Iglesias2011-01-231-6/+9
| | | | | | | | When using the iothread together with icount, make sure the qemu_icount counter makes forward progress when the vcpu is idle to avoid deadlocks. Signed-off-by: Edgar E. Iglesias <edgar.iglesias@gmail.com>
* qemu-timer: move commonly used timer code to qemu-timer-commonBlue Swirl2010-10-231-73/+0
| | | | | | | | | | | | | | | | | | | | Move timer init functions to a new file, qemu-timer-common.c. Make other critical timer functions inlined to preserve performance in qemu-timer.c, also move muldiv64() (used by the inline functions) to qemu-timer.h. Adjust block/raw-posix.c and simpletrace.c to use get_clock() directly. Remove a similar/duplicate definition in qemu-tool.c. Adjust hw/omap_clk.c to include qemu-timer.h because muldiv64() is used there. After this change, tracing can be used also for user code and simpletrace on Win32. Cc: Stefan Hajnoczi <stefanha@linux.vnet.ibm.com> Acked-by: Stefan Hajnoczi <stefanha@linux.vnet.ibm.com> Signed-off-by: Blue Swirl <blauwirbel@gmail.com>
* savevm: Add DeviceState paramAlex Williamson2010-07-061-1/+1
| | | | | | | | | | When available, we'd like to be able to access the DeviceState when registering a savevm. For buses with a get_dev_path() function, this will allow us to create more unique savevm id strings. Signed-off-by: Alex Williamson <alex.williamson@redhat.com> Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
* Compile qemu-timer only onceBlue Swirl2010-03-291-18/+2
| | | | | | | | | Arrange various declarations so that also non-CPU code can access them, adjust users. Move CPU specific code to cpus.c. Signed-off-by: Blue Swirl <blauwirbel@gmail.com>
* Add a missing #include for FreeBSD hostsJuergen Lock2010-03-271-0/+3
| | | | | 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 = 0Paolo Bonzini2010-03-271-2/+2
| | | | | | | | | | The period for Win32 timers is very short and always the same independent of dynticks, so it's possible that the timer fires before qemu_run_all_timers has reset alarm_timer->pending to zero. Reset alarm_timer->pending before rearming. Signed-off-by: Paolo Bonzini <pbonzini@redhat.com> Signed-off-by: Aurelien Jarno <aurelien@aurel32.net>
* split out qemu-timer.cPaolo Bonzini2010-03-171-0/+1203
Signed-off-by: Paolo Bonzini <pbonzini@redhat.com> Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
OpenPOWER on IntegriCloud