On 1/28/25 06:21, Philippe Mathieu-Daudé wrote:
> 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é <philmd@linaro.org>
> ---
> accel/tcg/tcg-accel-ops-rr.c | 15 ++++++++-------
> 1 file changed, 8 insertions(+), 7 deletions(-)
>
> diff --git a/accel/tcg/tcg-accel-ops-rr.c b/accel/tcg/tcg-accel-ops-rr.c
> index 028b385af9a..5ad3d617bce 100644
> --- a/accel/tcg/tcg-accel-ops-rr.c
> +++ b/accel/tcg/tcg-accel-ops-rr.c
> @@ -197,20 +197,21 @@ 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;
This final line seems to be unrelated.
I'm not saying it's wrong, but it's certainly a change in behaviour. We no longer execute
from first_cpu first.
r~