From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([2001:4830:134:3::10]:37414) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1X6dpP-0000Gk-Te for qemu-devel@nongnu.org; Mon, 14 Jul 2014 06:50:00 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1X6dpG-0007Fc-Os for qemu-devel@nongnu.org; Mon, 14 Jul 2014 06:49:51 -0400 Received: from mail-qg0-x22e.google.com ([2607:f8b0:400d:c04::22e]:44079) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1X6dpG-0007FQ-LJ for qemu-devel@nongnu.org; Mon, 14 Jul 2014 06:49:42 -0400 Received: by mail-qg0-f46.google.com with SMTP id z60so1768974qgd.33 for ; Mon, 14 Jul 2014 03:49:42 -0700 (PDT) Sender: Paolo Bonzini Message-ID: <53C3B5C2.7010001@redhat.com> Date: Mon, 14 Jul 2014 12:49:38 +0200 From: Paolo Bonzini MIME-Version: 1.0 References: <1405077612-7806-1-git-send-email-stefanha@redhat.com> <1405077612-7806-3-git-send-email-stefanha@redhat.com> <53C39685.2090400@redhat.com> In-Reply-To: <53C39685.2090400@redhat.com> Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit 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: Stefan Hajnoczi , qemu-devel@nongnu.org Cc: Christian Borntraeger 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); This is of course missing here: break; Paolo > > There is no change in logic, it's just that the goto is switched to a BH > representing a continuation. I am then not sure why > pool->completion_token is necessary?