]> Git Repo - qemu.git/commit - util/rcu.c
rcu: completely disable pthread_atfork callbacks as soon as possible
authorPaolo Bonzini <[email protected]>
Wed, 27 Jan 2016 07:49:21 +0000 (08:49 +0100)
committerPaolo Bonzini <[email protected]>
Tue, 8 Aug 2017 08:40:09 +0000 (10:40 +0200)
commit73c6e4013b4cd92d3d531bc22cc29e6036ef42e0
treea6eda7dbf2e2dfb39507cefd5cd0cb95cbe8a640
parentc233a35d3d91af666aa95a6a3ba8244d4ce728c6
rcu: completely disable pthread_atfork callbacks as soon as possible

Because of -daemonize, system mode QEMU sometimes needs to fork() and
keep RCU enabled in the child.  However, there is a possible deadlock
with synchronize_rcu:

- the CPU thread is inside a RCU critical section and wants to take
  the BQL in order to do MMIO

- the monitor thread, which is owning the BQL, calls rcu_init_lock
  which tries to take the rcu_sync_lock

- the call_rcu thread has taken rcu_sync_lock in synchronize_rcu, but
  synchronize_rcu needs the CPU thread to end the critical section
  before returning.

This cannot happen for user-mode emulation, because it does not have
a BQL.

To fix it, assume that system mode QEMU only forks in preparation for
exec (except when daemonizing) and disable pthread_atfork as soon as
the double fork has happened.

Reported-by: Dr. David Alan Gilbert <[email protected]>
Tested-by: Dr. David Alan Gilbert <[email protected]>
Signed-off-by: Paolo Bonzini <[email protected]>
include/qemu/rcu.h
util/rcu.c
vl.c
This page took 0.025991 seconds and 4 git commands to generate.