qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
From: Kevin Wolf <kwolf@redhat.com>
To: qemu-block@nongnu.org
Cc: kwolf@redhat.com, hreitz@redhat.com, eesposit@redhat.com,
	pbonzini@redhat.com, vsementsov@yandex-team.ru,
	qemu-devel@nongnu.org
Subject: [PATCH 04/18] async: Register/unregister aiocontext in graph lock list
Date: Wed,  7 Dec 2022 14:18:24 +0100	[thread overview]
Message-ID: <20221207131838.239125-5-kwolf@redhat.com> (raw)
In-Reply-To: <20221207131838.239125-1-kwolf@redhat.com>

From: Emanuele Giuseppe Esposito <eesposit@redhat.com>

Add/remove the AioContext in aio_context_list in graph-lock.c when it is
created/destroyed. This allows using the graph locking operations from
this AioContext.

In order to allow linking util/async.c with binaries that don't include
the block layer, introduce stubs for (un)register_aiocontext().

Signed-off-by: Emanuele Giuseppe Esposito <eesposit@redhat.com>
Signed-off-by: Kevin Wolf <kwolf@redhat.com>
---
 stubs/graph-lock.c | 10 ++++++++++
 util/async.c       |  4 ++++
 stubs/meson.build  |  1 +
 3 files changed, 15 insertions(+)
 create mode 100644 stubs/graph-lock.c

diff --git a/stubs/graph-lock.c b/stubs/graph-lock.c
new file mode 100644
index 0000000000..177aa0a8ba
--- /dev/null
+++ b/stubs/graph-lock.c
@@ -0,0 +1,10 @@
+#include "qemu/osdep.h"
+#include "block/graph-lock.h"
+
+void register_aiocontext(AioContext *ctx)
+{
+}
+
+void unregister_aiocontext(AioContext *ctx)
+{
+}
diff --git a/util/async.c b/util/async.c
index 63434ddae4..14d63b3091 100644
--- a/util/async.c
+++ b/util/async.c
@@ -27,6 +27,7 @@
 #include "qapi/error.h"
 #include "block/aio.h"
 #include "block/thread-pool.h"
+#include "block/graph-lock.h"
 #include "qemu/main-loop.h"
 #include "qemu/atomic.h"
 #include "qemu/rcu_queue.h"
@@ -376,6 +377,7 @@ aio_ctx_finalize(GSource     *source)
     qemu_rec_mutex_destroy(&ctx->lock);
     qemu_lockcnt_destroy(&ctx->list_lock);
     timerlistgroup_deinit(&ctx->tlg);
+    unregister_aiocontext(ctx);
     aio_context_destroy(ctx);
 }
 
@@ -574,6 +576,8 @@ AioContext *aio_context_new(Error **errp)
     ctx->thread_pool_min = 0;
     ctx->thread_pool_max = THREAD_POOL_MAX_THREADS_DEFAULT;
 
+    register_aiocontext(ctx);
+
     return ctx;
 fail:
     g_source_destroy(&ctx->source);
diff --git a/stubs/meson.build b/stubs/meson.build
index c96a74f095..981585cbdf 100644
--- a/stubs/meson.build
+++ b/stubs/meson.build
@@ -13,6 +13,7 @@ stub_ss.add(files('error-printf.c'))
 stub_ss.add(files('fdset.c'))
 stub_ss.add(files('gdbstub.c'))
 stub_ss.add(files('get-vm-name.c'))
+stub_ss.add(files('graph-lock.c'))
 if linux_io_uring.found()
   stub_ss.add(files('io_uring.c'))
 endif
-- 
2.38.1



  parent reply	other threads:[~2022-12-07 13:22 UTC|newest]

Thread overview: 22+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-12-07 13:18 [PATCH 00/18] block: Introduce a block graph rwlock Kevin Wolf
2022-12-07 13:18 ` [PATCH 01/18] block: Factor out bdrv_drain_all_begin_nopoll() Kevin Wolf
2022-12-07 13:18 ` [PATCH 02/18] graph-lock: Introduce a lock to protect block graph operations Kevin Wolf
2022-12-07 13:18 ` [PATCH 03/18] graph-lock: Implement guard macros Kevin Wolf
2022-12-07 13:18 ` Kevin Wolf [this message]
2022-12-07 13:18 ` [PATCH 05/18] Import clang-tsa.h Kevin Wolf
2022-12-07 13:18 ` [PATCH 06/18] clang-tsa: Add TSA_ASSERT() macro Kevin Wolf
2022-12-07 13:18 ` [PATCH 07/18] clang-tsa: Add macros for shared locks Kevin Wolf
2022-12-07 13:18 ` [PATCH 08/18] configure: Enable -Wthread-safety if present Kevin Wolf
2022-12-07 13:18 ` [PATCH 09/18] test-bdrv-drain: Fix incorrrect drain assumptions Kevin Wolf
2022-12-07 13:18 ` [PATCH 10/18] block: Fix locking in external_snapshot_prepare() Kevin Wolf
2022-12-07 13:18 ` [PATCH 11/18] block: wrlock in bdrv_replace_child_noperm Kevin Wolf
2022-12-07 13:18 ` [PATCH 12/18] block: remove unnecessary assert_bdrv_graph_writable() Kevin Wolf
2022-12-07 13:18 ` [PATCH 13/18] block: assert that graph read and writes are performed correctly Kevin Wolf
2022-12-07 13:18 ` [PATCH 14/18] graph-lock: TSA annotations for lock/unlock functions Kevin Wolf
2022-12-07 13:18 ` [PATCH 15/18] Mark assert_bdrv_graph_readable/writable() GRAPH_RD/WRLOCK Kevin Wolf
2022-12-07 13:18 ` [PATCH 16/18] block-coroutine-wrapper.py: introduce annotations that take the graph rdlock Kevin Wolf
2022-12-07 13:18 ` [PATCH 17/18] block: use co_wrapper_mixed_bdrv_rdlock in functions taking the rdlock Kevin Wolf
2022-12-07 13:18 ` [PATCH 18/18] block: GRAPH_RDLOCK for functions only called by co_wrappers Kevin Wolf
2022-12-07 14:12 ` [PATCH 00/18] block: Introduce a block graph rwlock Emanuele Giuseppe Esposito
2022-12-07 16:08   ` Kevin Wolf
2022-12-12 17:14   ` Kevin Wolf

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20221207131838.239125-5-kwolf@redhat.com \
    --to=kwolf@redhat.com \
    --cc=eesposit@redhat.com \
    --cc=hreitz@redhat.com \
    --cc=pbonzini@redhat.com \
    --cc=qemu-block@nongnu.org \
    --cc=qemu-devel@nongnu.org \
    --cc=vsementsov@yandex-team.ru \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).