[RFC PATCH RESEND 12/42] accel/split: Have thread routine ready to dispatch over HW/SW

Philippe Mathieu-Daudé posted 42 patches 4 months, 3 weeks ago
[RFC PATCH RESEND 12/42] accel/split: Have thread routine ready to dispatch over HW/SW
Posted by Philippe Mathieu-Daudé 4 months, 3 weeks ago
Signed-off-by: Philippe Mathieu-Daudé <philmd@linaro.org>
---
 accel/split/split-accel-ops.c | 22 ++++++++++++++++------
 1 file changed, 16 insertions(+), 6 deletions(-)

diff --git a/accel/split/split-accel-ops.c b/accel/split/split-accel-ops.c
index 2c7945b6331..39495fdff14 100644
--- a/accel/split/split-accel-ops.c
+++ b/accel/split/split-accel-ops.c
@@ -19,12 +19,18 @@
 static void *split_cpu_thread_routine(void *arg)
 {
     AccelState *as = current_accel();
+    SplitAccelState *sas = SPLIT_ACCEL(as);
+    AccelClass *hwc = ACCEL_GET_CLASS(sas->hw);
+    AccelClass *swc = ACCEL_GET_CLASS(sas->sw);
+    AccelOpsClass *hwops = hwc->ops;
+    AccelOpsClass *swops = swc->ops;
     void *sw_force_rcu;
     CPUState *cpu = arg;
     AccelCPUState *acs;
     int r;
 
-    /* TODO: check accel allowed */
+    assert(swc->allowed);
+    assert(hwc->allowed);
 
     rcu_register_thread();
     sw_force_rcu = mttcg_vcpu_register(cpu);
@@ -35,7 +41,8 @@ static void *split_cpu_thread_routine(void *arg)
     cpu->thread_id = qemu_get_thread_id();
     current_cpu = cpu;
 
-    /* TODO: init_vcpu_thread() */
+    hwops->init_vcpu_thread(cpu);
+    swops->init_vcpu_thread(cpu);
     cpu->accel = g_renew(AccelCPUState, cpu->accel, 1); /* XXX only with current TCG */
     acs = cpu->accel;
     acs->accel = as;
@@ -49,10 +56,12 @@ static void *split_cpu_thread_routine(void *arg)
     cpu->exit_request = 1;
 
     do {
-        r = 0;
-
         if (cpu_can_run(cpu)) {
-            r = 0; /* TODO: exec_vcpu_thread() */
+            if (acs->use_hw) {
+                r = hwops->exec_vcpu_thread(cpu);
+            } else {
+                r = swops->exec_vcpu_thread(cpu);
+            }
             switch (r) {
             case 0:
                 break;
@@ -83,7 +92,8 @@ static void *split_cpu_thread_routine(void *arg)
         qemu_wait_io_event(cpu);
     } while (!cpu->unplug || cpu_can_run(cpu));
 
-    /* TODO: destroy_vcpu_thread() */
+    hwops->destroy_vcpu_thread(cpu);
+    swops->destroy_vcpu_thread(cpu);
 
     cpu_thread_signal_destroyed(cpu);
     bql_unlock();
-- 
2.49.0


Re: [RFC PATCH RESEND 12/42] accel/split: Have thread routine ready to dispatch over HW/SW
Posted by Richard Henderson 4 months, 3 weeks ago
On 6/20/25 10:27, Philippe Mathieu-Daudé wrote:
> @@ -49,10 +56,12 @@ static void *split_cpu_thread_routine(void *arg)
>       cpu->exit_request = 1;
>   
>       do {
> -        r = 0;
> -
>           if (cpu_can_run(cpu)) {
> -            r = 0; /* TODO: exec_vcpu_thread() */
> +            if (acs->use_hw) {
> +                r = hwops->exec_vcpu_thread(cpu);
> +            } else {
> +                r = swops->exec_vcpu_thread(cpu);
> +            }

Maybe

   AccelOpsClass *curops = acs->use_hw ? hwops : swops;
   r = curops->exec_vcpu_thread(cpu);

Anyway,
Reviewed-by: Richard Henderson <richard.henderson@linaro.org>


r~