* [Qemu-devel] [RFC] icount: warp in the main_loop.
@ 2014-07-01 16:13 fred.konrad
2014-07-04 7:30 ` Frederic Konrad
0 siblings, 1 reply; 5+ messages in thread
From: fred.konrad @ 2014-07-01 16:13 UTC (permalink / raw)
To: qemu-devel; +Cc: pbonzini, fred.konrad, mark.burton, peter.maydell
From: KONRAD Frederic <fred.konrad@greensocs.com>
This fixes a bug where QEMU stall in icount mode.
It happens when a simple timer callback is created on VIRTUAL CLOCK modding
itself regularly.
The actual warping mechanism is called once and then the time didn't grow
anymore.
Signed-off-by: KONRAD Frederic <fred.konrad@greensocs.com>
---
main-loop.c | 6 ++++++
1 file changed, 6 insertions(+)
diff --git a/main-loop.c b/main-loop.c
index 8a85493..ef889b0 100644
--- a/main-loop.c
+++ b/main-loop.c
@@ -489,6 +489,12 @@ int main_loop_wait(int nonblocking)
qemu_clock_run_all_timers();
+ /*
+ * In icount mode, sometimes the VCPU is blocked and an event is needed to
+ * continue.
+ * Just warp to make the time grows and have a chance to run the CPU.
+ */
+ qemu_clock_warp(QEMU_CLOCK_VIRTUAL);
return ret;
}
--
1.9.0
^ permalink raw reply related [flat|nested] 5+ messages in thread
* Re: [Qemu-devel] [RFC] icount: warp in the main_loop.
2014-07-01 16:13 [Qemu-devel] [RFC] icount: warp in the main_loop fred.konrad
@ 2014-07-04 7:30 ` Frederic Konrad
2014-07-04 7:57 ` Paolo Bonzini
0 siblings, 1 reply; 5+ messages in thread
From: Frederic Konrad @ 2014-07-04 7:30 UTC (permalink / raw)
To: qemu-devel; +Cc: pbonzini, mark.burton, peter.maydell
On 01/07/2014 18:13, fred.konrad@greensocs.com wrote:
> From: KONRAD Frederic <fred.konrad@greensocs.com>
>
> This fixes a bug where QEMU stall in icount mode.
>
> It happens when a simple timer callback is created on VIRTUAL CLOCK modding
> itself regularly.
>
> The actual warping mechanism is called once and then the time didn't grow
> anymore.
>
> Signed-off-by: KONRAD Frederic <fred.konrad@greensocs.com>
> ---
> main-loop.c | 6 ++++++
> 1 file changed, 6 insertions(+)
>
> diff --git a/main-loop.c b/main-loop.c
> index 8a85493..ef889b0 100644
> --- a/main-loop.c
> +++ b/main-loop.c
> @@ -489,6 +489,12 @@ int main_loop_wait(int nonblocking)
>
> qemu_clock_run_all_timers();
>
> + /*
> + * In icount mode, sometimes the VCPU is blocked and an event is needed to
> + * continue.
> + * Just warp to make the time grows and have a chance to run the CPU.
> + */
> + qemu_clock_warp(QEMU_CLOCK_VIRTUAL);
> return ret;
> }
>
Paolo,
You mentioned some icount patches (I can't find where) can you point me
to them?
Did you already had this bug?
Thanks,
Fred
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [Qemu-devel] [RFC] icount: warp in the main_loop.
2014-07-04 7:30 ` Frederic Konrad
@ 2014-07-04 7:57 ` Paolo Bonzini
2014-07-04 10:28 ` Frederic Konrad
0 siblings, 1 reply; 5+ messages in thread
From: Paolo Bonzini @ 2014-07-04 7:57 UTC (permalink / raw)
To: Frederic Konrad, qemu-devel; +Cc: peter.maydell, mark.burton
Il 04/07/2014 09:30, Frederic Konrad ha scritto:
>> + /*
>> + * In icount mode, sometimes the VCPU is blocked and an event is
>> needed to
>> + * continue.
>> + * Just warp to make the time grows and have a chance to run the
>> CPU.
>> + */
>> + qemu_clock_warp(QEMU_CLOCK_VIRTUAL);
>> return ret;
>> }
>>
> Paolo,
> You mentioned some icount patches (I can't find where) can you point me
> to them?
> Did you already had this bug?
Why is this needed? It's possible that a qemu_clock_warp code is
missing somewhere, but for timers it should be handled here:
static void timerlist_rearm(QEMUTimerList *timer_list)
{
/* Interrupt execution to force deadline recalculation. */
qemu_clock_warp(timer_list->clock->type);
timerlist_notify(timer_list);
}
If the VCPU is blocked, it will set vm_clock_warp_start to the realtime
clock value ("clock") a QEMU_CLOCK_REALTIME timer to the next deadline
("clock + deadline"). At the next deadline, icount_warp_rt will
increase QEMU_CLOCK_VIRTUAL by "clock - vm_clock_warp_state" which
should trigger the clock event.
Paolo
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [Qemu-devel] [RFC] icount: warp in the main_loop.
2014-07-04 7:57 ` Paolo Bonzini
@ 2014-07-04 10:28 ` Frederic Konrad
2014-07-04 10:36 ` Paolo Bonzini
0 siblings, 1 reply; 5+ messages in thread
From: Frederic Konrad @ 2014-07-04 10:28 UTC (permalink / raw)
To: Paolo Bonzini, qemu-devel; +Cc: peter.maydell, mark.burton
On 04/07/2014 09:57, Paolo Bonzini wrote:
> Il 04/07/2014 09:30, Frederic Konrad ha scritto:
>>> + /*
>>> + * In icount mode, sometimes the VCPU is blocked and an event is
>>> needed to
>>> + * continue.
>>> + * Just warp to make the time grows and have a chance to run the
>>> CPU.
>>> + */
>>> + qemu_clock_warp(QEMU_CLOCK_VIRTUAL);
>>> return ret;
>>> }
>>>
>> Paolo,
>> You mentioned some icount patches (I can't find where) can you point me
>> to them?
>> Did you already had this bug?
>
> Why is this needed? It's possible that a qemu_clock_warp code is
> missing somewhere, but for timers it should be handled here:
>
> static void timerlist_rearm(QEMUTimerList *timer_list)
> {
> /* Interrupt execution to force deadline recalculation. */
> qemu_clock_warp(timer_list->clock->type);
> timerlist_notify(timer_list);
> }
>
> If the VCPU is blocked, it will set vm_clock_warp_start to the
> realtime clock value ("clock") a QEMU_CLOCK_REALTIME timer to the next
> deadline ("clock + deadline"). At the next deadline, icount_warp_rt
> will increase QEMU_CLOCK_VIRTUAL by "clock - vm_clock_warp_state"
> which should trigger the clock event.
Right, but when I put a timer eg on QEMU_VIRTUAL_CLOCK the guest is stuck.
icount_warp_rt is not called neither qemu_clock_warp(..)..
So yes as you said seems a qemu_clock_warp is missing somewhere.
Shouldn't icount_warp_rt called regularly to advance the time when the
VCPU is not
executing?
Thanks,
Fred
>
> Paolo
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [Qemu-devel] [RFC] icount: warp in the main_loop.
2014-07-04 10:28 ` Frederic Konrad
@ 2014-07-04 10:36 ` Paolo Bonzini
0 siblings, 0 replies; 5+ messages in thread
From: Paolo Bonzini @ 2014-07-04 10:36 UTC (permalink / raw)
To: Frederic Konrad; +Cc: peter maydell, mark burton, qemu-devel
> Right, but when I put a timer eg on QEMU_VIRTUAL_CLOCK the guest is stuck.
> icount_warp_rt is not called neither qemu_clock_warp(..)..
It should be. timer_mod_ns -> timerlist_rearm -> qemu_clock_warp.
> So yes as you said seems a qemu_clock_warp is missing somewhere.
>
> Shouldn't icount_warp_rt called regularly to advance the time when the
> VCPU is not executing?
No, everything is done dynamically based on timer deadlines. Polling is bad. :)
Paolo
^ permalink raw reply [flat|nested] 5+ messages in thread
end of thread, other threads:[~2014-07-04 10:37 UTC | newest]
Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2014-07-01 16:13 [Qemu-devel] [RFC] icount: warp in the main_loop fred.konrad
2014-07-04 7:30 ` Frederic Konrad
2014-07-04 7:57 ` Paolo Bonzini
2014-07-04 10:28 ` Frederic Konrad
2014-07-04 10:36 ` Paolo Bonzini
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.