[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Qemu-devel] [PATCH 27/40] aio: document locking
From: |
Paolo Bonzini |
Subject: |
[Qemu-devel] [PATCH 27/40] aio: document locking |
Date: |
Tue, 24 Nov 2015 19:01:18 +0100 |
Signed-off-by: Paolo Bonzini <address@hidden>
---
docs/multiple-iothreads.txt | 5 ++---
include/block/aio.h | 24 +++++++++++-------------
2 files changed, 13 insertions(+), 16 deletions(-)
diff --git a/docs/multiple-iothreads.txt b/docs/multiple-iothreads.txt
index 723cc7e..4197f62 100644
--- a/docs/multiple-iothreads.txt
+++ b/docs/multiple-iothreads.txt
@@ -84,9 +84,8 @@ How to synchronize with an IOThread
AioContext is not thread-safe so some rules must be followed when using file
descriptors, event notifiers, timers, or BHs across threads:
-1. AioContext functions can be called safely from file descriptor, event
-notifier, timer, or BH callbacks invoked by the AioContext. No locking is
-necessary.
+1. AioContext functions can always be called safely. They handle their
+own locking internally.
2. Other threads wishing to access the AioContext must use
aio_context_acquire()/aio_context_release() for mutual exclusion. Once the
diff --git a/include/block/aio.h b/include/block/aio.h
index 26aa658..21044af 100644
--- a/include/block/aio.h
+++ b/include/block/aio.h
@@ -50,18 +50,12 @@ typedef void IOHandler(void *opaque);
struct AioContext {
GSource source;
- /* Protects all fields from multi-threaded access */
+ /* Used by AioContext users to protect from multi-threaded access. */
QemuRecMutex lock;
- /* The list of registered AIO handlers */
+ /* The list of registered AIO handlers. Protected by ctx->list_lock. */
QLIST_HEAD(, AioHandler) aio_handlers;
- /* This is a simple lock used to protect the aio_handlers list.
- * Specifically, it's used to ensure that no callbacks are removed while
- * we're walking and dispatching callbacks.
- */
- int walking_handlers;
-
/* Used to avoid unnecessary event_notifier_set calls in aio_notify;
* accessed with atomic primitives. If this field is 0, everything
* (file descriptors, bottom halves, timers) will be re-evaluated
@@ -87,9 +81,9 @@ struct AioContext {
*/
uint32_t notify_me;
- /* A lock to protect between bh's adders and deleter, and to ensure
- * that no callbacks are removed while we're walking and dispatching
- * them.
+ /* A lock to protect between QEMUBH and AioHandler adders and deleter,
+ * and to ensure that no callbacks are removed while we're walking and
+ * dispatching them.
*/
QemuLockCnt list_lock;
@@ -111,10 +105,14 @@ struct AioContext {
bool notified;
EventNotifier notifier;
- /* Thread pool for performing work and receiving completion callbacks */
+ /* Thread pool for performing work and receiving completion callbacks.
+ * Has its own locking.
+ */
struct ThreadPool *thread_pool;
- /* TimerLists for calling timers - one per clock type */
+ /* TimerLists for calling timers - one per clock type. Has its own
+ * locking.
+ */
QEMUTimerListGroup tlg;
int external_disable_cnt;
--
1.8.3.1
- [Qemu-devel] [PATCH 11/40] virtio: add AioContext-specific function for host notifiers, (continued)
- [Qemu-devel] [PATCH 11/40] virtio: add AioContext-specific function for host notifiers, Paolo Bonzini, 2015/11/24
- [Qemu-devel] [PATCH 14/40] virtio-blk: do not use vring in dataplane, Paolo Bonzini, 2015/11/24
- [Qemu-devel] [PATCH 15/40] virtio-scsi: do not use vring in dataplane, Paolo Bonzini, 2015/11/24
- [Qemu-devel] [PATCH 16/40] vring: remove, Paolo Bonzini, 2015/11/24
- [Qemu-devel] [PATCH 20/40] aio: rename bh_lock to list_lock, Paolo Bonzini, 2015/11/24
- [Qemu-devel] [PATCH 22/40] aio: make ctx->list_lock a QemuLockCnt, subsuming ctx->walking_bh, Paolo Bonzini, 2015/11/24
- [Qemu-devel] [PATCH 19/40] aio: convert from RFifoLock to QemuRecMutex, Paolo Bonzini, 2015/11/24
- [Qemu-devel] [PATCH 17/40] iothread: release AioContext around aio_poll, Paolo Bonzini, 2015/11/24
- [Qemu-devel] [PATCH 18/40] qemu-thread: introduce QemuRecMutex, Paolo Bonzini, 2015/11/24
- [Qemu-devel] [PATCH 24/40] aio: tweak walking in dispatch phase, Paolo Bonzini, 2015/11/24
- [Qemu-devel] [PATCH 27/40] aio: document locking,
Paolo Bonzini <=
- [Qemu-devel] [PATCH 23/40] qemu-thread: optimize QemuLockCnt with futexes on Linux, Paolo Bonzini, 2015/11/24
- [Qemu-devel] [PATCH 21/40] qemu-thread: introduce QemuLockCnt, Paolo Bonzini, 2015/11/24
- [Qemu-devel] [PATCH 26/40] aio-win32: remove walking_handlers, protecting AioHandler list with list_lock, Paolo Bonzini, 2015/11/24
- [Qemu-devel] [PATCH 25/40] aio-posix: remove walking_handlers, protecting AioHandler list with list_lock, Paolo Bonzini, 2015/11/24
- [Qemu-devel] [PATCH 29/40] quorum: use atomics for rewrite_count, Paolo Bonzini, 2015/11/24
- [Qemu-devel] [PATCH 30/40] quorum: split quorum_fifo_aio_cb from quorum_aio_cb, Paolo Bonzini, 2015/11/24
- [Qemu-devel] [PATCH 28/40] aio: push aio_context_acquire/release down to dispatching, Paolo Bonzini, 2015/11/24
- [Qemu-devel] [PATCH 31/40] qed: introduce qed_aio_start_io and qed_aio_next_io_cb, Paolo Bonzini, 2015/11/24
- [Qemu-devel] [PATCH 34/40] block: explicitly acquire aiocontext in timers that need it, Paolo Bonzini, 2015/11/24
- [Qemu-devel] [PATCH 33/40] block: explicitly acquire aiocontext in bottom halves that need it, Paolo Bonzini, 2015/11/24