[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[RFC PATCH 3/7] accel/tcg: Implement tcg_get_cpus_queue()
From: |
Philippe Mathieu-Daudé |
Subject: |
[RFC PATCH 3/7] accel/tcg: Implement tcg_get_cpus_queue() |
Date: |
Mon, 6 Jan 2025 21:02:54 +0100 |
Use a specific vCPUs queue for our unique software accelerator.
Register the AccelOpsClass::get_cpus_queue() handler.
Signed-off-by: Philippe Mathieu-Daudé <philmd@linaro.org>
---
accel/tcg/tcg-accel-ops.h | 10 ++++++++++
accel/tcg/tcg-accel-ops.c | 8 ++++++++
2 files changed, 18 insertions(+)
diff --git a/accel/tcg/tcg-accel-ops.h b/accel/tcg/tcg-accel-ops.h
index 6feeb3f3e9b..7b1d6288742 100644
--- a/accel/tcg/tcg-accel-ops.h
+++ b/accel/tcg/tcg-accel-ops.h
@@ -13,10 +13,20 @@
#define TCG_ACCEL_OPS_H
#include "system/cpus.h"
+#include "hw/core/cpu.h"
void tcg_cpu_destroy(CPUState *cpu);
int tcg_cpu_exec(CPUState *cpu);
void tcg_handle_interrupt(CPUState *cpu, int mask);
void tcg_cpu_init_cflags(CPUState *cpu, bool parallel);
+#ifdef CONFIG_USER_ONLY
+#define tcg_cpus_queue cpus_queue
+#else
+/* Guard with qemu_cpu_list_lock */
+extern CPUTailQ tcg_cpus_queue;
+#endif
+
+#define CPU_FOREACH_TCG(cpu) QTAILQ_FOREACH_RCU(cpu, &tcg_cpus_queue, node)
+
#endif /* TCG_ACCEL_OPS_H */
diff --git a/accel/tcg/tcg-accel-ops.c b/accel/tcg/tcg-accel-ops.c
index 6e3f1fa92b2..1fb077f7b38 100644
--- a/accel/tcg/tcg-accel-ops.c
+++ b/accel/tcg/tcg-accel-ops.c
@@ -47,6 +47,13 @@
/* common functionality among all TCG variants */
+CPUTailQ tcg_cpus_queue = QTAILQ_HEAD_INITIALIZER(tcg_cpus_queue);
+
+static CPUTailQ *tcg_get_cpus_queue(void)
+{
+ return &tcg_cpus_queue;
+}
+
void tcg_cpu_init_cflags(CPUState *cpu, bool parallel)
{
uint32_t cflags;
@@ -199,6 +206,7 @@ static inline void tcg_remove_all_breakpoints(CPUState *cpu)
static void tcg_accel_ops_init(AccelOpsClass *ops)
{
+ ops->get_cpus_queue = tcg_get_cpus_queue;
if (qemu_tcg_mttcg_enabled()) {
ops->create_vcpu_thread = mttcg_start_vcpu_thread;
ops->kick_vcpu_thread = mttcg_kick_vcpu_thread;
--
2.47.1
- [RFC PATCH 0/7] accel: Add per-accelerator vCPUs queue, Philippe Mathieu-Daudé, 2025/01/06
- [RFC PATCH 1/7] cpus: Restrict CPU_FOREACH_SAFE() to user emulation, Philippe Mathieu-Daudé, 2025/01/06
- [RFC PATCH 2/7] cpus: Introduce AccelOpsClass::get_cpus_queue(), Philippe Mathieu-Daudé, 2025/01/06
- [RFC PATCH 3/7] accel/tcg: Implement tcg_get_cpus_queue(),
Philippe Mathieu-Daudé <=
- [RFC PATCH 4/7] accel/tcg: Use CPU_FOREACH_TCG(), Philippe Mathieu-Daudé, 2025/01/06
- [RFC PATCH 5/7] accel/hw: Implement hw_accel_get_cpus_queue(), Philippe Mathieu-Daudé, 2025/01/06
- [RFC PATCH 6/7] accel/hvf: Use CPU_FOREACH_HVF(), Philippe Mathieu-Daudé, 2025/01/06
- [RFC PATCH 7/7] accel/kvm: Use CPU_FOREACH_KVM(), Philippe Mathieu-Daudé, 2025/01/06