]> git.proxmox.com Git - mirror_qemu.git/commit - include/block/aio.h
AioContext: speed up aio_notify
authorPaolo Bonzini <pbonzini@redhat.com>
Mon, 7 Jul 2014 13:18:04 +0000 (15:18 +0200)
committerKevin Wolf <kwolf@redhat.com>
Wed, 9 Jul 2014 13:50:11 +0000 (15:50 +0200)
commit0ceb849bd336a5f9b6e1ed56d45cf5773d251ad8
tree970ee4f04a48eba0894602d28d2f70d23aeb532a
parentef508f427b348c7f0ef2bfe7c080fe5fcaee9f6b
AioContext: speed up aio_notify

In many cases, the call to event_notifier_set in aio_notify is unnecessary.
In particular, if we are executing aio_dispatch, or if aio_poll is not
blocking, we know that we will soon get to the next loop iteration (if
necessary); the thread that hosts the AioContext's event loop does not
need any nudging.

The patch includes a Promela formal model that shows that this really
works and does not need any further complication such as generation
counts.  It needs a memory barrier though.

The generation counts are not needed because any change to
ctx->dispatching after the memory barrier is okay for aio_notify.
If it changes from zero to one, it is the right thing to skip
event_notifier_set.  If it changes from one to zero, the
event_notifier_set is unnecessary but harmless.

Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
Signed-off-by: Kevin Wolf <kwolf@redhat.com>
aio-posix.c
async.c
docs/aio_notify.promela [new file with mode: 0644]
include/block/aio.h