[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[PATCH v1 07/18] cputlb: destroy CPUTLB with tlb_destroy
From: |
Alex Bennée |
Subject: |
[PATCH v1 07/18] cputlb: destroy CPUTLB with tlb_destroy |
Date: |
Fri, 12 Jun 2020 20:02:26 +0100 |
From: "Emilio G. Cota" <cota@braap.org>
I was after adding qemu_spin_destroy calls, but while at
it I noticed that we are leaking some memory.
Signed-off-by: Emilio G. Cota <cota@braap.org>
Signed-off-by: Robert Foley <robert.foley@linaro.org>
Reviewed-by: Alex Bennée <alex.bennee@linaro.org>
Signed-off-by: Alex Bennée <alex.bennee@linaro.org>
Message-Id: <20200609200738.445-5-robert.foley@linaro.org>
---
include/exec/exec-all.h | 8 ++++++++
accel/tcg/cputlb.c | 15 +++++++++++++++
exec.c | 1 +
3 files changed, 24 insertions(+)
diff --git a/include/exec/exec-all.h b/include/exec/exec-all.h
index 8792bea07ab..3cf88272df9 100644
--- a/include/exec/exec-all.h
+++ b/include/exec/exec-all.h
@@ -124,6 +124,11 @@ void cpu_address_space_init(CPUState *cpu, int asidx,
* @cpu: CPU whose TLB should be initialized
*/
void tlb_init(CPUState *cpu);
+/**
+ * tlb_destroy - destroy a CPU's TLB
+ * @cpu: CPU whose TLB should be destroyed
+ */
+void tlb_destroy(CPUState *cpu);
/**
* tlb_flush_page:
* @cpu: CPU whose TLB should be flushed
@@ -284,6 +289,9 @@ void tlb_set_page(CPUState *cpu, target_ulong vaddr,
static inline void tlb_init(CPUState *cpu)
{
}
+static inline void tlb_destroy(CPUState *cpu)
+{
+}
static inline void tlb_flush_page(CPUState *cpu, target_ulong addr)
{
}
diff --git a/accel/tcg/cputlb.c b/accel/tcg/cputlb.c
index eb2cf9de5e6..1e815357c70 100644
--- a/accel/tcg/cputlb.c
+++ b/accel/tcg/cputlb.c
@@ -270,6 +270,21 @@ void tlb_init(CPUState *cpu)
}
}
+void tlb_destroy(CPUState *cpu)
+{
+ CPUArchState *env = cpu->env_ptr;
+ int i;
+
+ qemu_spin_destroy(&env_tlb(env)->c.lock);
+ for (i = 0; i < NB_MMU_MODES; i++) {
+ CPUTLBDesc *desc = &env_tlb(env)->d[i];
+ CPUTLBDescFast *fast = &env_tlb(env)->f[i];
+
+ g_free(fast->table);
+ g_free(desc->iotlb);
+ }
+}
+
/* flush_all_helper: run fn across all cpus
*
* If the wait flag is set then the src cpu's helper will be queued as
diff --git a/exec.c b/exec.c
index a0bf9d61c87..6d7c312c910 100644
--- a/exec.c
+++ b/exec.c
@@ -892,6 +892,7 @@ void cpu_exec_unrealizefn(CPUState *cpu)
{
CPUClass *cc = CPU_GET_CLASS(cpu);
+ tlb_destroy(cpu);
cpu_list_remove(cpu);
if (cc->vmsd != NULL) {
--
2.20.1
- [PATCH v1 00/18] testing/next (tsan, dtc warnings, cross-builds), Alex Bennée, 2020/06/12
- [PATCH v1 01/18] tests/docker: bump fedora to 32, Alex Bennée, 2020/06/12
- [PATCH v1 02/18] Makefile: dtc: update, build the libfdt target, Alex Bennée, 2020/06/12
- [PATCH v1 03/18] Makefile: remove old compatibility gunks, Alex Bennée, 2020/06/12
- [PATCH v1 04/18] configure: add --enable-tsan flag + fiber annotations for coroutine-ucontext, Alex Bennée, 2020/06/12
- [PATCH v1 05/18] cpu: convert queued work to a QSIMPLEQ, Alex Bennée, 2020/06/12
- [PATCH v1 12/18] tests/docker: Added docker build support for TSan., Alex Bennée, 2020/06/12
- [PATCH v1 06/18] thread: add qemu_spin_destroy, Alex Bennée, 2020/06/12
- [PATCH v1 08/18] qht: call qemu_spin_destroy for head buckets, Alex Bennée, 2020/06/12
- [PATCH v1 07/18] cputlb: destroy CPUTLB with tlb_destroy,
Alex Bennée <=
- [PATCH v1 09/18] tcg: call qemu_spin_destroy for tb->jmp_lock, Alex Bennée, 2020/06/12
- [PATCH v1 10/18] translate-all: call qemu_spin_destroy for PageDesc, Alex Bennée, 2020/06/12
- [PATCH v1 11/18] thread: add tsan annotations to QemuSpin, Alex Bennée, 2020/06/12
- [PATCH v1 14/18] util: Added tsan annotate for thread name., Alex Bennée, 2020/06/12
- [PATCH v1 17/18] Revert ".shippable: temporaily disable some cross builds", Alex Bennée, 2020/06/12
- [PATCH v1 18/18] cirrus.yml: serialise make check, Alex Bennée, 2020/06/12
- [PATCH v1 13/18] include/qemu: Added tsan.h for annotations., Alex Bennée, 2020/06/12
- [PATCH v1 15/18] docs: Added details on TSan to testing.rst, Alex Bennée, 2020/06/12
- [PATCH v1 16/18] tests: Disable select tests under TSan, which hit TSan issue., Alex Bennée, 2020/06/12