diff mbox series

[11/24] accel/tcg: Allocate per-vCPU accel state in create_vcpu_thread()

Message ID 20240428221450.26460-12-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
Signed-off-by: Philippe Mathieu-Daudé <philmd@linaro.org>
---
 accel/tcg/vcpu-state.h          | 7 +++++++
 accel/tcg/tcg-accel-ops-mttcg.c | 2 ++
 accel/tcg/tcg-accel-ops-rr.c    | 2 ++
 3 files changed, 11 insertions(+)

Comments

Richard Henderson April 29, 2024, 2:23 p.m. UTC | #1
On 4/28/24 15:14, Philippe Mathieu-Daudé wrote:
> Signed-off-by: Philippe Mathieu-Daudé <philmd@linaro.org>
> ---
>   accel/tcg/vcpu-state.h          | 7 +++++++
>   accel/tcg/tcg-accel-ops-mttcg.c | 2 ++
>   accel/tcg/tcg-accel-ops-rr.c    | 2 ++
>   3 files changed, 11 insertions(+)

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

r~

> 
> diff --git a/accel/tcg/vcpu-state.h b/accel/tcg/vcpu-state.h
> index e407d914df..d0dd1bbff8 100644
> --- a/accel/tcg/vcpu-state.h
> +++ b/accel/tcg/vcpu-state.h
> @@ -8,6 +8,13 @@
>   
>   #include "hw/core/cpu.h"
>   
> +/**
> + * AccelCPUState:
> + */
> +struct AccelCPUState {
> +    /* Empty */
> +};
> +
>   #ifdef CONFIG_USER_ONLY
>   static inline TaskState *get_task_state(const CPUState *cs)
>   {
> diff --git a/accel/tcg/tcg-accel-ops-mttcg.c b/accel/tcg/tcg-accel-ops-mttcg.c
> index c552b45b8e..767b321a0d 100644
> --- a/accel/tcg/tcg-accel-ops-mttcg.c
> +++ b/accel/tcg/tcg-accel-ops-mttcg.c
> @@ -35,6 +35,7 @@
>   #include "tcg/startup.h"
>   #include "tcg-accel-ops.h"
>   #include "tcg-accel-ops-mttcg.h"
> +#include "accel/tcg/vcpu-state.h"
>   
>   typedef struct MttcgForceRcuNotifier {
>       Notifier notifier;
> @@ -135,6 +136,7 @@ void mttcg_start_vcpu_thread(CPUState *cpu)
>       char thread_name[VCPU_THREAD_NAME_SIZE];
>   
>       g_assert(tcg_enabled());
> +    cpu->accel = g_new0(AccelCPUState, 1);
>       tcg_cpu_init_cflags(cpu, current_machine->smp.max_cpus > 1);
>   
>       cpu->thread = g_new0(QemuThread, 1);
> diff --git a/accel/tcg/tcg-accel-ops-rr.c b/accel/tcg/tcg-accel-ops-rr.c
> index 894e73e52c..419b94f786 100644
> --- a/accel/tcg/tcg-accel-ops-rr.c
> +++ b/accel/tcg/tcg-accel-ops-rr.c
> @@ -36,6 +36,7 @@
>   #include "tcg-accel-ops.h"
>   #include "tcg-accel-ops-rr.h"
>   #include "tcg-accel-ops-icount.h"
> +#include "accel/tcg/vcpu-state.h"
>   
>   /* Kick all RR vCPUs */
>   void rr_kick_vcpu_thread(CPUState *unused)
> @@ -314,6 +315,7 @@ void rr_start_vcpu_thread(CPUState *cpu)
>       static QemuThread *single_tcg_cpu_thread;
>   
>       g_assert(tcg_enabled());
> +    cpu->accel = g_new0(AccelCPUState, 1);
>       tcg_cpu_init_cflags(cpu, false);
>   
>       if (!single_tcg_cpu_thread) {
diff mbox series

Patch

diff --git a/accel/tcg/vcpu-state.h b/accel/tcg/vcpu-state.h
index e407d914df..d0dd1bbff8 100644
--- a/accel/tcg/vcpu-state.h
+++ b/accel/tcg/vcpu-state.h
@@ -8,6 +8,13 @@ 
 
 #include "hw/core/cpu.h"
 
+/**
+ * AccelCPUState:
+ */
+struct AccelCPUState {
+    /* Empty */
+};
+
 #ifdef CONFIG_USER_ONLY
 static inline TaskState *get_task_state(const CPUState *cs)
 {
diff --git a/accel/tcg/tcg-accel-ops-mttcg.c b/accel/tcg/tcg-accel-ops-mttcg.c
index c552b45b8e..767b321a0d 100644
--- a/accel/tcg/tcg-accel-ops-mttcg.c
+++ b/accel/tcg/tcg-accel-ops-mttcg.c
@@ -35,6 +35,7 @@ 
 #include "tcg/startup.h"
 #include "tcg-accel-ops.h"
 #include "tcg-accel-ops-mttcg.h"
+#include "accel/tcg/vcpu-state.h"
 
 typedef struct MttcgForceRcuNotifier {
     Notifier notifier;
@@ -135,6 +136,7 @@  void mttcg_start_vcpu_thread(CPUState *cpu)
     char thread_name[VCPU_THREAD_NAME_SIZE];
 
     g_assert(tcg_enabled());
+    cpu->accel = g_new0(AccelCPUState, 1);
     tcg_cpu_init_cflags(cpu, current_machine->smp.max_cpus > 1);
 
     cpu->thread = g_new0(QemuThread, 1);
diff --git a/accel/tcg/tcg-accel-ops-rr.c b/accel/tcg/tcg-accel-ops-rr.c
index 894e73e52c..419b94f786 100644
--- a/accel/tcg/tcg-accel-ops-rr.c
+++ b/accel/tcg/tcg-accel-ops-rr.c
@@ -36,6 +36,7 @@ 
 #include "tcg-accel-ops.h"
 #include "tcg-accel-ops-rr.h"
 #include "tcg-accel-ops-icount.h"
+#include "accel/tcg/vcpu-state.h"
 
 /* Kick all RR vCPUs */
 void rr_kick_vcpu_thread(CPUState *unused)
@@ -314,6 +315,7 @@  void rr_start_vcpu_thread(CPUState *cpu)
     static QemuThread *single_tcg_cpu_thread;
 
     g_assert(tcg_enabled());
+    cpu->accel = g_new0(AccelCPUState, 1);
     tcg_cpu_init_cflags(cpu, false);
 
     if (!single_tcg_cpu_thread) {