aboutsummaryrefslogtreecommitdiff
path: root/util
diff options
context:
space:
mode:
authorKevin Wolf <kwolf@redhat.com>2016-08-11 17:45:06 +0200
committerKevin Wolf <kwolf@redhat.com>2016-09-05 19:06:48 +0200
commit0e438cdc932a785de72166af4641aafa103a6670 (patch)
tree344e3bc5fde4623595a0ea77a1c9884bc8b9ef1b /util
parent8b2bd09338ae44e35a46e324cda566dbf17fc21c (diff)
downloadqemu-arm-0e438cdc932a785de72166af4641aafa103a6670.tar.gz
coroutine: Let CoMutex remember who holds it
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 <kwolf@redhat.com> Reviewed-by: Paolo Bonzini <pbonzini@redhat.com> Reviewed-by: Stefan Hajnoczi <stefanha@redhat.com>
Diffstat (limited to 'util')
-rw-r--r--util/qemu-coroutine-lock.c3
1 files changed, 3 insertions, 0 deletions
diff --git a/util/qemu-coroutine-lock.c b/util/qemu-coroutine-lock.c
index 22aa9abb30..f30ee8184d 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);