[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[PATCH v1 1/8] linux-user: un-parent OBJECT(cpu) when closing thread
From: |
Alex Bennée |
Subject: |
[PATCH v1 1/8] linux-user: un-parent OBJECT(cpu) when closing thread |
Date: |
Thu, 11 Aug 2022 16:14:06 +0100 |
While forcing the CPU to unrealize by hand does trigger the clean-up
code we never fully free resources because refcount never reaches
zero. This is because QOM automatically added objects without an
explicit parent to /unattached/, incrementing the refcount.
Instead of manually triggering unrealization just unparent the object
and let the device machinery deal with that for us.
Resolves: https://gitlab.com/qemu-project/qemu/-/issues/866
Signed-off-by: Alex Bennée <alex.bennee@linaro.org>
Reviewed-by: Laurent Vivier <laurent@vivier.eu>
Message-Id: <20220610143855.1211000-1-alex.bennee@linaro.org>
---
v2
- move clearing of child_tidptr to before we finalise the CPU
object. While ts itself can be cleared g2h needs the current CPU
to resolve the address.
---
linux-user/syscall.c | 13 +++++++------
1 file changed, 7 insertions(+), 6 deletions(-)
diff --git a/linux-user/syscall.c b/linux-user/syscall.c
index f409121202..bfdd60136b 100644
--- a/linux-user/syscall.c
+++ b/linux-user/syscall.c
@@ -8594,7 +8594,13 @@ static abi_long do_syscall1(CPUArchState *cpu_env, int
num, abi_long arg1,
if (CPU_NEXT(first_cpu)) {
TaskState *ts = cpu->opaque;
- object_property_set_bool(OBJECT(cpu), "realized", false, NULL);
+ if (ts->child_tidptr) {
+ put_user_u32(0, ts->child_tidptr);
+ do_sys_futex(g2h(cpu, ts->child_tidptr),
+ FUTEX_WAKE, INT_MAX, NULL, NULL, 0);
+ }
+
+ object_unparent(OBJECT(cpu));
object_unref(OBJECT(cpu));
/*
* At this point the CPU should be unrealized and removed
@@ -8604,11 +8610,6 @@ static abi_long do_syscall1(CPUArchState *cpu_env, int
num, abi_long arg1,
pthread_mutex_unlock(&clone_lock);
- if (ts->child_tidptr) {
- put_user_u32(0, ts->child_tidptr);
- do_sys_futex(g2h(cpu, ts->child_tidptr),
- FUTEX_WAKE, INT_MAX, NULL, NULL, 0);
- }
thread_cpu = NULL;
g_free(ts);
rcu_unregister_thread();
--
2.30.2
- [PATCH v1 3/8] hw/core/cpu-sysemu: used cached class in cpu_asidx_from_attrs, (continued)
- [PATCH v1 3/8] hw/core/cpu-sysemu: used cached class in cpu_asidx_from_attrs, Alex Bennée, 2022/08/11
- [PATCH v1 7/8] tests/avocado: apply a band aid to aspeed-evb login, Alex Bennée, 2022/08/11
- [PATCH v1 2/8] cpu: cache CPUClass in CPUState for hot code paths, Alex Bennée, 2022/08/11
- [PATCH v1 5/8] ssi: cache SSIPeripheralClass to avoid GET_CLASS(), Alex Bennée, 2022/08/11
- [PATCH v1 1/8] linux-user: un-parent OBJECT(cpu) when closing thread,
Alex Bennée <=
- [PATCH v1 6/8] tests/avocado: add timeout to the aspeed tests, Alex Bennée, 2022/08/11
- [PATCH v1 8/8] accel/tcg: remove trace_vcpu_dstate TB checking, Alex Bennée, 2022/08/11
- Re: [PATCH for 7.1 v1 0/8] memory leaks and speed tweaks, Peter Maydell, 2022/08/11