diff mbox series

[v3,3/5] softmmu/cpus: Free cpu->halt_cond in generic_destroy_vcpu_thread()

Message ID 20220321141409.3112932-4-mark.kanda@oracle.com (mailing list archive)
State New, archived
Headers show
Series vCPU hotunplug related memory leaks | expand

Commit Message

Mark Kanda March 21, 2022, 2:14 p.m. UTC
vCPU hotunplug related leak reported by Valgrind:

==102631== 56 bytes in 1 blocks are definitely lost in loss record 5,089 of 8,555
==102631==    at 0x4C3ADBB: calloc (vg_replace_malloc.c:1117)
==102631==    by 0x69EE4CD: g_malloc0 (in /usr/lib64/libglib-2.0.so.0.5600.4)
==102631==    by 0x924452: kvm_start_vcpu_thread (kvm-accel-ops.c:69)
==102631==    by 0x4505C2: qemu_init_vcpu (cpus.c:643)
==102631==    by 0x76B4D1: x86_cpu_realizefn (cpu.c:6520)
==102631==    by 0x9344A7: device_set_realized (qdev.c:531)
==102631==    by 0x93E329: property_set_bool (object.c:2273)
==102631==    by 0x93C2F8: object_property_set (object.c:1408)
==102631==    by 0x940796: object_property_set_qobject (qom-qobject.c:28)
==102631==    by 0x93C663: object_property_set_bool (object.c:1477)
==102631==    by 0x933D3B: qdev_realize (qdev.c:333)
==102631==    by 0x455EC4: qdev_device_add_from_qdict (qdev-monitor.c:713)

Signed-off-by: Mark Kanda <mark.kanda@oracle.com>
---
 accel/accel-common.c | 1 +
 1 file changed, 1 insertion(+)

Comments

Philippe Mathieu-Daudé March 21, 2022, 10:12 p.m. UTC | #1
On 21/3/22 15:14, Mark Kanda wrote:
> vCPU hotunplug related leak reported by Valgrind:
> 
> ==102631== 56 bytes in 1 blocks are definitely lost in loss record 5,089 of 8,555
> ==102631==    at 0x4C3ADBB: calloc (vg_replace_malloc.c:1117)
> ==102631==    by 0x69EE4CD: g_malloc0 (in /usr/lib64/libglib-2.0.so.0.5600.4)
> ==102631==    by 0x924452: kvm_start_vcpu_thread (kvm-accel-ops.c:69)

Here we want to extract a common generic_init_vcpu_thread().

> ==102631==    by 0x4505C2: qemu_init_vcpu (cpus.c:643)
> ==102631==    by 0x76B4D1: x86_cpu_realizefn (cpu.c:6520)
> ==102631==    by 0x9344A7: device_set_realized (qdev.c:531)
> ==102631==    by 0x93E329: property_set_bool (object.c:2273)
> ==102631==    by 0x93C2F8: object_property_set (object.c:1408)
> ==102631==    by 0x940796: object_property_set_qobject (qom-qobject.c:28)
> ==102631==    by 0x93C663: object_property_set_bool (object.c:1477)
> ==102631==    by 0x933D3B: qdev_realize (qdev.c:333)
> ==102631==    by 0x455EC4: qdev_device_add_from_qdict (qdev-monitor.c:713)
> 
> Signed-off-by: Mark Kanda <mark.kanda@oracle.com>
> ---
>   accel/accel-common.c | 1 +
>   1 file changed, 1 insertion(+)
> 
> diff --git a/accel/accel-common.c b/accel/accel-common.c
> index 623df43cc3..297d4e4ef1 100644
> --- a/accel/accel-common.c
> +++ b/accel/accel-common.c
> @@ -140,4 +140,5 @@ type_init(register_accel_types);
>   void generic_destroy_vcpu_thread(CPUState *cpu)
>   {
>       g_free(cpu->thread);
> +    g_free(cpu->halt_cond);
>   }
Mark Kanda March 22, 2022, 12:52 p.m. UTC | #2
Thanks Philippe,

On 3/21/2022 5:12 PM, Philippe Mathieu-Daudé wrote:
> On 21/3/22 15:14, Mark Kanda wrote:
>> vCPU hotunplug related leak reported by Valgrind:
>>
>> ==102631== 56 bytes in 1 blocks are definitely lost in loss record 5,089 of 
>> 8,555
>> ==102631==    at 0x4C3ADBB: calloc (vg_replace_malloc.c:1117)
>> ==102631==    by 0x69EE4CD: g_malloc0 (in /usr/lib64/libglib-2.0.so.0.5600.4)
>> ==102631==    by 0x924452: kvm_start_vcpu_thread (kvm-accel-ops.c:69)
>
> Here we want to extract a common generic_init_vcpu_thread().
>

How about I add extracting 'generic_init_vcpu_thread()' as a separate cleanup 
patch at the end? I'll also drop my xsave_buf patch due to your followup.

Thanks/regards,
-Mark

>> ==102631==    by 0x4505C2: qemu_init_vcpu (cpus.c:643)
>> ==102631==    by 0x76B4D1: x86_cpu_realizefn (cpu.c:6520)
>> ==102631==    by 0x9344A7: device_set_realized (qdev.c:531)
>> ==102631==    by 0x93E329: property_set_bool (object.c:2273)
>> ==102631==    by 0x93C2F8: object_property_set (object.c:1408)
>> ==102631==    by 0x940796: object_property_set_qobject (qom-qobject.c:28)
>> ==102631==    by 0x93C663: object_property_set_bool (object.c:1477)
>> ==102631==    by 0x933D3B: qdev_realize (qdev.c:333)
>> ==102631==    by 0x455EC4: qdev_device_add_from_qdict (qdev-monitor.c:713)
>>
>> Signed-off-by: Mark Kanda <mark.kanda@oracle.com>
>> ---
>>   accel/accel-common.c | 1 +
>>   1 file changed, 1 insertion(+)
>>
>> diff --git a/accel/accel-common.c b/accel/accel-common.c
>> index 623df43cc3..297d4e4ef1 100644
>> --- a/accel/accel-common.c
>> +++ b/accel/accel-common.c
>> @@ -140,4 +140,5 @@ type_init(register_accel_types);
>>   void generic_destroy_vcpu_thread(CPUState *cpu)
>>   {
>>       g_free(cpu->thread);
>> +    g_free(cpu->halt_cond);
>>   }
>
Philippe Mathieu-Daudé March 22, 2022, 1:32 p.m. UTC | #3
On 22/3/22 13:52, Mark Kanda wrote:
> Thanks Philippe,
> 
> On 3/21/2022 5:12 PM, Philippe Mathieu-Daudé wrote:
>> On 21/3/22 15:14, Mark Kanda wrote:
>>> vCPU hotunplug related leak reported by Valgrind:
>>>
>>> ==102631== 56 bytes in 1 blocks are definitely lost in loss record 
>>> 5,089 of 8,555
>>> ==102631==    at 0x4C3ADBB: calloc (vg_replace_malloc.c:1117)
>>> ==102631==    by 0x69EE4CD: g_malloc0 (in 
>>> /usr/lib64/libglib-2.0.so.0.5600.4)
>>> ==102631==    by 0x924452: kvm_start_vcpu_thread (kvm-accel-ops.c:69)
>>
>> Here we want to extract a common generic_init_vcpu_thread().
>>
> 
> How about I add extracting 'generic_init_vcpu_thread()' as a separate 
> cleanup patch at the end? I'll also drop my xsave_buf patch due to your 
> followup.

I plan to queue patch #4 for v7.0, but I'd rather have the first ones
reworked by extracting the common vcpu_thread_create() code (which
only differs in TCG/RR). I'll give it a try and send a respin later
today.
diff mbox series

Patch

diff --git a/accel/accel-common.c b/accel/accel-common.c
index 623df43cc3..297d4e4ef1 100644
--- a/accel/accel-common.c
+++ b/accel/accel-common.c
@@ -140,4 +140,5 @@  type_init(register_accel_types);
 void generic_destroy_vcpu_thread(CPUState *cpu)
 {
     g_free(cpu->thread);
+    g_free(cpu->halt_cond);
 }