From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([2001:4830:134:3::10]:48704) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Ycbb1-0004TU-Ow for qemu-devel@nongnu.org; Mon, 30 Mar 2015 11:27:27 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1Ycbaw-0001kh-IQ for qemu-devel@nongnu.org; Mon, 30 Mar 2015 11:27:23 -0400 Date: Mon, 30 Mar 2015 16:27:13 +0100 From: Stefan Hajnoczi Message-ID: <20150330152713.GQ25181@stefanha-thinkpad.redhat.com> References: <1427524638-28157-1-git-send-email-pbonzini@redhat.com> MIME-Version: 1.0 Content-Type: multipart/signed; micalg=pgp-sha1; protocol="application/pgp-signature"; boundary="9+VnUxDxRuy97YQ+" Content-Disposition: inline In-Reply-To: <1427524638-28157-1-git-send-email-pbonzini@redhat.com> Subject: Re: [Qemu-devel] [PATCH] block: avoid unnecessary bottom halves List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: Paolo Bonzini Cc: qemu-devel@nongnu.org, qemu-block@nongnu.org --9+VnUxDxRuy97YQ+ Content-Type: text/plain; charset=us-ascii Content-Disposition: inline Content-Transfer-Encoding: quoted-printable On Sat, Mar 28, 2015 at 07:37:18AM +0100, Paolo Bonzini wrote: > bdrv_aio_* APIs can use coroutines to achieve asynchronicity. However, > the coroutine may terminate without having yielded back to the caller > (for example because of something that invokes a nested event loop, > or because the coroutine is doing nothing at all). In this case, > the bdrv_aio_* API must delay the completion to the next iteration > of the main loop, because bdrv_aio_* will never invoke the callback > before returning. >=20 > This can be done with a bottom half, and indeed bdrv_aio_* is always > using one for simplicity. It is possible to gain some performance > (~3%) by avoiding this in the common case. A new field in the > BlockAIOCBCoroutine struct is set to true until the first time the > corotine has yielded to its creator, and completion goes through a > new function bdrv_co_complete. If the flag is false, bdrv_co_complete > invokes the callback immediately. If it is true, the caller will > notice that the coroutine has completed and schedule the bottom > half itself. >=20 > Signed-off-by: Paolo Bonzini > --- > block.c | 43 ++++++++++++++++++++++++++++++++++--------- > 1 file changed, 34 insertions(+), 9 deletions(-) Reviewed-by: Stefan Hajnoczi --9+VnUxDxRuy97YQ+ Content-Type: application/pgp-signature -----BEGIN PGP SIGNATURE----- Version: GnuPG v1 iQEcBAEBAgAGBQJVGWtRAAoJEJykq7OBq3PIuLwH/RSsa/58MzYaLNpAOcXKBOod ikewk0Xr8CM0KPgFBWG0bueVfkx52tLq40nM1bt2meIgdODgb7o2rCBkku2b0eGo QjWtV9iXJBu1uxPlBiL1fQTP6bBFvPeff+8wPEKOH06MxkWNa4AKh8Bh0koWDBIC uOkMQilrx3AN1rzqsPSnCM/XZqQjm9ls6xZL4HMNi0W8I/99p7J0isTSOCiI8nBA lDocN8cd9QglBH/8OBVPs4pgrU61kCj6p343l/HJ1UFj3lNhzc3HUs0RVaVx9rfA 4DG+RIAYyw6DlSn44Dv7LXH48d+Bg3NdfBEmV5Putyz82nI1jFN1PmvQrz1PGak= =B4AQ -----END PGP SIGNATURE----- --9+VnUxDxRuy97YQ+--