qemu with hax to log dma reads & writes jcs.org/2018/11/12/vfio

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: 3c80ca158c96ff902a30883a8933e755988948b1
Cc: qemu-stable@nongnu.org
Signed-off-by: Peter Lieven <pl@kamp.de>
Signed-off-by: Kevin Wolf <kwolf@redhat.com>

authored by

Peter Lieven and committed by
Kevin Wolf
b7a745dc 8cd1a3e4

+7
+7
util/thread-pool.c
··· 188 188 aio_context_release(pool->ctx); 189 189 elem->common.cb(elem->common.opaque, elem->ret); 190 190 aio_context_acquire(pool->ctx); 191 + 192 + /* We can safely cancel the completion_bh here regardless of someone 193 + * else having scheduled it meanwhile because we reenter the 194 + * completion function anyway (goto restart). 195 + */ 196 + qemu_bh_cancel(pool->completion_bh); 197 + 191 198 qemu_aio_unref(elem); 192 199 goto restart; 193 200 } else {