aboutsummaryrefslogtreecommitdiff
path: root/hw/block
diff options
context:
space:
mode:
authorPaul Durrant <paul.durrant@citrix.com>2019-04-08 16:16:17 +0100
committerAnthony PERARD <anthony.perard@citrix.com>2019-06-24 10:42:29 +0100
commit345f42b4be9f9975ff3f7f3e95acae4f67c74f89 (patch)
treee9c8d791310f56d9e36be4851d9b84a870d62375 /hw/block
parent83361a8a1f932cfac8ae4a5b86e935ad6ab1c528 (diff)
downloadqemu-345f42b4be9f9975ff3f7f3e95acae4f67c74f89.zip
qemu-345f42b4be9f9975ff3f7f3e95acae4f67c74f89.tar.gz
qemu-345f42b4be9f9975ff3f7f3e95acae4f67c74f89.tar.bz2
xen-bus / xen-block: add support for event channel polling
This patch introduces a poll callback for event channel fd-s and uses this to invoke the channel callback function. To properly support polling, it is necessary for the event channel callback function to return a boolean saying whether it has done any useful work or not. Thus xen_block_dataplane_event() is modified to directly invoke xen_block_handle_requests() and the latter only returns true if it actually processes any requests. This also means that the call to qemu_bh_schedule() is moved into xen_block_complete_aio(), which is more intuitive since the only reason for doing a deferred poll of the shared ring should be because there were previously insufficient resources to fully complete a previous poll. Signed-off-by: Paul Durrant <paul.durrant@citrix.com> Reviewed-by: Anthony PERARD <anthony.perard@citrix.com> Message-Id: <20190408151617.13025-4-paul.durrant@citrix.com> Signed-off-by: Anthony PERARD <anthony.perard@citrix.com>
Diffstat (limited to 'hw/block')
-rw-r--r--hw/block/dataplane/xen-block.c17
1 files changed, 9 insertions, 8 deletions
diff --git a/hw/block/dataplane/xen-block.c b/hw/block/dataplane/xen-block.c
index aadca75..0f200c5 100644
--- a/hw/block/dataplane/xen-block.c
+++ b/hw/block/dataplane/xen-block.c
@@ -318,7 +318,9 @@ static void xen_block_complete_aio(void *opaque, int ret)
}
xen_block_release_request(request);
- qemu_bh_schedule(dataplane->bh);
+ if (dataplane->more_work) {
+ qemu_bh_schedule(dataplane->bh);
+ }
done:
aio_context_release(dataplane->ctx);
@@ -515,12 +517,13 @@ static int xen_block_get_request(XenBlockDataPlane *dataplane,
*/
#define IO_PLUG_THRESHOLD 1
-static void xen_block_handle_requests(XenBlockDataPlane *dataplane)
+static bool xen_block_handle_requests(XenBlockDataPlane *dataplane)
{
RING_IDX rc, rp;
XenBlockRequest *request;
int inflight_atstart = dataplane->requests_inflight;
int batched = 0;
+ bool done_something = false;
dataplane->more_work = 0;
@@ -552,6 +555,7 @@ static void xen_block_handle_requests(XenBlockDataPlane *dataplane)
}
xen_block_get_request(dataplane, request, rc);
dataplane->rings.common.req_cons = ++rc;
+ done_something = true;
/* parse them */
if (xen_block_parse_request(request) != 0) {
@@ -603,10 +607,7 @@ static void xen_block_handle_requests(XenBlockDataPlane *dataplane)
blk_io_unplug(dataplane->blk);
}
- if (dataplane->more_work &&
- dataplane->requests_inflight < dataplane->max_requests) {
- qemu_bh_schedule(dataplane->bh);
- }
+ return done_something;
}
static void xen_block_dataplane_bh(void *opaque)
@@ -618,11 +619,11 @@ static void xen_block_dataplane_bh(void *opaque)
aio_context_release(dataplane->ctx);
}
-static void xen_block_dataplane_event(void *opaque)
+static bool xen_block_dataplane_event(void *opaque)
{
XenBlockDataPlane *dataplane = opaque;
- qemu_bh_schedule(dataplane->bh);
+ return xen_block_handle_requests(dataplane);
}
XenBlockDataPlane *xen_block_dataplane_create(XenDevice *xendev,