[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Qemu-block] [PULL 32/42] coroutine: Let CoMutex remember who holds it
From: |
Kevin Wolf |
Subject: |
[Qemu-block] [PULL 32/42] coroutine: Let CoMutex remember who holds it |
Date: |
Mon, 5 Sep 2016 20:13:44 +0200 |
In cases of deadlocks, knowing who holds a given CoMutex is really
helpful for debugging. Keeping the information around doesn't cost much
and allows us to add another assertion to keep the code correct, so
let's just add it.
Signed-off-by: Kevin Wolf <address@hidden>
Reviewed-by: Paolo Bonzini <address@hidden>
Reviewed-by: Stefan Hajnoczi <address@hidden>
---
include/qemu/coroutine.h | 1 +
util/qemu-coroutine-lock.c | 3 +++
2 files changed, 4 insertions(+)
diff --git a/include/qemu/coroutine.h b/include/qemu/coroutine.h
index ac8d4c9..29a2078 100644
--- a/include/qemu/coroutine.h
+++ b/include/qemu/coroutine.h
@@ -143,6 +143,7 @@ bool qemu_co_queue_empty(CoQueue *queue);
*/
typedef struct CoMutex {
bool locked;
+ Coroutine *holder;
CoQueue queue;
} CoMutex;
diff --git a/util/qemu-coroutine-lock.c b/util/qemu-coroutine-lock.c
index 22aa9ab..f30ee81 100644
--- a/util/qemu-coroutine-lock.c
+++ b/util/qemu-coroutine-lock.c
@@ -129,6 +129,7 @@ void coroutine_fn qemu_co_mutex_lock(CoMutex *mutex)
}
mutex->locked = true;
+ mutex->holder = self;
trace_qemu_co_mutex_lock_return(mutex, self);
}
@@ -140,9 +141,11 @@ void coroutine_fn qemu_co_mutex_unlock(CoMutex *mutex)
trace_qemu_co_mutex_unlock_entry(mutex, self);
assert(mutex->locked == true);
+ assert(mutex->holder == self);
assert(qemu_in_coroutine());
mutex->locked = false;
+ mutex->holder = NULL;
qemu_co_queue_next(&mutex->queue);
trace_qemu_co_mutex_unlock_return(mutex, self);
--
1.8.3.1
- [Qemu-block] [PULL 28/42] qemu-iotests: test backup compression in 055, (continued)
- [Qemu-block] [PULL 28/42] qemu-iotests: test backup compression in 055, Kevin Wolf, 2016/09/05
- [Qemu-block] [PULL 23/42] block/io: turn on dirty_bitmaps for the compressed writes, Kevin Wolf, 2016/09/05
- [Qemu-block] [PULL 24/42] block: simplify drive-backup, Kevin Wolf, 2016/09/05
- [Qemu-block] [PULL 25/42] block: simplify blockdev-backup, Kevin Wolf, 2016/09/05
- [Qemu-block] [PULL 29/42] qemu-iotests: add vmdk for test backup compression in 055, Kevin Wolf, 2016/09/05
- [Qemu-block] [PULL 26/42] drive-backup: added support for data compression, Kevin Wolf, 2016/09/05
- [Qemu-block] [PULL 27/42] blockdev-backup: added support for data compression, Kevin Wolf, 2016/09/05
- [Qemu-block] [PULL 30/42] test-coroutine: Fix coroutine pool corruption, Kevin Wolf, 2016/09/05
- [Qemu-block] [PULL 32/42] coroutine: Let CoMutex remember who holds it,
Kevin Wolf <=
- [Qemu-block] [PULL 31/42] qcow2: fix iovec size at qcow2_co_pwritev_compressed, Kevin Wolf, 2016/09/05
- [Qemu-block] [PULL 34/42] block jobs: Improve error message for missing job ID, Kevin Wolf, 2016/09/05
- [Qemu-block] [PULL 35/42] qemu-iotests: Log QMP traffic in debug mode, Kevin Wolf, 2016/09/05
- [Qemu-block] [PULL 36/42] block: Allow node name for 'qemu-io' HMP command, Kevin Wolf, 2016/09/05
- [Qemu-block] [PULL 38/42] coroutine: add a macro for the coroutine stack size, Kevin Wolf, 2016/09/05
- [Qemu-block] [PULL 37/42] oslib-posix: add helpers for stack alloc and free, Kevin Wolf, 2016/09/05
- [Qemu-block] [PULL 33/42] coroutine: Assert that no locks are held on termination, Kevin Wolf, 2016/09/05
- [Qemu-block] [PULL 40/42] coroutine-sigaltstack: use helper for allocating stack memory, Kevin Wolf, 2016/09/05
- [Qemu-block] [PULL 39/42] coroutine-ucontext: use helper for allocating stack memory, Kevin Wolf, 2016/09/05