* [Qemu-devel] [PATCH v2] qtest: Fix deadloop by running main loop AIO context's timers
@ 2015-01-19 9:51 Fam Zheng
2015-01-19 10:03 ` Paolo Bonzini
2015-02-13 9:46 ` Stefan Hajnoczi
0 siblings, 2 replies; 3+ messages in thread
From: Fam Zheng @ 2015-01-19 9:51 UTC (permalink / raw)
To: qemu-devel; +Cc: Paolo Bonzini, qemu-stable, Stefan Hajnoczi
qemu_clock_run_timers() only takes care of main_loop_tlg, we shouldn't
forget aio timer list groups.
Currently, the qemu_clock_deadline_ns_all (a few lines above) counts all
the timergroups of this clock type, including aio tlg, but we don't fire
them, so they are never cleared, which makes a dead loop.
For example, this function hangs when trying to drive throttled block
request queue with qtest clock_step.
Signed-off-by: Fam Zheng <famz@redhat.com>
---
v2: Only run QEMU_CLOCK_VIRTUAL events. (Paolo).
---
cpus.c | 4 ++++
1 file changed, 4 insertions(+)
diff --git a/cpus.c b/cpus.c
index 3a5323b..9b3db0b 100644
--- a/cpus.c
+++ b/cpus.c
@@ -378,15 +378,19 @@ static void icount_warp_rt(void *opaque)
void qtest_clock_warp(int64_t dest)
{
int64_t clock = qemu_clock_get_ns(QEMU_CLOCK_VIRTUAL);
+ AioContext *aio_context;
assert(qtest_enabled());
+ aio_context = qemu_get_aio_context();
while (clock < dest) {
int64_t deadline = qemu_clock_deadline_ns_all(QEMU_CLOCK_VIRTUAL);
int64_t warp = qemu_soonest_timeout(dest - clock, deadline);
+
seqlock_write_lock(&timers_state.vm_clock_seqlock);
timers_state.qemu_icount_bias += warp;
seqlock_write_unlock(&timers_state.vm_clock_seqlock);
qemu_clock_run_timers(QEMU_CLOCK_VIRTUAL);
+ timerlist_run_timers(aio_context->tlg.tl[QEMU_CLOCK_VIRTUAL]);
clock = qemu_clock_get_ns(QEMU_CLOCK_VIRTUAL);
}
qemu_clock_notify(QEMU_CLOCK_VIRTUAL);
--
1.9.3
^ permalink raw reply related [flat|nested] 3+ messages in thread
* Re: [Qemu-devel] [PATCH v2] qtest: Fix deadloop by running main loop AIO context's timers
2015-01-19 9:51 [Qemu-devel] [PATCH v2] qtest: Fix deadloop by running main loop AIO context's timers Fam Zheng
@ 2015-01-19 10:03 ` Paolo Bonzini
2015-02-13 9:46 ` Stefan Hajnoczi
1 sibling, 0 replies; 3+ messages in thread
From: Paolo Bonzini @ 2015-01-19 10:03 UTC (permalink / raw)
To: Fam Zheng, qemu-devel; +Cc: Kevin Wolf, qemu-stable, Stefan Hajnoczi
On 19/01/2015 10:51, Fam Zheng wrote:
> qemu_clock_run_timers() only takes care of main_loop_tlg, we shouldn't
> forget aio timer list groups.
>
> Currently, the qemu_clock_deadline_ns_all (a few lines above) counts all
> the timergroups of this clock type, including aio tlg, but we don't fire
> them, so they are never cleared, which makes a dead loop.
>
> For example, this function hangs when trying to drive throttled block
> request queue with qtest clock_step.
>
> Signed-off-by: Fam Zheng <famz@redhat.com>
>
> ---
> v2: Only run QEMU_CLOCK_VIRTUAL events. (Paolo).
> ---
> cpus.c | 4 ++++
> 1 file changed, 4 insertions(+)
>
> diff --git a/cpus.c b/cpus.c
> index 3a5323b..9b3db0b 100644
> --- a/cpus.c
> +++ b/cpus.c
> @@ -378,15 +378,19 @@ static void icount_warp_rt(void *opaque)
> void qtest_clock_warp(int64_t dest)
> {
> int64_t clock = qemu_clock_get_ns(QEMU_CLOCK_VIRTUAL);
> + AioContext *aio_context;
> assert(qtest_enabled());
> + aio_context = qemu_get_aio_context();
> while (clock < dest) {
> int64_t deadline = qemu_clock_deadline_ns_all(QEMU_CLOCK_VIRTUAL);
> int64_t warp = qemu_soonest_timeout(dest - clock, deadline);
> +
> seqlock_write_lock(&timers_state.vm_clock_seqlock);
> timers_state.qemu_icount_bias += warp;
> seqlock_write_unlock(&timers_state.vm_clock_seqlock);
>
> qemu_clock_run_timers(QEMU_CLOCK_VIRTUAL);
> + timerlist_run_timers(aio_context->tlg.tl[QEMU_CLOCK_VIRTUAL]);
> clock = qemu_clock_get_ns(QEMU_CLOCK_VIRTUAL);
> }
> qemu_clock_notify(QEMU_CLOCK_VIRTUAL);
>
Acked-by: Paolo Bonzini <pbonzini@redhat.com>
Kevin/Stefan, can you apply it to the block branch together with Fam's
qemu-iotests patches for throttling?
Paolo
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [Qemu-devel] [PATCH v2] qtest: Fix deadloop by running main loop AIO context's timers
2015-01-19 9:51 [Qemu-devel] [PATCH v2] qtest: Fix deadloop by running main loop AIO context's timers Fam Zheng
2015-01-19 10:03 ` Paolo Bonzini
@ 2015-02-13 9:46 ` Stefan Hajnoczi
1 sibling, 0 replies; 3+ messages in thread
From: Stefan Hajnoczi @ 2015-02-13 9:46 UTC (permalink / raw)
To: Fam Zheng; +Cc: Paolo Bonzini, qemu-devel, qemu-stable
[-- Attachment #1: Type: text/plain, Size: 772 bytes --]
On Mon, Jan 19, 2015 at 05:51:43PM +0800, Fam Zheng wrote:
> qemu_clock_run_timers() only takes care of main_loop_tlg, we shouldn't
> forget aio timer list groups.
>
> Currently, the qemu_clock_deadline_ns_all (a few lines above) counts all
> the timergroups of this clock type, including aio tlg, but we don't fire
> them, so they are never cleared, which makes a dead loop.
>
> For example, this function hangs when trying to drive throttled block
> request queue with qtest clock_step.
>
> Signed-off-by: Fam Zheng <famz@redhat.com>
>
> ---
> v2: Only run QEMU_CLOCK_VIRTUAL events. (Paolo).
> ---
> cpus.c | 4 ++++
> 1 file changed, 4 insertions(+)
Thanks, applied to my block tree:
https://github.com/stefanha/qemu/commits/block
Stefan
[-- Attachment #2: Type: application/pgp-signature, Size: 473 bytes --]
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2015-02-13 9:46 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2015-01-19 9:51 [Qemu-devel] [PATCH v2] qtest: Fix deadloop by running main loop AIO context's timers Fam Zheng
2015-01-19 10:03 ` Paolo Bonzini
2015-02-13 9:46 ` Stefan Hajnoczi
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).