From fcf5def1ab0f94ff120b7141c943b517d2ece83d Mon Sep 17 00:00:00 2001 From: Paolo Bonzini Date: Wed, 17 Dec 2014 16:09:58 +0100 Subject: block: mark AioContext as recursive AioContext can be accessed recursively, in fact that's what we do with aio_poll. Marking the GSource as recursive avoids that GLib blocks it and unblocks it around every call to aio_dispatch, which is a pretty expensive operation. Signed-off-by: Paolo Bonzini Signed-off-by: Kevin Wolf --- async.c | 1 + 1 file changed, 1 insertion(+) (limited to 'async.c') diff --git a/async.c b/async.c index 3939b79..572f239 100644 --- a/async.c +++ b/async.c @@ -300,6 +300,7 @@ AioContext *aio_context_new(Error **errp) error_setg_errno(errp, -ret, "Failed to initialize event notifier"); return NULL; } + g_source_set_can_recurse(&ctx->source, true); aio_set_event_notifier(ctx, &ctx->notifier, (EventNotifierHandler *) event_notifier_test_and_clear); -- cgit v1.1 From ee82310f8a6cc9ba9e8d1ac892f1a3cfc0debd8c Mon Sep 17 00:00:00 2001 From: Paolo Bonzini Date: Wed, 17 Dec 2014 16:10:00 +0100 Subject: block: replace g_new0 with g_new for bottom half allocation. This saves about 15% of the clock cycles spent on allocation. Using the slice allocator does not add a visible improvement; allocation is faster than malloc, while freeing seems to be slower. Signed-off-by: Paolo Bonzini Signed-off-by: Kevin Wolf --- async.c | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) (limited to 'async.c') diff --git a/async.c b/async.c index 572f239..2be88cc 100644 --- a/async.c +++ b/async.c @@ -44,10 +44,12 @@ struct QEMUBH { QEMUBH *aio_bh_new(AioContext *ctx, QEMUBHFunc *cb, void *opaque) { QEMUBH *bh; - bh = g_new0(QEMUBH, 1); - bh->ctx = ctx; - bh->cb = cb; - bh->opaque = opaque; + bh = g_new(QEMUBH, 1); + *bh = (QEMUBH){ + .ctx = ctx, + .cb = cb, + .opaque = opaque, + }; qemu_mutex_lock(&ctx->bh_lock); bh->next = ctx->first_bh; /* Make sure that the members are ready before putting bh into list */ -- cgit v1.1