提交 cb842c90 编写于 作者: P Paolo Bonzini 提交者: Edgar E. Iglesias

qemu_next_deadline should not consider host-time timers

It is purely for icount-based virtual timers.  And now that we got the
code right, rename the function to clarify the intended scope.
Signed-off-by: NPaolo Bonzini <pbonzini@redhat.com>
Tested-by: NEdgar E. Iglesias <edgar.iglesias@gmail.com>
Signed-off-by: NEdgar E. Iglesias <edgar.iglesias@gmail.com>
上级 1ece93a9
...@@ -833,7 +833,7 @@ static void *qemu_tcg_cpu_thread_fn(void *arg) ...@@ -833,7 +833,7 @@ static void *qemu_tcg_cpu_thread_fn(void *arg)
while (1) { while (1) {
cpu_exec_all(); cpu_exec_all();
if (use_icount && qemu_next_deadline() <= 0) { if (use_icount && qemu_next_icount_deadline() <= 0) {
qemu_notify_event(); qemu_notify_event();
} }
qemu_tcg_wait_io_event(); qemu_tcg_wait_io_event();
...@@ -1050,7 +1050,7 @@ static int tcg_cpu_exec(CPUState *env) ...@@ -1050,7 +1050,7 @@ static int tcg_cpu_exec(CPUState *env)
qemu_icount -= (env->icount_decr.u16.low + env->icount_extra); qemu_icount -= (env->icount_decr.u16.low + env->icount_extra);
env->icount_decr.u16.low = 0; env->icount_decr.u16.low = 0;
env->icount_extra = 0; env->icount_extra = 0;
count = qemu_icount_round (qemu_next_deadline()); count = qemu_icount_round(qemu_next_icount_deadline());
qemu_icount += count; qemu_icount += count;
decr = (count > 0xffff) ? 0xffff : count; decr = (count > 0xffff) ? 0xffff : count;
count -= decr; count -= decr;
......
...@@ -452,7 +452,7 @@ void qemu_clock_warp(QEMUClock *clock) ...@@ -452,7 +452,7 @@ void qemu_clock_warp(QEMUClock *clock)
} }
vm_clock_warp_start = qemu_get_clock_ns(rt_clock); vm_clock_warp_start = qemu_get_clock_ns(rt_clock);
deadline = qemu_next_deadline(); deadline = qemu_next_icount_deadline();
if (deadline > 0) { if (deadline > 0) {
/* /*
* Ensure the vm_clock proceeds even when the virtual CPU goes to * Ensure the vm_clock proceeds even when the virtual CPU goes to
...@@ -765,21 +765,16 @@ static void host_alarm_handler(int host_signum) ...@@ -765,21 +765,16 @@ static void host_alarm_handler(int host_signum)
} }
} }
int64_t qemu_next_deadline(void) int64_t qemu_next_icount_deadline(void)
{ {
/* To avoid problems with overflow limit this to 2^32. */ /* To avoid problems with overflow limit this to 2^32. */
int64_t delta = INT32_MAX; int64_t delta = INT32_MAX;
assert(use_icount);
if (active_timers[QEMU_CLOCK_VIRTUAL]) { if (active_timers[QEMU_CLOCK_VIRTUAL]) {
delta = active_timers[QEMU_CLOCK_VIRTUAL]->expire_time - delta = active_timers[QEMU_CLOCK_VIRTUAL]->expire_time -
qemu_get_clock_ns(vm_clock); qemu_get_clock_ns(vm_clock);
} }
if (active_timers[QEMU_CLOCK_HOST]) {
int64_t hdelta = active_timers[QEMU_CLOCK_HOST]->expire_time -
qemu_get_clock_ns(host_clock);
if (hdelta < delta)
delta = hdelta;
}
if (delta < 0) if (delta < 0)
delta = 0; delta = 0;
...@@ -1169,7 +1164,7 @@ int qemu_calculate_timeout(void) ...@@ -1169,7 +1164,7 @@ int qemu_calculate_timeout(void)
} else { } else {
/* Wait for either IO to occur or the next /* Wait for either IO to occur or the next
timer event. */ timer event. */
add = qemu_next_deadline(); add = qemu_next_icount_deadline();
/* We advance the timer before checking for IO. /* We advance the timer before checking for IO.
Limit the amount we advance so that early IO Limit the amount we advance so that early IO
activity won't get the guest too far ahead. */ activity won't get the guest too far ahead. */
......
...@@ -51,7 +51,7 @@ int qemu_timer_expired(QEMUTimer *timer_head, int64_t current_time); ...@@ -51,7 +51,7 @@ int qemu_timer_expired(QEMUTimer *timer_head, int64_t current_time);
void qemu_run_all_timers(void); void qemu_run_all_timers(void);
int qemu_alarm_pending(void); int qemu_alarm_pending(void);
int64_t qemu_next_deadline(void); int64_t qemu_next_icount_deadline(void);
void configure_alarms(char const *opt); void configure_alarms(char const *opt);
void configure_icount(const char *option); void configure_icount(const char *option);
int qemu_calculate_timeout(void); int qemu_calculate_timeout(void);
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册