Re: [PATCH v2 07/10] accel/tcg: Simplify use of &first_cpu in rr_cpu_thread_fn()

2025-02-25 Thread Alex Bennée
Igor Mammedov  writes:

> From: Philippe Mathieu-Daudé 
>
> 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é 
> Signed-off-by: Igor Mammedov 

Acked-by: Alex Bennée 

-- 
Alex Bennée
Virtualisation Tech Lead @ Linaro



[PATCH v2 07/10] accel/tcg: Simplify use of &first_cpu in rr_cpu_thread_fn()

2025-02-07 Thread Igor Mammedov
From: Philippe Mathieu-Daudé 

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é 
Signed-off-by: Igor Mammedov 
---
 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