[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[PULL 07/50] util/async: replace __thread with QEMU TLS macros
From: |
Kevin Wolf |
Subject: |
[PULL 07/50] util/async: replace __thread with QEMU TLS macros |
Date: |
Fri, 4 Mar 2022 17:46:28 +0100 |
From: Stefan Hajnoczi <stefanha@redhat.com>
QEMU TLS macros must be used to make TLS variables safe with coroutines.
Signed-off-by: Stefan Hajnoczi <stefanha@redhat.com>
Message-Id: <20220222140150.27240-3-stefanha@redhat.com>
Signed-off-by: Kevin Wolf <kwolf@redhat.com>
---
util/async.c | 12 +++++++-----
1 file changed, 7 insertions(+), 5 deletions(-)
diff --git a/util/async.c b/util/async.c
index 08d25feef5..2ea1172f3e 100644
--- a/util/async.c
+++ b/util/async.c
@@ -32,6 +32,7 @@
#include "qemu/rcu_queue.h"
#include "block/raw-aio.h"
#include "qemu/coroutine_int.h"
+#include "qemu/coroutine-tls.h"
#include "trace.h"
/***********************************************************/
@@ -675,12 +676,13 @@ void aio_context_release(AioContext *ctx)
qemu_rec_mutex_unlock(&ctx->lock);
}
-static __thread AioContext *my_aiocontext;
+QEMU_DEFINE_STATIC_CO_TLS(AioContext *, my_aiocontext)
AioContext *qemu_get_current_aio_context(void)
{
- if (my_aiocontext) {
- return my_aiocontext;
+ AioContext *ctx = get_my_aiocontext();
+ if (ctx) {
+ return ctx;
}
if (qemu_mutex_iothread_locked()) {
/* Possibly in a vCPU thread. */
@@ -691,6 +693,6 @@ AioContext *qemu_get_current_aio_context(void)
void qemu_set_current_aio_context(AioContext *ctx)
{
- assert(!my_aiocontext);
- my_aiocontext = ctx;
+ assert(!get_my_aiocontext());
+ set_my_aiocontext(ctx);
}
--
2.35.1
- [PULL 05/50] block: move BQL logic of bdrv_co_invalidate_cache in bdrv_activate, (continued)
- [PULL 05/50] block: move BQL logic of bdrv_co_invalidate_cache in bdrv_activate, Kevin Wolf, 2022/03/04
- [PULL 04/50] block: rename bdrv_invalidate_cache_all, blk_invalidate_cache and test_sync_op_invalidate_cache, Kevin Wolf, 2022/03/04
- [PULL 06/50] tls: add macros for coroutine-safe TLS variables, Kevin Wolf, 2022/03/04
- [PULL 08/50] rcu: use coroutine TLS macros, Kevin Wolf, 2022/03/04
- [PULL 09/50] cpus: use coroutine TLS macros for iothread_locked, Kevin Wolf, 2022/03/04
- [PULL 11/50] qsd: Add pre-init argument parsing pass, Kevin Wolf, 2022/03/04
- [PULL 14/50] main-loop.h: introduce qemu_in_main_thread(), Kevin Wolf, 2022/03/04
- [PULL 15/50] main loop: macros to mark GS and I/O functions, Kevin Wolf, 2022/03/04
- [PULL 10/50] os-posix: Add os_set_daemonize(), Kevin Wolf, 2022/03/04
- [PULL 12/50] qsd: Add --daemonize, Kevin Wolf, 2022/03/04
- [PULL 07/50] util/async: replace __thread with QEMU TLS macros,
Kevin Wolf <=
- [PULL 13/50] iotests/185: Add post-READY quit tests, Kevin Wolf, 2022/03/04
- [PULL 21/50] block/block-backend.c: assertions for block-backend, Kevin Wolf, 2022/03/04
- Re: [PULL 21/50] block/block-backend.c: assertions for block-backend, Emanuele Giuseppe Esposito, 2022/03/16
[PULL 18/50] IO_CODE and IO_OR_GS_CODE for block I/O API, Kevin Wolf, 2022/03/04
[PULL 20/50] include/sysemu/block-backend: split header into I/O and global state (GS) API, Kevin Wolf, 2022/03/04