diff mbox series

[06/24] accel: Introduce AccelOpsClass::exit_vcpu_thread() handler

Message ID 20240428221450.26460-7-philmd@linaro.org (mailing list archive)
State New, archived
Headers show
Series exec: Rework around CPUState user fields (part 2) | expand

Commit Message

Philippe Mathieu-Daudé April 28, 2024, 10:14 p.m. UTC
Introduce a per-accelerator handler that can be call
when a vCPU exits.

Signed-off-by: Philippe Mathieu-Daudé <philmd@linaro.org>
---
 include/sysemu/accel-ops.h | 1 +
 system/cpus.c              | 3 +++
 2 files changed, 4 insertions(+)

Comments

Richard Henderson April 29, 2024, 1:05 a.m. UTC | #1
On 4/28/24 15:14, Philippe Mathieu-Daudé wrote:
> Introduce a per-accelerator handler that can be call
> when a vCPU exits.
> 
> Signed-off-by: Philippe Mathieu-Daudé <philmd@linaro.org>
> ---
>   include/sysemu/accel-ops.h | 1 +
>   system/cpus.c              | 3 +++
>   2 files changed, 4 insertions(+)

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

r~

> 
> diff --git a/include/sysemu/accel-ops.h b/include/sysemu/accel-ops.h
> index ef91fc28bb..35dfb7e266 100644
> --- a/include/sysemu/accel-ops.h
> +++ b/include/sysemu/accel-ops.h
> @@ -35,6 +35,7 @@ struct AccelOpsClass {
>       void (*create_vcpu_thread)(CPUState *cpu); /* MANDATORY NON-NULL */
>       void (*kick_vcpu_thread)(CPUState *cpu);
>       bool (*cpu_thread_is_idle)(CPUState *cpu);
> +    void (*exit_vcpu_thread)(CPUState *cpu);
>   
>       void (*synchronize_post_reset)(CPUState *cpu);
>       void (*synchronize_post_init)(CPUState *cpu);
> diff --git a/system/cpus.c b/system/cpus.c
> index e0530ad603..d0d585e8b9 100644
> --- a/system/cpus.c
> +++ b/system/cpus.c
> @@ -425,6 +425,9 @@ void cpu_exit(CPUState *cpu)
>       /* Ensure cpu_exec will see the exit request after TCG has exited.  */
>       smp_wmb();
>       qatomic_set(&cpu->neg.icount_decr.u16.high, -1);
> +    if (cpus_accel->exit_vcpu_thread) {
> +        cpus_accel->exit_vcpu_thread(cpu);
> +    }
>   }
>   
>   static void qemu_cpu_stop(CPUState *cpu, bool exit)
diff mbox series

Patch

diff --git a/include/sysemu/accel-ops.h b/include/sysemu/accel-ops.h
index ef91fc28bb..35dfb7e266 100644
--- a/include/sysemu/accel-ops.h
+++ b/include/sysemu/accel-ops.h
@@ -35,6 +35,7 @@  struct AccelOpsClass {
     void (*create_vcpu_thread)(CPUState *cpu); /* MANDATORY NON-NULL */
     void (*kick_vcpu_thread)(CPUState *cpu);
     bool (*cpu_thread_is_idle)(CPUState *cpu);
+    void (*exit_vcpu_thread)(CPUState *cpu);
 
     void (*synchronize_post_reset)(CPUState *cpu);
     void (*synchronize_post_init)(CPUState *cpu);
diff --git a/system/cpus.c b/system/cpus.c
index e0530ad603..d0d585e8b9 100644
--- a/system/cpus.c
+++ b/system/cpus.c
@@ -425,6 +425,9 @@  void cpu_exit(CPUState *cpu)
     /* Ensure cpu_exec will see the exit request after TCG has exited.  */
     smp_wmb();
     qatomic_set(&cpu->neg.icount_decr.u16.high, -1);
+    if (cpus_accel->exit_vcpu_thread) {
+        cpus_accel->exit_vcpu_thread(cpu);
+    }
 }
 
 static void qemu_cpu_stop(CPUState *cpu, bool exit)