"Rao, Lei" <lei....@intel.com> wrote: > From: "Rao, Lei" <lei....@intel.com> > > This patch fixed as follows: > Thread 1 (Thread 0x7f34ee738d80 (LWP 11212)): > #0 __pthread_clockjoin_ex (threadid=139847152957184, > thread_return=0x7f30b1febf30, clockid=<optimized out>, abstime=<optimized > out>, block=<optimized out>) at pthread_join_common.c:145 > #1 0x0000563401998e36 in qemu_thread_join (thread=0x563402d66610) at > util/qemu-thread-posix.c:587 > #2 0x00005634017a79fa in process_incoming_migration_co (opaque=0x0) at > migration/migration.c:502 > #3 0x00005634019b59c9 in coroutine_trampoline (i0=63395504, i1=22068) at > util/coroutine-ucontext.c:115 > #4 0x00007f34ef860660 in ?? () at > ../sysdeps/unix/sysv/linux/x86_64/__start_context.S:91 from > /lib/x86_64-linux-gnu/libc.so.6 > #5 0x00007f30b21ee730 in ?? () > #6 0x0000000000000000 in ?? () > > Thread 13 (Thread 0x7f30b3dff700 (LWP 11747)): > #0 __lll_lock_wait (futex=futex@entry=0x56340218ffa0 > <qemu_global_mutex>, private=0) at lowlevellock.c:52 > #1 0x00007f34efa000a3 in _GI__pthread_mutex_lock (mutex=0x56340218ffa0 > <qemu_global_mutex>) at ../nptl/pthread_mutex_lock.c:80 > #2 0x0000563401997f99 in qemu_mutex_lock_impl (mutex=0x56340218ffa0 > <qemu_global_mutex>, file=0x563401b7a80e "migration/colo.c", line=806) at > util/qemu-thread-posix.c:78 > #3 0x0000563401407144 in qemu_mutex_lock_iothread_impl > (file=0x563401b7a80e "migration/colo.c", line=806) at > /home/workspace/colo-qemu/cpus.c:1899 > #4 0x00005634017ba8e8 in colo_process_incoming_thread > (opaque=0x563402d664c0) at migration/colo.c:806 > #5 0x0000563401998b72 in qemu_thread_start (args=0x5634039f8370) at > util/qemu-thread-posix.c:519 > #6 0x00007f34ef9fd609 in start_thread (arg=<optimized out>) at > pthread_create.c:477 > #7 0x00007f34ef924293 in clone () at > ../sysdeps/unix/sysv/linux/x86_64/clone.S:95 > > The QEMU main thread is holding the lock: > (gdb) p qemu_global_mutex > $1 = {lock = {_data = {lock = 2, __count = 0, __owner = 11212, __nusers = > 9, __kind = 0, __spins = 0, __elision = 0, __list = {_prev = 0x0, __next = > 0x0}}, > __size = "\002\000\000\000\000\000\000\000\314+\000\000\t", '\000' > <repeats 26 times>, __align = 2}, file = 0x563401c07e4b "util/main-loop.c", > line = 240, > initialized = true} > > From the call trace, we can see it is a deadlock bug. and the QEMU main > thread holds the global mutex to wait until the COLO thread ends. and the > colo thread > wants to acquire the global mutex, which will cause a deadlock. So, we should > release the qemu_global_mutex before waiting colo thread ends. > > Signed-off-by: Lei Rao <lei....@intel.com> > Reviewed-by: Li Zhijian <lizhij...@cn.fujitsu.com>
Reviewed-by: Juan Quintela <quint...@redhat.com> queued.