qemu-img hangs on rcu_call_ready_event logic in Aarch64 when converting images
Affects | Status | Importance | Assigned to | Milestone | |
---|---|---|---|---|---|
QEMU |
Fix Released
|
Undecided
|
Unassigned | ||
kunpeng920 |
Fix Released
|
Undecided
|
Unassigned | ||
Ubuntu-18.04 |
Fix Released
|
Undecided
|
Unassigned | ||
Ubuntu-19.10 |
Fix Released
|
Undecided
|
Unassigned | ||
Ubuntu-20.04 |
Fix Released
|
Undecided
|
Unassigned | ||
Upstream-kernel |
Invalid
|
Undecided
|
Unassigned | ||
qemu (Ubuntu) |
Fix Released
|
Medium
|
Unassigned | ||
Bionic |
Fix Released
|
Medium
|
Unassigned | ||
Eoan |
Fix Released
|
Medium
|
Unassigned | ||
Focal |
Fix Released
|
Medium
|
Unassigned |
Bug Description
SRU TEAM REVIEWER: This has already been SRUed for Focal, Eoan and Bionic. Unfortunately the Bionic SRU did not work and we had to reverse the change. Since then we had another update and now I'm retrying the SRU.
After discussing with @paelzer (and @dannf as a reviewer) extensively, Christian and I agreed that we should scope this SRU as Aarch64 only AND I was much, much more conservative in question of what is being changed in the AIO qemu code.
New code has been tested against the initial Test Case and the new one, regressed for Bionic. More information (about tests and discussion) can be found in the MR at ~rafaeldtinoco/
BIONIC REGRESSION BUG:
https:/
[Impact]
* QEMU locking primitives might face a race condition in QEMU Async I/O bottom halves scheduling. This leads to a dead lock making either QEMU or one of its tools to hang indefinitely.
[Test Case]
INITIAL
* qemu-img convert -f qcow2 -O qcow2 ./disk01.qcow2 ./output.qcow2
Hangs indefinitely approximately 30% of the runs in Aarch64.
[Regression Potential]
* This is a change to a core part of QEMU: The AIO scheduling. It works like a "kernel" scheduler, whereas kernel schedules OS tasks, the QEMU AIO code is responsible to schedule QEMU coroutines or event listeners callbacks.
* There was a long discussion upstream about primitives and Aarch64. After quite sometime Paolo released this patch and it solves the issue. Tested platforms were: amd64 and aarch64 based on his commit log.
* Christian suggests that this fix stay little longer in -proposed to make sure it won't cause any regressions.
* dannf suggests we also check for performance regressions; e.g. how long it takes to convert a cloud image on high-core systems.
BIONIC REGRESSED ISSUE
https:/
[Other Info]
* Original Description bellow:
Command:
qemu-img convert -f qcow2 -O qcow2 ./disk01.qcow2 ./output.qcow2
Hangs indefinitely approximately 30% of the runs.
----
Workaround:
qemu-img convert -m 1 -f qcow2 -O qcow2 ./disk01.qcow2 ./output.qcow2
Run "qemu-img convert" with "a single coroutine" to avoid this issue.
----
(gdb) thread 1
...
(gdb) bt
#0 0x0000ffffbf1ad81c in __GI_ppoll
#1 0x0000aaaaaabcf73c in ppoll
#2 qemu_poll_ns
#3 0x0000aaaaaabd0764 in os_host_
#4 main_loop_wait
...
(gdb) thread 2
...
(gdb) bt
#0 syscall ()
#1 0x0000aaaaaabd41cc in qemu_futex_wait
#2 qemu_event_wait (ev=ev@
#3 0x0000aaaaaabed05c in call_rcu_thread
#4 0x0000aaaaaabd34c8 in qemu_thread_start
#5 0x0000ffffbf25c880 in start_thread
#6 0x0000ffffbf1b6b9c in thread_start ()
(gdb) thread 3
...
(gdb) bt
#0 0x0000ffffbf11aa20 in __GI___sigtimedwait
#1 0x0000ffffbf2671b4 in __sigwait
#2 0x0000aaaaaabd1ddc in sigwait_compat
#3 0x0000aaaaaabd34c8 in qemu_thread_start
#4 0x0000ffffbf25c880 in start_thread
#5 0x0000ffffbf1b6b9c in thread_start
----
(gdb) run
Starting program: /usr/bin/qemu-img convert -f qcow2 -O qcow2
./disk01.ext4.qcow2 ./output.qcow2
[New Thread 0xffffbec5ad90 (LWP 72839)]
[New Thread 0xffffbe459d90 (LWP 72840)]
[New Thread 0xffffbdb57d90 (LWP 72841)]
[New Thread 0xffffacac9d90 (LWP 72859)]
[New Thread 0xffffa7ffed90 (LWP 72860)]
[New Thread 0xffffa77fdd90 (LWP 72861)]
[New Thread 0xffffa6ffcd90 (LWP 72862)]
[New Thread 0xffffa67fbd90 (LWP 72863)]
[New Thread 0xffffa5ffad90 (LWP 72864)]
[Thread 0xffffa5ffad90 (LWP 72864) exited]
[Thread 0xffffa6ffcd90 (LWP 72862) exited]
[Thread 0xffffa77fdd90 (LWP 72861) exited]
[Thread 0xffffbdb57d90 (LWP 72841) exited]
[Thread 0xffffa67fbd90 (LWP 72863) exited]
[Thread 0xffffacac9d90 (LWP 72859) exited]
[Thread 0xffffa7ffed90 (LWP 72860) exited]
<HUNG w/ 3 threads in the stack trace showed before>
"""
All the tasks left are blocked in a system call, so no task left to call
qemu_futex_wake() to unblock thread #2 (in futex()), which would unblock
thread #1 (doing poll() in a pipe with thread #2).
Those 7 threads exit before disk conversion is complete (sometimes in
the beginning, sometimes at the end).
----
On the HiSilicon D06 system - a 96 core NUMA arm64 box - qemu-img frequently hangs (~50% of the time) with this command:
qemu-img convert -f qcow2 -O qcow2 /tmp/cloudimg /tmp/cloudimg2
Where "cloudimg" is a standard qcow2 Ubuntu cloud image. This qcow2->qcow2 conversion happens to be something uvtool does every time it fetches images.
Once hung, attaching gdb gives the following backtrace:
(gdb) bt
#0 0x0000ffffae4f8154 in __GI_ppoll (fds=0xaaaae8a6
timeout=
at ../sysdeps/
#1 0x0000aaaabbefaf00 in ppoll (__ss=0x0, __timeout=0x0, __nfds=<optimized out>,
__fds=
#2 qemu_poll_ns (fds=<optimized out>, nfds=<optimized out>,
timeout=
#3 0x0000aaaabbefbf80 in os_host_
at util/main-
#4 main_loop_wait (nonblocking=
#5 0x0000aaaabbe2aa30 in convert_do_copy (s=0xffffc123bb58) at qemu-img.c:1980
#6 img_convert (argc=<optimized out>, argv=<optimized out>) at qemu-img.c:2456
#7 0x0000aaaabbe2333c in main (argc=7, argv=<optimized out>) at qemu-img.c:4975
Reproduced w/ latest QEMU git (@ 53744e0a182)
Related branches
- Rafael David Tinoco (community): Approve
- dann frazier (community): Approve
- Christian Ehrhardt (community): Needs Information
- Canonical Server: Pending requested
-
Diff: 212 lines (+190/-0)3 files modifieddebian/changelog (+8/-0)
debian/patches/series (+1/-0)
debian/patches/ubuntu/lp-1805256-async-use-explicit-mem-barriers-arm-only.patch (+181/-0)
- Christian Ehrhardt (community): Approve
- Rafael David Tinoco (community): Approve
- Ike Panhc (community): Approve
- dann frazier (community): Needs Fixing
- Canonical Server: Pending requested
-
Diff: 585 lines (+533/-0)8 files modifieddebian/changelog (+12/-0)
debian/patches/series (+6/-0)
debian/patches/ubuntu/lp-1805256-aio-Do-aio_notify_accept-only-during-blocking.patch (+116/-0)
debian/patches/ubuntu/lp-1805256-aio-posix-Assert-that-aio_poll_is-always-called.patch (+41/-0)
debian/patches/ubuntu/lp-1805256-aio-rename-aio_context_in_iothread.patch (+62/-0)
debian/patches/ubuntu/lp-1805256-aio-wait_delegate_poll_aioctx_bql.patch (+107/-0)
debian/patches/ubuntu/lp-1805256-async_use_explicit_mem_barriers.patch (+164/-0)
debian/patches/ubuntu/lp-1805256-dont-count-ctx-not-as-progress.patch (+25/-0)
- Christian Ehrhardt (community): Approve
- Rafael David Tinoco (community): Approve
- Ike Panhc (community): Approve
- dann frazier (community): Approve
- Canonical Server: Pending requested
-
Diff: 307 lines (+279/-0)4 files modifieddebian/changelog (+8/-0)
debian/patches/series (+2/-0)
debian/patches/ubuntu/lp-1805256-aio-wait_delegate_poll_aioctx_bql.patch (+110/-0)
debian/patches/ubuntu/lp-1805256-async_use_explicit_mem_barriers.patch (+159/-0)
- Christian Ehrhardt (community): Approve
- Rafael David Tinoco (community): Approve
- Ike Panhc (community): Approve
- dann frazier (community): Approve
- Canonical Server: Pending requested
-
Diff: 310 lines (+279/-0)4 files modifieddebian/changelog (+8/-0)
debian/patches/series (+2/-0)
debian/patches/ubuntu/lp-1805256-aio-wait_delegate_poll_aioctx_bql.patch (+110/-0)
debian/patches/ubuntu/lp-1805256-async_use_explicit_mem_barriers.patch (+159/-0)
- Christian Ehrhardt (community): Approve
- Rafael David Tinoco (community): Approve
- dann frazier (community): Approve
- Canonical Server: Pending requested
-
Diff: 310 lines (+279/-0)4 files modifieddebian/changelog (+8/-0)
debian/patches/series (+2/-0)
debian/patches/ubuntu/lp-1805256-aio-wait_delegate_poll_aioctx_bql.patch (+110/-0)
debian/patches/ubuntu/lp-1805256-async_use_explicit_mem_barriers.patch (+159/-0)
tags: | added: qemu-img |
Changed in qemu: | |
status: | New → Confirmed |
Changed in qemu (Ubuntu): | |
status: | New → Confirmed |
Changed in qemu (Ubuntu): | |
status: | Confirmed → In Progress |
assignee: | nobody → Rafael David Tinoco (rafaeldtinoco) |
importance: | Undecided → Medium |
summary: |
- qemu-img hangs on high core count ARM system + qemu-img hangs on rcu_call_ready_event logic in Aarch64 when converting + images |
Changed in qemu: | |
status: | Confirmed → In Progress |
assignee: | nobody → Rafael David Tinoco (rafaeldtinoco) |
description: | updated |
description: | updated |
Changed in kunpeng920: | |
status: | New → Confirmed |
Changed in qemu (Ubuntu Bionic): | |
status: | New → Confirmed |
Changed in qemu (Ubuntu Disco): | |
status: | New → Confirmed |
Changed in qemu (Ubuntu Focal): | |
status: | New → Confirmed |
tags: | added: patch |
tags: | added: ikeradar |
Changed in qemu (Ubuntu Eoan): | |
assignee: | Rafael David Tinoco (rafaeldtinoco) → nobody |
Changed in qemu: | |
assignee: | Rafael David Tinoco (rafaeldtinoco) → nobody |
Changed in qemu (Ubuntu): | |
assignee: | Rafael David Tinoco (rafaeldtinoco) → nobody |
Changed in qemu: | |
status: | In Progress → Fix Released |
Changed in qemu (Ubuntu Focal): | |
status: | Incomplete → In Progress |
Changed in qemu (Ubuntu Eoan): | |
status: | Incomplete → In Progress |
Changed in qemu (Ubuntu Disco): | |
status: | Incomplete → In Progress |
Changed in qemu (Ubuntu Bionic): | |
status: | Incomplete → In Progress |
Changed in qemu (Ubuntu): | |
status: | Incomplete → In Progress |
description: | updated |
description: | updated |
Changed in kunpeng920: | |
status: | Triaged → In Progress |
no longer affects: | qemu (Ubuntu Disco) |
Changed in kunpeng920: | |
status: | In Progress → Fix Committed |
Changed in kunpeng920: | |
status: | Fix Committed → Fix Released |
description: | updated |
Changed in kunpeng920: | |
status: | Triaged → Fix Committed |
no longer affects: | kunpeng920/ubuntu-18.04-hwe |
Changed in kunpeng920: | |
status: | Fix Committed → Fix Released |
Hi, can you do a `thread apply all bt` instead? If I were to bet, we're probably waiting for some slow call like lseek to return in another thread.
What filesystem/ blockdevice is involved here?