From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([2001:4830:134:3::10]:35781) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1X73rI-0005gW-JU for qemu-devel@nongnu.org; Tue, 15 Jul 2014 10:37:41 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1X73r9-00031q-G6 for qemu-devel@nongnu.org; Tue, 15 Jul 2014 10:37:32 -0400 Received: from mail-wi0-x229.google.com ([2a00:1450:400c:c05::229]:46452) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1X73r9-00031I-9y for qemu-devel@nongnu.org; Tue, 15 Jul 2014 10:37:23 -0400 Received: by mail-wi0-f169.google.com with SMTP id n3so4223117wiv.0 for ; Tue, 15 Jul 2014 07:37:22 -0700 (PDT) Date: Tue, 15 Jul 2014 16:37:19 +0200 From: Stefan Hajnoczi Message-ID: <20140715143718.GA19441@stefanha-thinkpad.redhat.com> References: <1405077612-7806-1-git-send-email-stefanha@redhat.com> <1405077612-7806-3-git-send-email-stefanha@redhat.com> <53C39685.2090400@redhat.com> <53C3B5C2.7010001@redhat.com> MIME-Version: 1.0 Content-Type: multipart/signed; micalg=pgp-sha1; protocol="application/pgp-signature"; boundary="vtzGhvizbBRQ85DL" Content-Disposition: inline In-Reply-To: <53C3B5C2.7010001@redhat.com> Subject: Re: [Qemu-devel] [PATCH for-2.1? 2/2] thread-pool: avoid deadlock in nested aio_poll() calls List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: Paolo Bonzini Cc: Christian Borntraeger , qemu-devel@nongnu.org, Stefan Hajnoczi --vtzGhvizbBRQ85DL Content-Type: text/plain; charset=us-ascii Content-Disposition: inline Content-Transfer-Encoding: quoted-printable On Mon, Jul 14, 2014 at 12:49:38PM +0200, Paolo Bonzini wrote: > Il 14/07/2014 10:36, Paolo Bonzini ha scritto: > > > > > >to > > > > /* In case elem->common.cb() makes a nested aio_poll() call, > > * next may become invalid as well. Instead of just > > * restarting the QLIST_FOREACH_SAFE, go through the BH > > * once more, which also avoids deadlock if element A's > > * callback waits for element B and both completed at the > > * same time. > > */ > > qemu_bh_schedule(pool->completion_bh); > > elem->common.cb(elem->common.opaque, elem->ret); > > qemu_aio_release(elem); >=20 > This is of course missing here: >=20 > break; Let's keep goto restart so we don't use the BH for each completion callback. We just need the BH scheduled once to protect against the deadlock. Stefan --vtzGhvizbBRQ85DL Content-Type: application/pgp-signature -----BEGIN PGP SIGNATURE----- Version: GnuPG v1 iQEcBAEBAgAGBQJTxTyeAAoJEJykq7OBq3PI9aYIAMkX6KWmsV4e3Ml4kBUAhGjS f4MjG4ch2jbmkg1+FDyJIbGeffvUjsjZJRsbMtEe7Ml+vDGKqxEP2my6FC9tkeqM nhxup680Lj1S1R/+dDHhl/uBfCeMJ68ouYWSAm2ezM8SzIAq4fNumstW+vKysfAA aCTAAewBLnyZpiGh7a4fuKWAFUtICUPBdCvj5Y7lr0ePWcauIJebu6DK4mvBQ71M n+1L0d/+ug/Sez2I18WIKx0mYLUC+HJn4gdv0IOadCynseNU/3V8jirl57HSDzr6 RR1TBm4sf9G60XWO4GrBJHtqX4xxeCqhgm4eFckVdwNRY4QfDX55IWwZiLQp4OI= =NZfa -----END PGP SIGNATURE----- --vtzGhvizbBRQ85DL--