Ccing the QOM maintainers to make sure we have the
QOM lifecycle operations right here...
On Tue, 16 Jul 2019 at 15:02, Alex Bennée <email address hidden> wrote:
>
> When a CPU object is created it is parented during it's realize stage.
> If we don't unparent before the "final" unref we will never finzalize
> the object leading to a memory leak. For most setups you probably
> won't notice but with anything that creates and destroys a lot of
> threads this will add up. This goes especially for architectures which
> allocate a lot of memory in their CPU structures.
>
> Fixes: https://bugs.launchpad.net/qemu/+bug/1836558
> Cc: <email address hidden>
> Signed-off-by: Alex Bennée <email address hidden>
> ---
> linux-user/syscall.c | 1 +
> 1 file changed, 1 insertion(+)
>
> diff --git a/linux-user/syscall.c b/linux-user/syscall.c
> index 39a37496fed..4c9313fd9d0 100644
> --- a/linux-user/syscall.c
> +++ b/linux-user/syscall.c
> @@ -7183,6 +7183,7 @@ static abi_long do_syscall1(void *cpu_env, int num, abi_long arg1,
> NULL, NULL, 0);
> }
> thread_cpu = NULL;
> + object_unparent(OBJECT(cpu));
> object_unref(OBJECT(cpu));
> g_free(ts);
> rcu_unregister_thread();
I think (as I mentioned on IRC) that we also need to unrealize
the CPU object, because target/ppc at least does some freeing
of memory in its unrealize method. I think we do that by
setting the QOM "realize" property back to "false" -- but that
might barf if we try it on a CPU that isn't hotpluggable...
Ccing the QOM maintainers to make sure we have the
QOM lifecycle operations right here...
On Tue, 16 Jul 2019 at 15:02, Alex Bennée <email address hidden> wrote: /bugs.launchpad .net/qemu/ +bug/1836558 syscall. c | 1 + user/syscall. c b/linux- user/syscall. c .4c9313fd9d0 100644 user/syscall. c user/syscall. c unparent( OBJECT( cpu)); unref(OBJECT( cpu)); thread( );
>
> When a CPU object is created it is parented during it's realize stage.
> If we don't unparent before the "final" unref we will never finzalize
> the object leading to a memory leak. For most setups you probably
> won't notice but with anything that creates and destroys a lot of
> threads this will add up. This goes especially for architectures which
> allocate a lot of memory in their CPU structures.
>
> Fixes: https:/
> Cc: <email address hidden>
> Signed-off-by: Alex Bennée <email address hidden>
> ---
> linux-user/
> 1 file changed, 1 insertion(+)
>
> diff --git a/linux-
> index 39a37496fed.
> --- a/linux-
> +++ b/linux-
> @@ -7183,6 +7183,7 @@ static abi_long do_syscall1(void *cpu_env, int num, abi_long arg1,
> NULL, NULL, 0);
> }
> thread_cpu = NULL;
> + object_
> object_
> g_free(ts);
> rcu_unregister_
I think (as I mentioned on IRC) that we also need to unrealize
the CPU object, because target/ppc at least does some freeing
of memory in its unrealize method. I think we do that by
setting the QOM "realize" property back to "false" -- but that
might barf if we try it on a CPU that isn't hotpluggable...
thanks
-- PMM