From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([2001:4830:134:3::10]:51986) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ZAYG8-0006GW-Vv for qemu-devel@nongnu.org; Thu, 02 Jul 2015 02:46:09 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1ZAYG5-0007jN-Of for qemu-devel@nongnu.org; Thu, 02 Jul 2015 02:46:08 -0400 Received: from e06smtp13.uk.ibm.com ([195.75.94.109]:56299) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ZAYG5-0007ir-EP for qemu-devel@nongnu.org; Thu, 02 Jul 2015 02:46:05 -0400 Received: from /spool/local by e06smtp13.uk.ibm.com with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted for from ; Thu, 2 Jul 2015 07:46:02 +0100 Received: from b06cxnps4076.portsmouth.uk.ibm.com (d06relay13.portsmouth.uk.ibm.com [9.149.109.198]) by d06dlp01.portsmouth.uk.ibm.com (Postfix) with ESMTP id BC41B17D8069 for ; Thu, 2 Jul 2015 07:47:13 +0100 (BST) Received: from d06av06.portsmouth.uk.ibm.com (d06av06.portsmouth.uk.ibm.com [9.149.37.217]) by b06cxnps4076.portsmouth.uk.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP id t626k0q132768204 for ; Thu, 2 Jul 2015 06:46:00 GMT Received: from d06av06.portsmouth.uk.ibm.com (localhost [127.0.0.1]) by d06av06.portsmouth.uk.ibm.com (8.14.4/8.14.4/NCO v10.0 AVout) with ESMTP id t621d21w020159 for ; Wed, 1 Jul 2015 21:39:03 -0400 Message-ID: <5594DE27.3010002@de.ibm.com> Date: Thu, 02 Jul 2015 08:45:59 +0200 From: Christian Borntraeger MIME-Version: 1.0 References: <1435818839-5376-1-git-send-email-famz@redhat.com> In-Reply-To: <1435818839-5376-1-git-send-email-famz@redhat.com> Content-Type: text/plain; charset=iso-8859-15 Content-Transfer-Encoding: 7bit Subject: Re: [Qemu-devel] [PATCH] thread-pool: Notify AIO context upon completion List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: Fam Zheng , qemu-devel@nongnu.org Cc: Kevin Wolf , pbonzini@redhat.com, Stefan Hajnoczi Am 02.07.2015 um 08:33 schrieb Fam Zheng: > bdrv_flush() uses a loop like > > while (rwco.ret == NOT_DONE) { > aio_poll(aio_context, true); > } > > to wait for thread pool, which may not get notified about the scheduled > BH right away, if there is no new event that wakes up a blocking > qemu_poll_ns(). In this case, it may even be a permanent hang. > > Wake the main thread up by writing to the event notifier fd. > > Cc: Paolo Bonzini > Cc: Christian Borntraeger > Signed-off-by: Fam Zheng > > --- > > I suspect this may relate to > > [Qemu-devel] "iothread: release iothread around aio_poll" causes random > hangs at startup > > [http://lists.nongnu.org/archive/html/qemu-devel/2015-06/msg00623.html] > > reported by Christian Borntraeger. Because in iothread there is rarely > any fd activity, so the blocking aio_poll() may block forever if it > misses the BH schedule. > > Christian, could you test this patch against your reproducer? Still does not work. It really seems to be triggered by the null device (and there must be >= 2). > --- > thread-pool.c | 1 + > 1 file changed, 1 insertion(+) > > diff --git a/thread-pool.c b/thread-pool.c > index ac909f4..9b9c065 100644 > --- a/thread-pool.c > +++ b/thread-pool.c > @@ -112,6 +112,7 @@ static void *worker_thread(void *opaque) > qemu_mutex_lock(&pool->lock); > > qemu_bh_schedule(pool->completion_bh); > + aio_notify(pool->ctx); > } > > pool->cur_threads--; >