On 22/6/25 04:10, Richard Henderson wrote:
On 6/20/25 10:13, Philippe Mathieu-Daudé wrote:
By converting to AccelOpsClass::cpu_thread_routine we can
let the common accel_create_vcpu_thread() create the thread.
Signed-off-by: Philippe Mathieu-Daudé <[email protected]>
---
target/i386/whpx/whpx-accel-ops.c | 12 +-----------
1 file changed, 1 insertion(+), 11 deletions(-)
diff --git a/target/i386/whpx/whpx-accel-ops.c b/target/i386/whpx/
whpx-accel-ops.c
index b8bebe403c9..c1b27d1b89d 100644
--- a/target/i386/whpx/whpx-accel-ops.c
+++ b/target/i386/whpx/whpx-accel-ops.c
@@ -61,16 +61,6 @@ static void *whpx_cpu_thread_fn(void *arg)
return NULL;
}
-static void whpx_start_vcpu_thread(CPUState *cpu)
-{
- char thread_name[VCPU_THREAD_NAME_SIZE];
-
- snprintf(thread_name, VCPU_THREAD_NAME_SIZE, "CPU %d/WHPX",
- cpu->cpu_index);
- qemu_thread_create(cpu->thread, thread_name, whpx_cpu_thread_fn,
- cpu, QEMU_THREAD_JOINABLE);
-}
-
static void whpx_kick_vcpu_thread(CPUState *cpu)
{
if (!qemu_cpu_is_self(cpu)) {
@@ -87,7 +77,7 @@ static void whpx_accel_ops_class_init(ObjectClass
*oc, const void *data)
{
AccelOpsClass *ops = ACCEL_OPS_CLASS(oc);
- ops->create_vcpu_thread = whpx_start_vcpu_thread;
+ ops->cpu_thread_routine = whpx_cpu_thread_fn;
ops->kick_vcpu_thread = whpx_kick_vcpu_thread;
ops->cpu_thread_is_idle = whpx_vcpu_thread_is_idle;
After this, create_vcpu_thread is unused, correct?
Only RR left, which is a bit different:
339 void rr_start_vcpu_thread(CPUState *cpu)
340 {
341 char thread_name[VCPU_THREAD_NAME_SIZE];
342 static QemuCond *single_tcg_halt_cond;
343 static QemuThread *single_tcg_cpu_thread;
344
345 tcg_vcpu_thread_precreate(cpu);
346
347 if (!single_tcg_cpu_thread) {
348 single_tcg_halt_cond = cpu->halt_cond;
349 single_tcg_cpu_thread = cpu->thread;
350
351 /* share a single thread for all cpus with TCG */
352 snprintf(thread_name, VCPU_THREAD_NAME_SIZE, "ALL CPUs/TCG");
353 qemu_thread_create(cpu->thread, thread_name,
354 rr_cpu_thread_fn,
355 cpu, QEMU_THREAD_JOINABLE);
356 } else {
357 /* we share the thread, dump spare data */
358 g_free(cpu->thread);
359 qemu_cond_destroy(cpu->halt_cond);
360 g_free(cpu->halt_cond);
361 cpu->thread = single_tcg_cpu_thread;
362 cpu->halt_cond = single_tcg_halt_cond;
363
364 /* copy the stuff done at start of rr_cpu_thread_fn */
365 cpu->thread_id = first_cpu->thread_id;
366 cpu->neg.can_do_io = 1;
367 cpu->created = true;
368 }
369 }