From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([2001:4830:134:3::10]:50066) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1X4rQr-00041m-SC for qemu-devel@nongnu.org; Wed, 09 Jul 2014 08:57:15 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1X4rQl-0001oF-NL for qemu-devel@nongnu.org; Wed, 09 Jul 2014 08:57:09 -0400 Received: from mx1.redhat.com ([209.132.183.28]:24876) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1X4rQl-0001nR-EF for qemu-devel@nongnu.org; Wed, 09 Jul 2014 08:57:03 -0400 Date: Wed, 9 Jul 2014 14:56:57 +0200 From: Kevin Wolf Message-ID: <20140709125657.GC4537@noname.redhat.com> References: <1404895786-15506-1-git-send-email-pbonzini@redhat.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <1404895786-15506-1-git-send-email-pbonzini@redhat.com> Subject: Re: [Qemu-devel] [PATCH for-2.1] AioContext: do not rely on aio_poll(ctx, true) result to end a loop List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: Paolo Bonzini Cc: borntraeger@de.ibm.com, qemu-devel@nongnu.org, stefanha@redhat.com Am 09.07.2014 um 10:49 hat Paolo Bonzini geschrieben: > Currently, whenever aio_poll(ctx, true) has completed all pending > work it returns true *and* the next call to aio_poll(ctx, true) > will not block. > > This invariant has its roots in qemu_aio_flush()'s implementation > as "while (qemu_aio_wait()) {}". However, qemu_aio_flush() does > not exist anymore and bdrv_drain_all() is implemented differently; > and this invariant is complicated to maintain and subtly different > from the return value of GMainLoop's g_main_context_iteration. > > All calls to aio_poll(ctx, true) except one are guarded by a > while() loop checking for a request to be incomplete, or a > BlockDriverState to be idle. The one remaining call (in > iothread.c) uses this to delay the aio_context_release/acquire > pair until the AioContext is quiescent, however: > > - we can do the same just by using non-blocking aio_poll, > similar to how vl.c invokes main_loop_wait > > - it is buggy, because it does not ensure that the AioContext > is released between an aio_notify and the next time the > iothread goes to sleep. This leads to hangs when stopping > the dataplane thread. > > In the end, these semantics are a bad match for the current > users of AioContext. So modify that one exception in iothread.c, > which also fixes the hangs, as well as the testcase so that > it use the same idiom as the actual QEMU code. > > Reported-by: Christian Borntraeger > Tested-by: Christian Borntraeger > Signed-off-by: Paolo Bonzini Thanks, applied to the block branch. Kevin