]> git.proxmox.com Git - mirror_qemu.git/commit - util/async.c
async: always set ctx->notified in aio_notify()
authorStefan Hajnoczi <stefanha@redhat.com>
Thu, 6 Aug 2020 13:18:01 +0000 (14:18 +0100)
committerStefan Hajnoczi <stefanha@redhat.com>
Thu, 13 Aug 2020 12:32:59 +0000 (13:32 +0100)
commit601829f88e0eff8f54fa08b7a69b0774a9c259c8
tree7de8aa930014c903d1a973a0e08aef8895a5afc1
parentc13be5a1bfcd6cafdf20072c75eaf3e5af35f2e6
async: always set ctx->notified in aio_notify()

aio_notify() does not set ctx->notified when called with
ctx->aio_notify_me disabled. Therefore aio_notify_me needs to be enabled
during polling.

This is suboptimal since expensive event_notifier_set(&ctx->notifier)
and event_notifier_test_and_clear(&ctx->notifier) calls are required
when ctx->aio_notify_me is enabled.

Change aio_notify() so that aio->notified is always set, regardless of
ctx->aio_notify_me. This will make polling cheaper since
ctx->aio_notify_me can remain disabled. Move the
event_notifier_test_and_clear() to the fd handler function (which is now
no longer an empty function so "dummy" has been dropped from its name).

The next patch takes advantage of this by optimizing polling in
util/aio-posix.c.

Signed-off-by: Stefan Hajnoczi <stefanha@redhat.com>
Reviewed-by: Paolo Bonzini <pbonzini@redhat.com>
Reviewed-by: Philippe Mathieu-Daudé <philmd@redhat.com>
Message-id: 20200806131802.569478-3-stefanha@redhat.com

[Paolo Bonzini pointed out that the smp_wmb() in aio_notify_accept()
should be smp_wb() but the comment should be smp_wmb() instead of
smp_wb(). Fixed.
--Stefan]

Signed-off-by: Stefan Hajnoczi <stefanha@redhat.com>
util/async.c