summaryrefslogtreecommitdiff
path: root/async.c
diff options
context:
space:
mode:
authorPaolo Bonzini <pbonzini@redhat.com>2017-01-12 19:08:00 +0100
committerStefan Hajnoczi <stefanha@redhat.com>2017-01-16 13:25:18 +0000
commit7d506c90afa47facdb993bc19c15863eef584f1d (patch)
tree351e0ea4b050c1a6b829c302e2e553f2eb4d7231 /async.c
parent7c690fd1931f0908b18f7034b5d71d7b27ca59ef (diff)
downloadqemu-7d506c90afa47facdb993bc19c15863eef584f1d.tar.gz
async: optimize aio_bh_poll
Avoid entering the slow path of qemu_lockcnt_dec_and_lock if no bottom half has to be deleted. Reviewed-by: Stefan Hajnoczi <stefanha@redhat.com> Signed-off-by: Paolo Bonzini <pbonzini@redhat.com> Reviewed-by: Fam Zheng <famz@redhat.com> Message-id: 20170112180800.21085-11-pbonzini@redhat.com Signed-off-by: Stefan Hajnoczi <stefanha@redhat.com>
Diffstat (limited to 'async.c')
-rw-r--r--async.c10
1 files changed, 9 insertions, 1 deletions
diff --git a/async.c b/async.c
index 2305e11f26..0d218ab0e0 100644
--- a/async.c
+++ b/async.c
@@ -92,6 +92,7 @@ int aio_bh_poll(AioContext *ctx)
{
QEMUBH *bh, **bhp, *next;
int ret;
+ bool deleted = false;
qemu_lockcnt_inc(&ctx->list_lock);
@@ -112,9 +113,17 @@ int aio_bh_poll(AioContext *ctx)
bh->idle = 0;
aio_bh_call(bh);
}
+ if (bh->deleted) {
+ deleted = true;
+ }
}
/* remove deleted bhs */
+ if (!deleted) {
+ qemu_lockcnt_dec(&ctx->list_lock);
+ return ret;
+ }
+
if (qemu_lockcnt_dec_and_lock(&ctx->list_lock)) {
bhp = &ctx->first_bh;
while (*bhp) {
@@ -128,7 +137,6 @@ int aio_bh_poll(AioContext *ctx)
}
qemu_lockcnt_unlock(&ctx->list_lock);
}
-
return ret;
}