From: Philippe Mathieu-Daudé <phi...@linaro.org> Let vCPUs wait for themselves being ready first, then other ones. This allows the first thread to starts without the global vcpu queue (thus &first_cpu) being populated.
Signed-off-by: Philippe Mathieu-Daudé <phi...@linaro.org> Signed-off-by: Igor Mammedov <imamm...@redhat.com> --- accel/tcg/tcg-accel-ops-rr.c | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) diff --git a/accel/tcg/tcg-accel-ops-rr.c b/accel/tcg/tcg-accel-ops-rr.c index 028b385af9..d9eadd5ec4 100644 --- a/accel/tcg/tcg-accel-ops-rr.c +++ b/accel/tcg/tcg-accel-ops-rr.c @@ -197,16 +197,19 @@ static void *rr_cpu_thread_fn(void *arg) qemu_guest_random_seed_thread_part2(cpu->random_seed); /* wait for initial kick-off after machine start */ - while (first_cpu->stopped) { - qemu_cond_wait_bql(first_cpu->halt_cond); + while (cpu->stopped) { + CPUState *iter_cpu; + + qemu_cond_wait_bql(cpu->halt_cond); /* process any pending work */ - CPU_FOREACH(cpu) { - current_cpu = cpu; - qemu_wait_io_event_common(cpu); + CPU_FOREACH(iter_cpu) { + current_cpu = iter_cpu; + qemu_wait_io_event_common(iter_cpu); } } + g_assert(first_cpu); rr_start_kick_timer(); cpu = first_cpu; -- 2.43.0