Skip to content

Commit

Permalink
linux-aio: Cancel BH if not needed
Browse files Browse the repository at this point in the history
linux-aio uses a BH in order to make sure that the remaining completions
are processed even in nested event loops of completion callbacks in
order to avoid deadlocks.

There is no need, however, to have the BH overhead for the first call
into qemu_laio_completion_bh() or after all pending completions have
already been processed. Therefore, this patch calls directly into
qemu_laio_completion_bh() in qemu_laio_completion_cb() and cancels
the BH after qemu_laio_completion_bh() has processed all pending
completions.

Signed-off-by: Kevin Wolf <kwolf@redhat.com>
Reviewed-by: Paolo Bonzini <pbonzini@redhat.com>
  • Loading branch information
kevmw committed Jun 16, 2016
1 parent 23b0d9f commit ccb9dc1
Showing 1 changed file with 3 additions and 1 deletion.
4 changes: 3 additions & 1 deletion block/linux-aio.c
Expand Up @@ -149,14 +149,16 @@ static void qemu_laio_completion_bh(void *opaque)
if (!s->io_q.plugged && !QSIMPLEQ_EMPTY(&s->io_q.pending)) {
ioq_submit(s);
}

qemu_bh_cancel(s->completion_bh);
}

static void qemu_laio_completion_cb(EventNotifier *e)
{
LinuxAioState *s = container_of(e, LinuxAioState, e);

if (event_notifier_test_and_clear(&s->e)) {
qemu_bh_schedule(s->completion_bh);
qemu_laio_completion_bh(s);
}
}

Expand Down

0 comments on commit ccb9dc1

Please sign in to comment.