mbox series

[v4,0/2] accel/tcg: Fix monitor deadlock

Message ID 20211109183523.47726-1-groug@kaod.org (mailing list archive)
Headers show
Series accel/tcg: Fix monitor deadlock | expand

Message

Greg Kurz Nov. 9, 2021, 6:35 p.m. UTC
Commit 7bed89958bfb ("device_core: use drain_call_rcu in in qmp_device_add")
introduced a regression in QEMU 6.0 : passing device_add without argument
hangs the monitor. This was reported against qemu-system-mips64 with TGC,
but I could consistently reproduce it with other targets (x86 and ppc64).

See https://gitlab.com/qemu-project/qemu/-/issues/650 for details.

The problem is that an emulated busy-looping vCPU can stay forever in
its RCU read-side critical section and prevent drain_call_rcu() to return.
This series fixes the issue by letting RCU kick vCPU threads out of the
read-side critical section when drain_call_rcu() is in progress. This is
achieved through notifiers, as suggested by Paolo Bonzini.

I've pushed this series to:

https://gitlab.com/gkurz/qemu/-/commits/fix-drain-call-rcu

v4:
- use rr_kick_next_cpu() instead of async_run_on_cpu(first_cpu)

v3:
- new separate implementations of force RCU notifiers for MTTCG and RR

v2:
- moved notifier list to RCU reader data
- separate API for notifier registration
- CPUState passed as an opaque pointer

Greg Kurz (2):
  rcu: Introduce force_rcu notifier
  accel/tcg: Register a force_rcu notifier

 accel/tcg/tcg-accel-ops-mttcg.c | 26 ++++++++++++++++++++++++++
 accel/tcg/tcg-accel-ops-rr.c    | 10 ++++++++++
 include/qemu/rcu.h              | 15 +++++++++++++++
 util/rcu.c                      | 19 +++++++++++++++++++
 4 files changed, 70 insertions(+)