qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
From: "Philippe Mathieu-Daudé" <philippe.mathieu.daude@gmail.com>
To: Mark Kanda <mark.kanda@oracle.com>, qemu-devel@nongnu.org
Cc: pbonzini@redhat.com, richard.henderson@linaro.org
Subject: Re: [PATCH v2 4/5] cpu: Free cpu->cpu_ases in cpu_exec_unrealizefn()
Date: Fri, 18 Mar 2022 17:26:47 +0100	[thread overview]
Message-ID: <780af3a1-018b-92b1-6fbf-b27cc711bef0@gmail.com> (raw)
In-Reply-To: <20220318151555.381737-5-mark.kanda@oracle.com>

On 18/3/22 16:15, Mark Kanda wrote:
> vCPU hotunplug related leak reported by Valgrind:
> 
> ==132362== 216 bytes in 1 blocks are definitely lost in loss record 7,119 of 8,549
> ==132362==    at 0x4C3ADBB: calloc (vg_replace_malloc.c:1117)
> ==132362==    by 0x69EE4CD: g_malloc0 (in /usr/lib64/libglib-2.0.so.0.5600.4)
> ==132362==    by 0x7E34AF: cpu_address_space_init (physmem.c:751)
> ==132362==    by 0x45053E: qemu_init_vcpu (cpus.c:635)
> ==132362==    by 0x76B4A7: x86_cpu_realizefn (cpu.c:6520)
> ==132362==    by 0x9343ED: device_set_realized (qdev.c:531)
> ==132362==    by 0x93E26F: property_set_bool (object.c:2273)
> ==132362==    by 0x93C23E: object_property_set (object.c:1408)
> ==132362==    by 0x9406DC: object_property_set_qobject (qom-qobject.c:28)
> ==132362==    by 0x93C5A9: object_property_set_bool (object.c:1477)
> ==132362==    by 0x933C81: qdev_realize (qdev.c:333)
> ==132362==    by 0x455E9A: qdev_device_add_from_qdict (qdev-monitor.c:713)
> 
> Signed-off-by: Mark Kanda <mark.kanda@oracle.com>
> ---
>   cpu.c | 1 +
>   1 file changed, 1 insertion(+)
> 
> diff --git a/cpu.c b/cpu.c
> index be1f8b074c..6a3475022f 100644
> --- a/cpu.c
> +++ b/cpu.c
> @@ -173,6 +173,7 @@ void cpu_exec_unrealizefn(CPUState *cpu)
>       if (tcg_enabled()) {
>           tcg_exec_unrealizefn(cpu);
>       }
> +    g_free(cpu->cpu_ases);

There is an API mismatch here. We miss cpu_address_space_destroy().

cpu_exec_unrealizefn() then calls cpu_address_space_destroy(),
and cpu_address_space_destroy() frees cpu_ases.

Otherwise other cpu_address_space_init() calls will keep leaking.

>       cpu_list_remove(cpu);
>   }



  reply	other threads:[~2022-03-18 16:27 UTC|newest]

Thread overview: 11+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-03-18 15:15 [PATCH v2 0/5] vCPU hotunplug related memory leaks Mark Kanda
2022-03-18 15:15 ` [PATCH v2 1/5] accel: Introduce AccelOpsClass::destroy_vcpu_thread() Mark Kanda
2022-03-18 16:20   ` Philippe Mathieu-Daudé
2022-03-18 15:15 ` [PATCH v2 2/5] softmmu/cpus: Free cpu->thread in destroy_vcpu_thread_generic() Mark Kanda
2022-03-18 15:15 ` [PATCH v2 3/5] softmmu/cpus: Free cpu->halt_cond " Mark Kanda
2022-03-18 15:15 ` [PATCH v2 4/5] cpu: Free cpu->cpu_ases in cpu_exec_unrealizefn() Mark Kanda
2022-03-18 16:26   ` Philippe Mathieu-Daudé [this message]
2022-03-18 17:03     ` Mark Kanda
2022-03-18 15:15 ` [PATCH v2 5/5] i386/cpu: Free env->xsave_buf in x86_cpu_unrealizefn() Mark Kanda
2022-03-18 16:32   ` Philippe Mathieu-Daudé
2022-03-18 17:04     ` Mark Kanda

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=780af3a1-018b-92b1-6fbf-b27cc711bef0@gmail.com \
    --to=philippe.mathieu.daude@gmail.com \
    --cc=mark.kanda@oracle.com \
    --cc=pbonzini@redhat.com \
    --cc=qemu-devel@nongnu.org \
    --cc=richard.henderson@linaro.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).