diff options
author | Peter Maydell <peter.maydell@linaro.org> | 2020-08-21 17:26:52 +0100 |
---|---|---|
committer | Peter Maydell <peter.maydell@linaro.org> | 2020-08-21 17:26:52 +0100 |
commit | f86d9a093dada588889bde5582c7ec320487c4b8 (patch) | |
tree | e317d643fa35c79d98791bb1bd7fcc7f410557b6 /util/async.c | |
parent | d6f83a72a7db94a3ede9f5cc4fb39f9c8e89f954 (diff) | |
parent | 44277bf914471962c9e88e09c859aae65ae109c4 (diff) |
Merge remote-tracking branch 'remotes/stefanha/tags/block-pull-request' into staging
Pull request
# gpg: Signature made Mon 17 Aug 2020 15:34:34 BST
# gpg: using RSA key 8695A8BFD3F97CDAAC35775A9CA4ABB381AB73C8
# gpg: Good signature from "Stefan Hajnoczi <stefanha@redhat.com>" [full]
# gpg: aka "Stefan Hajnoczi <stefanha@gmail.com>" [full]
# Primary key fingerprint: 8695 A8BF D3F9 7CDA AC35 775A 9CA4 ABB3 81AB 73C8
* remotes/stefanha/tags/block-pull-request:
aio-posix: keep aio_notify_me disabled during polling
async: always set ctx->notified in aio_notify()
async: rename event_notifier_dummy_cb/poll()
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
Diffstat (limited to 'util/async.c')
-rw-r--r-- | util/async.c | 36 |
1 files changed, 23 insertions, 13 deletions
diff --git a/util/async.c b/util/async.c index 1319eee3bc..4266745dee 100644 --- a/util/async.c +++ b/util/async.c @@ -419,25 +419,32 @@ LuringState *aio_get_linux_io_uring(AioContext *ctx) void aio_notify(AioContext *ctx) { - /* Write e.g. bh->scheduled before reading ctx->notify_me. Pairs + /* + * Write e.g. bh->flags before writing ctx->notified. Pairs with smp_mb in + * aio_notify_accept. + */ + smp_wmb(); + atomic_set(&ctx->notified, true); + + /* + * Write ctx->notified before reading ctx->notify_me. Pairs * with smp_mb in aio_ctx_prepare or aio_poll. */ smp_mb(); if (atomic_read(&ctx->notify_me)) { event_notifier_set(&ctx->notifier); - atomic_mb_set(&ctx->notified, true); } } void aio_notify_accept(AioContext *ctx) { - if (atomic_xchg(&ctx->notified, false) -#ifdef WIN32 - || true -#endif - ) { - event_notifier_test_and_clear(&ctx->notifier); - } + atomic_set(&ctx->notified, false); + + /* + * Write ctx->notified before reading e.g. bh->flags. Pairs with smp_wmb + * in aio_notify. + */ + smp_mb(); } static void aio_timerlist_notify(void *opaque, QEMUClockType type) @@ -445,12 +452,15 @@ static void aio_timerlist_notify(void *opaque, QEMUClockType type) aio_notify(opaque); } -static void event_notifier_dummy_cb(EventNotifier *e) +static void aio_context_notifier_cb(EventNotifier *e) { + AioContext *ctx = container_of(e, AioContext, notifier); + + event_notifier_test_and_clear(&ctx->notifier); } /* Returns true if aio_notify() was called (e.g. a BH was scheduled) */ -static bool event_notifier_poll(void *opaque) +static bool aio_context_notifier_poll(void *opaque) { EventNotifier *e = opaque; AioContext *ctx = container_of(e, AioContext, notifier); @@ -508,8 +518,8 @@ AioContext *aio_context_new(Error **errp) aio_set_event_notifier(ctx, &ctx->notifier, false, - event_notifier_dummy_cb, - event_notifier_poll); + aio_context_notifier_cb, + aio_context_notifier_poll); #ifdef CONFIG_LINUX_AIO ctx->linux_aio = NULL; #endif |