]> git.proxmox.com Git - qemu.git/commit
icount: prepare the code for future races in calling qemu_clock_warp
authorPaolo Bonzini <pbonzini@redhat.com>
Mon, 7 Oct 2013 15:30:02 +0000 (17:30 +0200)
committerPaolo Bonzini <pbonzini@redhat.com>
Thu, 17 Oct 2013 15:31:00 +0000 (17:31 +0200)
commitce78d18ced118b03e821135e702ba1d513c8b2a7
treea378f5b85523a1e793f4cc5def8a2a8121735b0b
parent8ed961d95708ee6cadac22fba7762724d533a5b4
icount: prepare the code for future races in calling qemu_clock_warp

Computing the deadline of all vm_clocks is somewhat expensive and calls
out to qemu-timer.c; two reasons not to do it in the seqlock's write-side
critical section.  This however opens the door for races in setting and
reading vm_clock_warp_start.

To plug them, we need to cover the case where a new deadline slips in
between the call to qemu_clock_deadline_ns_all and the actual modification
of the icount_warp_timer.  Restrict changes to vm_clock_warp_start and
the icount_warp_timer's expiration time, to only move them back (which
would simply cause an early wakeup).

If a vm_clock timer is cancelled while CPUs are idle, this might cause the
icount_warp_timer to fire unnecessarily.  This is not a problem, after it
fires the timer becomes inactive and the next call to timer_mod_anticipate
will be precise.

In addition to this, we must deactivate the icount_warp_timer _before_
checking whether CPUs are idle.  This way, if the "last" CPU becomes idle
during the call to timer_del we will still set up the icount_warp_timer.

Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
cpus.c