[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[PULL 05/18] spapr: Fix leak of CPU machine specific data
From: |
David Gibson |
Subject: |
[PULL 05/18] spapr: Fix leak of CPU machine specific data |
Date: |
Wed, 28 Oct 2020 01:17:22 +1100 |
From: Greg Kurz <groug@kaod.org>
When a CPU core is being removed, the machine specific data of each
CPU thread object is leaked.
Fix this by calling the dedicated helper we have for that instead of
simply unparenting the CPU object. Call it from a separate loop in
spapr_cpu_core_unrealize() for symmetry with spapr_cpu_core_realize().
Signed-off-by: Greg Kurz <groug@kaod.org>
Message-Id: <160279670540.1808373.17319746576919615623.stgit@bahia.lan>
Signed-off-by: David Gibson <david@gibson.dropbear.id.au>
---
hw/ppc/spapr_cpu_core.c | 22 ++++++++++++----------
1 file changed, 12 insertions(+), 10 deletions(-)
diff --git a/hw/ppc/spapr_cpu_core.c b/hw/ppc/spapr_cpu_core.c
index b03620823a..c552112145 100644
--- a/hw/ppc/spapr_cpu_core.c
+++ b/hw/ppc/spapr_cpu_core.c
@@ -188,7 +188,6 @@ static void spapr_unrealize_vcpu(PowerPCCPU *cpu,
SpaprCpuCore *sc)
}
spapr_irq_cpu_intc_destroy(SPAPR_MACHINE(qdev_get_machine()), cpu);
cpu_remove_sync(CPU(cpu));
- object_unparent(OBJECT(cpu));
}
/*
@@ -213,6 +212,15 @@ static void spapr_cpu_core_reset_handler(void *opaque)
spapr_cpu_core_reset(opaque);
}
+static void spapr_delete_vcpu(PowerPCCPU *cpu, SpaprCpuCore *sc)
+{
+ SpaprCpuState *spapr_cpu = spapr_cpu_state(cpu);
+
+ cpu->machine_data = NULL;
+ g_free(spapr_cpu);
+ object_unparent(OBJECT(cpu));
+}
+
static void spapr_cpu_core_unrealize(DeviceState *dev)
{
SpaprCpuCore *sc = SPAPR_CPU_CORE(OBJECT(dev));
@@ -224,6 +232,9 @@ static void spapr_cpu_core_unrealize(DeviceState *dev)
for (i = 0; i < cc->nr_threads; i++) {
spapr_unrealize_vcpu(sc->threads[i], sc);
}
+ for (i = 0; i < cc->nr_threads; i++) {
+ spapr_delete_vcpu(sc->threads[i], sc);
+ }
g_free(sc->threads);
}
@@ -294,15 +305,6 @@ err:
return NULL;
}
-static void spapr_delete_vcpu(PowerPCCPU *cpu, SpaprCpuCore *sc)
-{
- SpaprCpuState *spapr_cpu = spapr_cpu_state(cpu);
-
- cpu->machine_data = NULL;
- g_free(spapr_cpu);
- object_unparent(OBJECT(cpu));
-}
-
static void spapr_cpu_core_realize(DeviceState *dev, Error **errp)
{
/* We don't use SPAPR_MACHINE() in order to exit gracefully if the user
--
2.26.2
- [PULL 02/18] ppc/spapr: re-assert IRQs during event-scan if there are pending, (continued)
- [PULL 02/18] ppc/spapr: re-assert IRQs during event-scan if there are pending, David Gibson, 2020/10/27
- [PULL 03/18] hw/net: move allocation to the heap due to very large stack frame, David Gibson, 2020/10/27
- [PULL 04/18] spapr: Move spapr_create_nvdimm_dr_connectors() to core machine code, David Gibson, 2020/10/27
- [PULL 07/18] spapr: Drop spapr_delete_vcpu() unused argument, David Gibson, 2020/10/27
- [PULL 06/18] spapr: Unrealize vCPUs with qdev_unrealize(), David Gibson, 2020/10/27
- [PULL 08/18] spapr: Make spapr_cpu_core_unrealize() idempotent, David Gibson, 2020/10/27
- [PULL 13/18] spapr: Pass &error_abort when getting some PC DIMM properties, David Gibson, 2020/10/27
- [PULL 09/18] spapr: Simplify spapr_cpu_core_realize() and spapr_cpu_core_unrealize(), David Gibson, 2020/10/27
- [PULL 11/18] spapr: Use appropriate getter for PC_DIMM_ADDR_PROP, David Gibson, 2020/10/27
- [PULL 14/18] spapr: Simplify error handling in spapr_memory_plug(), David Gibson, 2020/10/27
- [PULL 05/18] spapr: Fix leak of CPU machine specific data,
David Gibson <=
- [PULL 12/18] spapr: Use appropriate getter for PC_DIMM_SLOT_PROP, David Gibson, 2020/10/27
- [PULL 10/18] pc-dimm: Drop @errp argument of pc_dimm_plug(), David Gibson, 2020/10/27
- [PULL 15/18] spapr: Use error_append_hint() in spapr_reallocate_hpt(), David Gibson, 2020/10/27
- [PULL 16/18] target/ppc: Fix kvmppc_load_htab_chunk() error reporting, David Gibson, 2020/10/27
- [PULL 17/18] spapr: Improve spapr_reallocate_hpt() error reporting, David Gibson, 2020/10/27
- [PULL 18/18] ppc/: fix some comment spelling errors, David Gibson, 2020/10/27
- Re: [PULL 00/18] ppc-for-5.2 queue 20201028, Peter Maydell, 2020/10/30