]> Git Repo - qemu.git/commit
block: avoid unnecessary bottom halves
authorPaolo Bonzini <[email protected]>
Sat, 28 Mar 2015 06:37:18 +0000 (07:37 +0100)
committerKevin Wolf <[email protected]>
Tue, 28 Apr 2015 13:36:09 +0000 (15:36 +0200)
commit0b5a24454fc551f0294fe93821e8c643214a55f5
tree3c4e764314d8f157a31ebc4903f04161c7a44fb5
parenta7282330c01364ef00260749bc6a37c7f16ec047
block: avoid unnecessary bottom halves

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.

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.

Signed-off-by: Paolo Bonzini <[email protected]>
Reviewed-by: Stefan Hajnoczi <[email protected]>
Message-id: 1427524638[email protected]
Signed-off-by: Stefan Hajnoczi <[email protected]>
Signed-off-by: Kevin Wolf <[email protected]>
block.c
This page took 0.026575 seconds and 4 git commands to generate.