提交 0e438cdc 编写于 作者: K Kevin Wolf

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: NKevin Wolf <kwolf@redhat.com>
Reviewed-by: NPaolo Bonzini <pbonzini@redhat.com>
Reviewed-by: NStefan Hajnoczi <stefanha@redhat.com>
上级 8b2bd093
......@@ -143,6 +143,7 @@ bool qemu_co_queue_empty(CoQueue *queue);
*/
typedef struct CoMutex {
bool locked;
Coroutine *holder;
CoQueue queue;
} CoMutex;
......
......@@ -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);
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册