From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([2001:4830:134:3::10]:46679) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1XMg5N-0002iQ-SV for qemu-devel@nongnu.org; Wed, 27 Aug 2014 12:28:47 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1XMg5E-0005AS-Ow for qemu-devel@nongnu.org; Wed, 27 Aug 2014 12:28:37 -0400 Sender: Paolo Bonzini Message-ID: <53FE0727.5010501@redhat.com> Date: Wed, 27 Aug 2014 18:28:23 +0200 From: Paolo Bonzini MIME-Version: 1.0 References: <53F80DC4.7030102@gmail.com> <20140827155339.21832.73704@loki> In-Reply-To: <20140827155339.21832.73704@loki> Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 7bit Subject: Re: [Qemu-devel] [Qemu-stable] [PATCH] stream: fix the deadlock bug when stream finish List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: Michael Roth , Liu Yu , qemu-stable@nongnu.org Cc: qemu-devel@nongnu.org Il 27/08/2014 17:53, Michael Roth ha scritto: >> In case VM does IO while we run a stream job. >> When stream finishes, the stream coroutine drains all IOs before >> close the unused image, in bdrv_drain_all() it may find >> a pending request which is submitted by guest IO coroutine. >> In order to wait the pending req finish, the subsequent aio_poll() >> call poll() to wait the req. however, if the req is already done by >> threadpool and is waiting for the callback, there is no chance to switch >> back to guest IO coroutine to call the callback and so that the stream >> coroutine waits in poll() all the time. This is the same bug fixed by this patch; commit 3c80ca158c96ff902a30883a8933e755988948b1 Author: Stefan Hajnoczi Date: Tue Jul 15 16:44:26 2014 +0200 thread-pool: avoid deadlock in nested aio_poll() calls The thread pool has a race condition if two elements complete before thread_pool_completion_bh() runs: If element A's callback waits for element B using aio_poll() it will deadlock since pool->completion_bh is not marked scheduled when the nested aio_poll() runs. Fix this by marking the BH scheduled while thread_pool_completion_bh() is executing. This way any nested aio_poll() loops will enter thread_pool_completion_bh() and complete the remaining elements. Signed-off-by: Stefan Hajnoczi Paolo