mirror_qemu/accel
Greg Kurz 36c651c226 accel/tcg: Register a force_rcu notifier
A TCG vCPU doing a busy loop systematicaly hangs the QEMU monitor
if the user passes 'device_add' without argument. This is because
drain_cpu_all() which is called from qmp_device_add() cannot return
if readers don't exit read-side critical sections. That is typically
what busy-looping TCG vCPUs do:

int cpu_exec(CPUState *cpu)
{
[...]
    rcu_read_lock();
[...]
    while (!cpu_handle_exception(cpu, &ret)) {
        // Busy loop keeps vCPU here
    }
[...]
    rcu_read_unlock();

    return ret;
}

For MTTCG, have all vCPU threads register a force_rcu notifier that will
kick them out of the loop using async_run_on_cpu(). The notifier is called
with the rcu_registry_lock mutex held, using async_run_on_cpu() ensures
there are no deadlocks.

For RR, a single thread runs all vCPUs. Just register a single notifier
that kicks the current vCPU to the next one.

For MTTCG:
Suggested-by: Paolo Bonzini <pbonzini@redhat.com>

For RR:
Suggested-by: Richard Henderson <richard.henderson@linaro.org>

Fixes: 7bed89958b ("device_core: use drain_call_rcu in in qmp_device_add")
Resolves: https://gitlab.com/qemu-project/qemu/-/issues/650
Signed-off-by: Greg Kurz <groug@kaod.org>
Reviewed-by: Richard Henderson <richard.henderson@linaro.org>
Message-Id: <20211109183523.47726-3-groug@kaod.org>
Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
(cherry picked from commit dd47a8f654)
Signed-off-by: Michael Roth <michael.roth@amd.com>
2021-12-14 14:26:01 -06:00
..
hvf hvf: Simplify post reset/init/loadvm hooks 2021-06-03 16:43:27 +01:00
kvm kvm: ppc: Print meaningful message on KVM_CREATE_VM failure 2021-07-29 10:59:49 +10:00
qtest accel: build qtest modular 2021-07-09 18:21:33 +02:00
stubs Do not include cpu.h if it's not really necessary 2021-05-02 17:24:51 +02:00
tcg accel/tcg: Register a force_rcu notifier 2021-12-14 14:26:01 -06:00
xen sysemu: Let VMChangeStateHandler take boolean 'running' argument 2021-03-09 23:13:57 +01:00
Kconfig Add NVMM accelerator: configure and build logic 2021-05-04 14:15:34 +02:00
accel-common.c accel: autoload modules 2021-07-09 18:21:33 +02:00
accel-softmmu.c accel: autoload modules 2021-07-09 18:21:33 +02:00
accel-softmmu.h accel: replace struct CpusAccel with AccelOpsClass 2021-02-05 10:24:15 -10:00
accel-user.c accel: extend AccelState and AccelClass to user-mode 2021-02-05 10:24:15 -10:00
dummy-cpus.c accel: move qtest CpusAccel functions to a common location 2020-10-24 07:23:19 +02:00
meson.build hvf: Move assert_hvf_ok() into common directory 2021-06-03 16:43:26 +01:00