mirror of https://github.com/xqemu/xqemu.git
icount: use cpu_get_icount() directly
This will help later when we will have to place these calls in a critical section, and thus call a version of cpu_get_icount() that does not take the lock. Reviewed-by: Alex Bligh <alex@alex.org.uk> Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
This commit is contained in:
parent
add40e9777
commit
468cc7cf3b
7
cpus.c
7
cpus.c
|
@ -236,12 +236,15 @@ static void icount_adjust(void)
|
||||||
int64_t cur_icount;
|
int64_t cur_icount;
|
||||||
int64_t delta;
|
int64_t delta;
|
||||||
static int64_t last_delta;
|
static int64_t last_delta;
|
||||||
|
|
||||||
/* If the VM is not running, then do nothing. */
|
/* If the VM is not running, then do nothing. */
|
||||||
if (!runstate_is_running()) {
|
if (!runstate_is_running()) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
cur_time = cpu_get_clock();
|
cur_time = cpu_get_clock();
|
||||||
cur_icount = qemu_clock_get_ns(QEMU_CLOCK_VIRTUAL);
|
cur_icount = cpu_get_icount();
|
||||||
|
|
||||||
delta = cur_icount - cur_time;
|
delta = cur_icount - cur_time;
|
||||||
/* FIXME: This is a very crude algorithm, somewhat prone to oscillation. */
|
/* FIXME: This is a very crude algorithm, somewhat prone to oscillation. */
|
||||||
if (delta > 0
|
if (delta > 0
|
||||||
|
@ -297,7 +300,7 @@ static void icount_warp_rt(void *opaque)
|
||||||
* far ahead of real time.
|
* far ahead of real time.
|
||||||
*/
|
*/
|
||||||
int64_t cur_time = cpu_get_clock();
|
int64_t cur_time = cpu_get_clock();
|
||||||
int64_t cur_icount = qemu_clock_get_ns(QEMU_CLOCK_VIRTUAL);
|
int64_t cur_icount = cpu_get_icount();
|
||||||
int64_t delta = cur_time - cur_icount;
|
int64_t delta = cur_time - cur_icount;
|
||||||
qemu_icount_bias += MIN(warp_delta, delta);
|
qemu_icount_bias += MIN(warp_delta, delta);
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue