[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[PATCH 06/22] exec/cpu: Call cpu_remove_sync() once in cpu_common_unreal
From: |
Philippe Mathieu-Daudé |
Subject: |
[PATCH 06/22] exec/cpu: Call cpu_remove_sync() once in cpu_common_unrealize() |
Date: |
Mon, 18 Sep 2023 18:02:39 +0200 |
While create_vcpu_thread() creates a vCPU thread, its counterpart
is cpu_remove_sync(), which join and destroy the thread.
create_vcpu_thread() is called in qemu_init_vcpu(), itself called
in cpu_common_realizefn(). Since we don't have qemu_deinit_vcpu()
helper (we probably don't need any), simply destroy the thread in
cpu_common_unrealizefn().
Note: only the PPC and X86 targets were calling cpu_remove_sync(),
meaning all other targets were leaking the thread when the vCPU
was unrealized (mostly when vCPU are hot-unplugged).
Signed-off-by: Philippe Mathieu-Daudé <philmd@linaro.org>
---
hw/core/cpu-common.c | 3 +++
target/i386/cpu.c | 1 -
target/ppc/cpu_init.c | 2 --
3 files changed, 3 insertions(+), 3 deletions(-)
diff --git a/hw/core/cpu-common.c b/hw/core/cpu-common.c
index a3b8de7054..e5841c59df 100644
--- a/hw/core/cpu-common.c
+++ b/hw/core/cpu-common.c
@@ -221,6 +221,9 @@ static void cpu_common_unrealizefn(DeviceState *dev)
/* NOTE: latest generic point before the cpu is fully unrealized */
cpu_exec_unrealizefn(cpu);
+
+ /* Destroy vCPU thread */
+ cpu_remove_sync(cpu);
}
static void cpu_common_initfn(Object *obj)
diff --git a/target/i386/cpu.c b/target/i386/cpu.c
index cb41d30aab..d79797d963 100644
--- a/target/i386/cpu.c
+++ b/target/i386/cpu.c
@@ -7470,7 +7470,6 @@ static void x86_cpu_unrealizefn(DeviceState *dev)
X86CPUClass *xcc = X86_CPU_GET_CLASS(dev);
#ifndef CONFIG_USER_ONLY
- cpu_remove_sync(CPU(dev));
qemu_unregister_reset(x86_cpu_machine_reset_cb, dev);
#endif
diff --git a/target/ppc/cpu_init.c b/target/ppc/cpu_init.c
index e2c06c1f32..24d4e8fa7e 100644
--- a/target/ppc/cpu_init.c
+++ b/target/ppc/cpu_init.c
@@ -6853,8 +6853,6 @@ static void ppc_cpu_unrealize(DeviceState *dev)
pcc->parent_unrealize(dev);
- cpu_remove_sync(CPU(cpu));
-
destroy_ppc_opcodes(cpu);
}
--
2.41.0
- [PATCH 00/22] exec/cpu: Call cpu_exec_realizefn() once in cpu_common_realize(), Philippe Mathieu-Daudé, 2023/09/18
- [PATCH 01/22] target/i386: Only realize existing APIC device, Philippe Mathieu-Daudé, 2023/09/18
- [PATCH 02/22] hw/intc/apic: Pass CPU using QOM link property, Philippe Mathieu-Daudé, 2023/09/18
- [PATCH 03/22] target/i386/kvm: Correct comment in kvm_cpu_realize(), Philippe Mathieu-Daudé, 2023/09/18
- [PATCH 07/22] exec/cpu: Introduce the CPU address space destruction function, Philippe Mathieu-Daudé, 2023/09/18
- [PATCH 05/22] exec/cpu: Call qemu_init_vcpu() once in cpu_common_realize(), Philippe Mathieu-Daudé, 2023/09/18
- [RFC PATCH 04/22] exec/cpu: Never call cpu_reset() before cpu_realize(), Philippe Mathieu-Daudé, 2023/09/18
- [PATCH 06/22] exec/cpu: Call cpu_remove_sync() once in cpu_common_unrealize(),
Philippe Mathieu-Daudé <=
- [PATCH 08/22] exec/cpu: RFC Destroy vCPU address spaces in cpu_common_unrealize(), Philippe Mathieu-Daudé, 2023/09/18
- [PATCH 09/22] target/arm: Create timers *after* accelerator vCPU is realized, Philippe Mathieu-Daudé, 2023/09/18
- [PATCH 10/22] target/hppa: Create timer *after* accelerator vCPU is realized, Philippe Mathieu-Daudé, 2023/09/18
- [PATCH 11/22] target/nios2: Create IRQs *after* accelerator vCPU is realized, Philippe Mathieu-Daudé, 2023/09/18
- [PATCH 12/22] target/mips: Create clock *after* accelerator vCPU is realized, Philippe Mathieu-Daudé, 2023/09/18
- [PATCH 14/22] target/sparc: Init CPU environment *after* accelerator vCPU is realized, Philippe Mathieu-Daudé, 2023/09/18
- [PATCH 15/22] exec/cpu: Introduce CPUClass::verify_accel_features(), Philippe Mathieu-Daudé, 2023/09/18
- [PATCH 16/22] target/arm: Extract verify_accel_features() from cpu_realize(), Philippe Mathieu-Daudé, 2023/09/18
- [PATCH 13/22] target/xtensa: Create IRQs *after* accelerator vCPU is realized, Philippe Mathieu-Daudé, 2023/09/18
- [PATCH 17/22] target/i386: Extract verify_accel_features() from cpu_realize(), Philippe Mathieu-Daudé, 2023/09/18