icount: reorganize icount_warp_rt
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 <pbonzini@redhat.com>
This commit is contained in:
parent
468cc7cf3b
commit
8ed961d957
18
cpus.c
18
cpus.c
@ -291,10 +291,10 @@ static void icount_warp_rt(void *opaque)
|
|||||||
|
|
||||||
if (runstate_is_running()) {
|
if (runstate_is_running()) {
|
||||||
int64_t clock = qemu_clock_get_ns(QEMU_CLOCK_REALTIME);
|
int64_t clock = qemu_clock_get_ns(QEMU_CLOCK_REALTIME);
|
||||||
int64_t warp_delta = clock - vm_clock_warp_start;
|
int64_t warp_delta;
|
||||||
if (use_icount == 1) {
|
|
||||||
qemu_icount_bias += warp_delta;
|
warp_delta = clock - vm_clock_warp_start;
|
||||||
} else {
|
if (use_icount == 2) {
|
||||||
/*
|
/*
|
||||||
* In adaptive mode, do not let QEMU_CLOCK_VIRTUAL run too
|
* In adaptive mode, do not let QEMU_CLOCK_VIRTUAL run too
|
||||||
* far ahead of real time.
|
* 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_time = cpu_get_clock();
|
||||||
int64_t cur_icount = cpu_get_icount();
|
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);
|
warp_delta = MIN(warp_delta, delta);
|
||||||
}
|
|
||||||
if (qemu_clock_expired(QEMU_CLOCK_VIRTUAL)) {
|
|
||||||
qemu_clock_notify(QEMU_CLOCK_VIRTUAL);
|
|
||||||
}
|
}
|
||||||
|
qemu_icount_bias += warp_delta;
|
||||||
}
|
}
|
||||||
vm_clock_warp_start = -1;
|
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)
|
void qtest_clock_warp(int64_t dest)
|
||||||
|
Loading…
x
Reference in New Issue
Block a user