mirror of https://gitee.com/openkylin/qemu.git
do not use qemu_icount_delta in the !use_icount case
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>
This commit is contained in:
parent
9a31334f41
commit
c9f7383c6e
59
qemu-timer.c
59
qemu-timer.c
|
@ -112,9 +112,7 @@ static int64_t cpu_get_clock(void)
|
||||||
|
|
||||||
static int64_t qemu_icount_delta(void)
|
static int64_t qemu_icount_delta(void)
|
||||||
{
|
{
|
||||||
if (!use_icount) {
|
if (use_icount == 1) {
|
||||||
return 5000 * (int64_t) 1000000;
|
|
||||||
} else if (use_icount == 1) {
|
|
||||||
/* When not using an adaptive execution frequency
|
/* When not using an adaptive execution frequency
|
||||||
we tend to get badly out of sync with real time,
|
we tend to get badly out of sync with real time,
|
||||||
so just delay for a reasonable amount of time. */
|
so just delay for a reasonable amount of time. */
|
||||||
|
@ -1077,43 +1075,36 @@ void quit_timers(void)
|
||||||
int qemu_calculate_timeout(void)
|
int qemu_calculate_timeout(void)
|
||||||
{
|
{
|
||||||
int timeout;
|
int timeout;
|
||||||
|
int64_t add;
|
||||||
|
int64_t delta;
|
||||||
|
|
||||||
#ifdef CONFIG_IOTHREAD
|
|
||||||
/* When using icount, making forward progress with qemu_icount when the
|
/* When using icount, making forward progress with qemu_icount when the
|
||||||
guest CPU is idle is critical. We only use the static io-thread timeout
|
guest CPU is idle is critical. We only use the static io-thread timeout
|
||||||
for non icount runs. */
|
for non icount runs. */
|
||||||
if (!use_icount) {
|
if (!use_icount || !vm_running) {
|
||||||
return 1000;
|
return 5000;
|
||||||
}
|
}
|
||||||
#endif
|
|
||||||
|
|
||||||
if (!vm_running)
|
/* Advance virtual time to the next event. */
|
||||||
timeout = 5000;
|
delta = qemu_icount_delta();
|
||||||
else {
|
if (delta > 0) {
|
||||||
/* XXX: use timeout computed from timers */
|
/* If virtual time is ahead of real time then just
|
||||||
int64_t add;
|
wait for IO. */
|
||||||
int64_t delta;
|
timeout = (delta + 999999) / 1000000;
|
||||||
/* Advance virtual time to the next event. */
|
} else {
|
||||||
delta = qemu_icount_delta();
|
/* Wait for either IO to occur or the next
|
||||||
if (delta > 0) {
|
timer event. */
|
||||||
/* If virtual time is ahead of real time then just
|
add = qemu_next_deadline();
|
||||||
wait for IO. */
|
/* We advance the timer before checking for IO.
|
||||||
timeout = (delta + 999999) / 1000000;
|
Limit the amount we advance so that early IO
|
||||||
} else {
|
activity won't get the guest too far ahead. */
|
||||||
/* Wait for either IO to occur or the next
|
if (add > 10000000)
|
||||||
timer event. */
|
add = 10000000;
|
||||||
add = qemu_next_deadline();
|
delta += add;
|
||||||
/* We advance the timer before checking for IO.
|
qemu_icount += qemu_icount_round (add);
|
||||||
Limit the amount we advance so that early IO
|
timeout = delta / 1000000;
|
||||||
activity won't get the guest too far ahead. */
|
if (timeout < 0)
|
||||||
if (add > 10000000)
|
timeout = 0;
|
||||||
add = 10000000;
|
|
||||||
delta += add;
|
|
||||||
qemu_icount += qemu_icount_round (add);
|
|
||||||
timeout = delta / 1000000;
|
|
||||||
if (timeout < 0)
|
|
||||||
timeout = 0;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return timeout;
|
return timeout;
|
||||||
|
|
Loading…
Reference in New Issue