Replaces the pattern `atomic_store(atomic_load() <op> something)` pattern with its direct atomic function.
Signed-off-by: Wolfgang Bumiller <w.bumil...@proxmox.com> --- Note: these previously used RELEASE ordering for the store and `relaxed` ordering for the reads, while the replacement uses SEQ_CST, as there are no other wrappers around yet. Should we add `qatomic_fetch_{sub,and}_release` variants? util/aio-posix.c | 3 +-- util/aio-win32.c | 3 +-- util/async.c | 2 +- 3 files changed, 3 insertions(+), 5 deletions(-) diff --git a/util/aio-posix.c b/util/aio-posix.c index 266c9dd35f..9cf7fed8fc 100644 --- a/util/aio-posix.c +++ b/util/aio-posix.c @@ -672,8 +672,7 @@ bool aio_poll(AioContext *ctx, bool blocking) if (use_notify_me) { /* Finish the poll before clearing the flag. */ - qatomic_store_release(&ctx->notify_me, - qatomic_read(&ctx->notify_me) - 2); + qatomic_fetch_sub(&ctx->notify_me, 2); } aio_notify_accept(ctx); diff --git a/util/aio-win32.c b/util/aio-win32.c index d144f9391f..ff6d1ebf97 100644 --- a/util/aio-win32.c +++ b/util/aio-win32.c @@ -387,8 +387,7 @@ bool aio_poll(AioContext *ctx, bool blocking) ret = WaitForMultipleObjects(count, events, FALSE, timeout); if (blocking) { assert(first); - qatomic_store_release(&ctx->notify_me, - qatomic_read(&ctx->notify_me) - 2); + qatomic_fetch_sub(&ctx->notify_me, 2); aio_notify_accept(ctx); } diff --git a/util/async.c b/util/async.c index 0467890052..d17deeceea 100644 --- a/util/async.c +++ b/util/async.c @@ -330,7 +330,7 @@ aio_ctx_check(GSource *source) BHListSlice *s; /* Finish computing the timeout before clearing the flag. */ - qatomic_store_release(&ctx->notify_me, qatomic_read(&ctx->notify_me) & ~1); + qatomic_fetch_and(&ctx->notify_me, ~1); aio_notify_accept(ctx); QSLIST_FOREACH_RCU(bh, &ctx->bh_list, next) { -- 2.39.2