[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Qemu-devel] [PULL 13/17] icount: reorganize icount_warp_rt
From: |
Paolo Bonzini |
Subject: |
[Qemu-devel] [PULL 13/17] icount: reorganize icount_warp_rt |
Date: |
Thu, 17 Oct 2013 17:48:51 +0200 |
To prepare for future code changes, move the increment of qemu_icount_bias
outside the "if" statement.
Also, hoist outside the if the check for timers that expired due to the
"warping". The check is redundant when !runstate_is_running(), but
doing it this way helps because the code that increments qemu_icount_bias
will be a critical section.
Signed-off-by: Paolo Bonzini <address@hidden>
---
cpus.c | 18 ++++++++++--------
1 file changed, 10 insertions(+), 8 deletions(-)
diff --git a/cpus.c b/cpus.c
index a2d09f3..bc365b7 100644
--- a/cpus.c
+++ b/cpus.c
@@ -291,10 +291,10 @@ static void icount_warp_rt(void *opaque)
if (runstate_is_running()) {
int64_t clock = qemu_clock_get_ns(QEMU_CLOCK_REALTIME);
- int64_t warp_delta = clock - vm_clock_warp_start;
- if (use_icount == 1) {
- qemu_icount_bias += warp_delta;
- } else {
+ int64_t warp_delta;
+
+ warp_delta = clock - vm_clock_warp_start;
+ if (use_icount == 2) {
/*
* In adaptive mode, do not let QEMU_CLOCK_VIRTUAL run too
* far ahead of real time.
@@ -302,13 +302,15 @@ static void icount_warp_rt(void *opaque)
int64_t cur_time = cpu_get_clock();
int64_t cur_icount = cpu_get_icount();
int64_t delta = cur_time - cur_icount;
- qemu_icount_bias += MIN(warp_delta, delta);
- }
- if (qemu_clock_expired(QEMU_CLOCK_VIRTUAL)) {
- qemu_clock_notify(QEMU_CLOCK_VIRTUAL);
+ warp_delta = MIN(warp_delta, delta);
}
+ qemu_icount_bias += warp_delta;
}
vm_clock_warp_start = -1;
+
+ if (qemu_clock_expired(QEMU_CLOCK_VIRTUAL)) {
+ qemu_clock_notify(QEMU_CLOCK_VIRTUAL);
+ }
}
void qtest_clock_warp(int64_t dest)
--
1.8.3.1
- [Qemu-devel] [PULL 05/17] vga: Mark relevant portio lists regions as coalesced MMIO flushing, (continued)
- [Qemu-devel] [PULL 05/17] vga: Mark relevant portio lists regions as coalesced MMIO flushing, Paolo Bonzini, 2013/10/17
- [Qemu-devel] [PULL 03/17] portio: Allow to mark portio lists as coalesced MMIO flushing, Paolo Bonzini, 2013/10/17
- [Qemu-devel] [PULL 10/17] timer: extract timer_mod_ns_locked and timerlist_rearm, Paolo Bonzini, 2013/10/17
- [Qemu-devel] [PULL 11/17] timer: add timer_mod_anticipate and timer_mod_anticipate_ns, Paolo Bonzini, 2013/10/17
- [Qemu-devel] [PULL 07/17] timer: protect timers_state's clock with seqlock, Paolo Bonzini, 2013/10/17
- [Qemu-devel] [PULL 06/17] seqlock: introduce read-write seqlock, Paolo Bonzini, 2013/10/17
- [Qemu-devel] [PULL 08/17] qemu-thread: add QemuEvent, Paolo Bonzini, 2013/10/17
- [Qemu-devel] [PULL 12/17] icount: use cpu_get_icount() directly, Paolo Bonzini, 2013/10/17
- [Qemu-devel] [PULL 09/17] timer: make qemu_clock_enable sync between disable and timer's cb, Paolo Bonzini, 2013/10/17
- [Qemu-devel] [PULL 15/17] icount: document (future) locking rules for icount, Paolo Bonzini, 2013/10/17
- [Qemu-devel] [PULL 13/17] icount: reorganize icount_warp_rt,
Paolo Bonzini <=
- [Qemu-devel] [PULL 14/17] icount: prepare the code for future races in calling qemu_clock_warp, Paolo Bonzini, 2013/10/17
- [Qemu-devel] [PULL 16/17] icount: make it thread-safe, Paolo Bonzini, 2013/10/17
- [Qemu-devel] [PULL 17/17] exec: remove qemu_safe_ram_ptr, Paolo Bonzini, 2013/10/17