qemu-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [Qemu-devel] [PATCH] thread-pool: fix deadlock when callbacks depend


From: Paolo Bonzini
Subject: Re: [Qemu-devel] [PATCH] thread-pool: fix deadlock when callbacks depends on each other
Date: Mon, 02 Jun 2014 17:32:30 +0200
User-agent: Mozilla/5.0 (X11; Linux x86_64; rv:24.0) Gecko/20100101 Thunderbird/24.5.0

Il 01/06/2014 21:02, Marcin Gibuła ha scritto:
Good catch!  The main problem with the patch is that you need to use
atomic_inc/atomic_dec to increment and decrement
pool->pending_completions.

Ok.

Secondarily, event_notifier_set is pretty heavy-weight, does it work if
you wrap the loop like this?

restart:
     QLIST_FOREACH_SAFE(elem, &pool->head, all, next) {
         ...
     }
     if (pool->pending_completions) {
         goto restart;
     }
     event_notifier_test_and_clear(notifier);
     if (pool->pending_completions) {
         event_notifier_set(notifier);
         goto restart;
     }

I'll test it tomorrow. I assume you want to avoid calling
event_notifier_set() until function is reentered via aio_pool?

Yes. But actually, I need to check if it's possible to fix bdrv_drain_all. If you're in coroutine context, you can defer the draining to a safe point using a bottom half. If you're not in coroutine context, perhaps bdrv_drain_all has to be made illegal. Which means a bunch of code auditing...

Paolo

Finally, the same bug is also in block/linux-aio.c and
block/win32-aio.c.

I can try with linux-aio, but my knowledge of windows api is zero...





reply via email to

[Prev in Thread] Current Thread [Next in Thread]