From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([2001:4830:134:3::10]:56151) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1WrB1a-0006vO-Jd for qemu-devel@nongnu.org; Sun, 01 Jun 2014 15:02:38 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1WrB1T-0000VV-4i for qemu-devel@nongnu.org; Sun, 01 Jun 2014 15:02:30 -0400 Received: from mx.beyond.pl ([92.43.117.49]:33743) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1WrB1S-0000UJ-U5 for qemu-devel@nongnu.org; Sun, 01 Jun 2014 15:02:23 -0400 Message-ID: <538B78A9.8060804@beyond.pl> Date: Sun, 01 Jun 2014 21:02:01 +0200 From: =?UTF-8?B?TWFyY2luIEdpYnXFgmE=?= MIME-Version: 1.0 References: <538A1F71.4080203@beyond.pl> <538B6D25.8030106@redhat.com> In-Reply-To: <538B6D25.8030106@redhat.com> Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 7bit Subject: Re: [Qemu-devel] [PATCH] thread-pool: fix deadlock when callbacks depends on each other List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: Paolo Bonzini , "qemu-devel@nongnu.org" Cc: Stefan Hajnoczi > 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? > 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... -- mg