From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([2001:4830:134:3::10]:36170) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Up1SE-0005nc-D9 for qemu-devel@nongnu.org; Tue, 18 Jun 2013 15:20:35 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1Up1SC-0005mh-Bj for qemu-devel@nongnu.org; Tue, 18 Jun 2013 15:20:34 -0400 Received: from mail-wg0-x22e.google.com ([2a00:1450:400c:c00::22e]:36552) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Up1SC-0005mW-6X for qemu-devel@nongnu.org; Tue, 18 Jun 2013 15:20:32 -0400 Received: by mail-wg0-f46.google.com with SMTP id c11so3737542wgh.13 for ; Tue, 18 Jun 2013 12:20:31 -0700 (PDT) Sender: Paolo Bonzini Message-ID: <51C0B2FA.4090808@redhat.com> Date: Tue, 18 Jun 2013 21:20:26 +0200 From: Paolo Bonzini MIME-Version: 1.0 References: <1371381681-14252-1-git-send-email-pingfanl@linux.vnet.ibm.com> <1371381681-14252-3-git-send-email-pingfanl@linux.vnet.ibm.com> <20130618151438.GA12685@vm> In-Reply-To: <20130618151438.GA12685@vm> Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: 7bit Subject: Re: [Qemu-devel] [PATCH v2 2/2] QEMUBH: make AioContext's bh re-entrant List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: mdroth Cc: Liu Ping Fan , Anthony Liguori , qemu-devel@nongnu.org Il 18/06/2013 17:14, mdroth ha scritto: > Could we possibly simplify this by introducing a recursive mutex that we > could use to protect the whole list loop and hold even during the cb? If it is possible, we should avoid recursive locks. It makes impossible to establish a lock hierarchy. For example: > I assume we can't hold the lock during the cb currently since we might > try to reschedule, but if it's a recursive mutex would that simplify > things? If you have two callbacks in two different AioContexts, both of which do bdrv_drain_all(), you get an AB-BA deadlock Also, the barriers for qemu_bh_schedule are needed anyway. It's only those that order bh->next vs. ctx->first_bh that would go away. Paolo > I've been doing something similar with IOHandlers for the QContext > stuff, and that's the approach I took. This patch introduces the > recursive mutex: > > https://github.com/mdroth/qemu/commit/c7ee0844da62283c9466fcb10ddbfadd0b8bfc53