thread-pool: add missing qemu_bh_cancel in completion function

commit 3c80ca15 fixed a deadlock scenarion with nested aio_poll invocations.

However, the rescheduling of the completion BH introcuded unnecessary spinning
in the main-loop. On very fast file backends this can even lead to the
"WARNING: I/O thread spun for 1000 iterations" message popping up.

Callgrind reports about 3-4% less instructions with this patch running
qemu-img bench on a ramdisk based VMDK file.

Fixes: 3c80ca158c
Cc: qemu-stable@nongnu.org
Signed-off-by: Peter Lieven <pl@kamp.de>
Signed-off-by: Kevin Wolf <kwolf@redhat.com>
(cherry picked from commit b7a745dc33)
* drop context dep on b9e413d
Signed-off-by: Michael Roth <mdroth@linux.vnet.ibm.com>
This commit is contained in:
Peter Lieven 2017-03-16 17:02:49 +01:00 committed by Michael Roth
parent 34e9c09d03
commit a3aeb9f09d
1 changed files with 7 additions and 0 deletions

View File

@ -185,6 +185,13 @@ restart:
qemu_bh_schedule(pool->completion_bh); qemu_bh_schedule(pool->completion_bh);
elem->common.cb(elem->common.opaque, elem->ret); elem->common.cb(elem->common.opaque, elem->ret);
/* We can safely cancel the completion_bh here regardless of someone
* else having scheduled it meanwhile because we reenter the
* completion function anyway (goto restart).
*/
qemu_bh_cancel(pool->completion_bh);
qemu_aio_unref(elem); qemu_aio_unref(elem);
goto restart; goto restart;
} else { } else {