From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([2001:4830:134:3::10]:48656) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1X7lF6-0007Eh-3e for qemu-devel@nongnu.org; Thu, 17 Jul 2014 08:57:07 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1X7lEy-0007rt-10 for qemu-devel@nongnu.org; Thu, 17 Jul 2014 08:57:00 -0400 Received: from mx1.redhat.com ([209.132.183.28]:36829) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1X7lEx-0007rM-Oj for qemu-devel@nongnu.org; Thu, 17 Jul 2014 08:56:51 -0400 Date: Thu, 17 Jul 2014 13:56:44 +0100 From: Stefan Hajnoczi Message-ID: <20140717125644.GB24256@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> <20140715143718.GA19441@stefanha-thinkpad.redhat.com> <53C546F1.1090003@redhat.com> MIME-Version: 1.0 Content-Type: multipart/signed; micalg=pgp-sha1; protocol="application/pgp-signature"; boundary="CUfgB8w4ZwR/yMy5" Content-Disposition: inline In-Reply-To: <53C546F1.1090003@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: Stefan Hajnoczi , qemu-devel@nongnu.org, Christian Borntraeger --CUfgB8w4ZwR/yMy5 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline Content-Transfer-Encoding: quoted-printable On Tue, Jul 15, 2014 at 05:21:21PM +0200, Paolo Bonzini wrote: > Il 15/07/2014 16:37, Stefan Hajnoczi ha scritto: > >>> This is of course missing here: > >>> > >>> 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. >=20 > Ah, I missed this remark. >=20 > Then you could add qemu_bh_cancel at the end of the BH handler. No, because a worker thread could be completing a work item just as we leave the BH handler. Then the BH would be cancelled and the work item completion would never get executed (until the next work item completes). This is why I needed the atomic completion_token. That way I could check whether more requests completed while we were in the BH handler. Stefan --CUfgB8w4ZwR/yMy5 Content-Type: application/pgp-signature -----BEGIN PGP SIGNATURE----- Version: GnuPG v1 iQEcBAEBAgAGBQJTx8gMAAoJEJykq7OBq3PI8gsH/3yR4ojJQz4T7Og9AdeBOdN0 +tl+DJqpeARvDpwrcZRCp0kyXKdaaBTDMHujjRT6Cwy2MP+ORB2XmqOoD0gmxFWo fS5p7E2vlcPDkrN3R1TdPHqvewqLK2WFJiBL5+w+41AyrPk/mpC+j/zGMdrNUbuI 71zM7kFeR0ZxGuzDSQvQuR7AKUTbIeJQO5ND0dsLPRBrivr14xQZC9xtCcToB2MZ hT9fk9UCMXPR2CaOVmjCNtJH2lgo96IAxC3tEn5CzryVpirgWTJFch0X9RsGKdDZ tq/eJ7mzUkq3qpQ3K2IdzjRtjCHWsJDCS/wNWijPLULO8B1QO3BqW2p9UZBiuVM= =HH+3 -----END PGP SIGNATURE----- --CUfgB8w4ZwR/yMy5--