From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([2001:4830:134:3::10]:33047) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1YajRo-0005Ft-Mn for qemu-devel@nongnu.org; Wed, 25 Mar 2015 07:26:09 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1YajRl-0006K8-Fa for qemu-devel@nongnu.org; Wed, 25 Mar 2015 07:26:08 -0400 Received: from mx1.redhat.com ([209.132.183.28]:57064) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1YajRl-0006K4-8V for qemu-devel@nongnu.org; Wed, 25 Mar 2015 07:26:05 -0400 Received: from int-mx11.intmail.prod.int.phx2.redhat.com (int-mx11.intmail.prod.int.phx2.redhat.com [10.5.11.24]) by mx1.redhat.com (8.14.4/8.14.4) with ESMTP id t2PBQ40p030335 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=FAIL) for ; Wed, 25 Mar 2015 07:26:04 -0400 Message-ID: <55129B46.2060003@redhat.com> Date: Wed, 25 Mar 2015 12:25:58 +0100 From: Paolo Bonzini MIME-Version: 1.0 References: <20150325083139.GB14724@ad.nay.redhat.com> In-Reply-To: <20150325083139.GB14724@ad.nay.redhat.com> Content-Type: text/plain; charset=windows-1252 Content-Transfer-Encoding: 7bit Subject: Re: [Qemu-devel] AioContext of block jobs List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: Fam Zheng , qemu-devel@nongnu.org Cc: stefanha@redhat.com On 25/03/2015 09:31, Fam Zheng wrote: > I was looking at block jobs' AioContext and realized that the block job > coroutines are actually started in main loop. > > I'm confused because 5a7e7a0bad17c96e03f55ed7019e2d7545e21a96 and friends in > the series [1] seem to move the coroutines to the BDS's iothreads, but it > didn't do that. > > (Although after the first block_job_yield or sleep, the coroutines ARE resumed > in the right AioContext.) > > Why is it safe to start the jobs from the main thread where QMP command is > handled? I see no guarantee that the jobs won't access BDS before first yield > but after releasing the AioContext. > > Is this a bug? It's okay because the coroutine is started while the main thread is holding the AioContext. So the first "stint" of the coroutine, until the first yield, is done in the main thread but still with the AioContext held. After the first yield, the main thread releases the AioContext, the dataplane thread gets it back and the coroutine is moved to the dataplane thread. Paolo