Message ID | 20220318151555.381737-6-mark.kanda@oracle.com (mailing list archive) |
---|---|
State | New, archived |
Headers | show |
Series | vCPU hotunplug related memory leaks | expand |
On 18/3/22 16:15, Mark Kanda wrote: > vCPU hotunplug related leak reported by Valgrind: > > ==132362== 4,096 bytes in 1 blocks are definitely lost in loss record 8,440 of 8,549 > ==132362== at 0x4C3B15F: memalign (vg_replace_malloc.c:1265) > ==132362== by 0x4C3B288: posix_memalign (vg_replace_malloc.c:1429) > ==132362== by 0xB41195: qemu_try_memalign (memalign.c:53) > ==132362== by 0xB41204: qemu_memalign (memalign.c:73) > ==132362== by 0x7131CB: kvm_init_xsave (kvm.c:1601) > ==132362== by 0x7148ED: kvm_arch_init_vcpu (kvm.c:2031) > ==132362== by 0x91D224: kvm_init_vcpu (kvm-all.c:516) > ==132362== by 0x9242C9: kvm_vcpu_thread_fn (kvm-accel-ops.c:40) > ==132362== by 0xB2EB26: qemu_thread_start (qemu-thread-posix.c:556) > ==132362== by 0x7EB2159: start_thread (in /usr/lib64/libpthread-2.28.so) > ==132362== by 0x9D45DD2: clone (in /usr/lib64/libc-2.28.so) > > Signed-off-by: Mark Kanda <mark.kanda@oracle.com> > --- > target/i386/cpu.c | 5 +++++ > 1 file changed, 5 insertions(+) > > diff --git a/target/i386/cpu.c b/target/i386/cpu.c > index a88d6554c8..014a716c36 100644 > --- a/target/i386/cpu.c > +++ b/target/i386/cpu.c > @@ -6572,6 +6572,11 @@ static void x86_cpu_unrealizefn(DeviceState *dev) > } > > xcc->parent_unrealize(dev); > + > +#if defined(CONFIG_KVM) || defined(CONFIG_HVF) > + CPUX86State *env = &cpu->env; > + g_free(env->xsave_buf); This belong to hvf_arch_vcpu_destroy(). And for KVM, in the missing kvm_arch_destroy_vcpu(). > +#endif > } > > typedef struct BitProperty {
On 3/18/2022 11:32 AM, Philippe Mathieu-Daudé wrote: > On 18/3/22 16:15, Mark Kanda wrote: >> vCPU hotunplug related leak reported by Valgrind: >> >> ==132362== 4,096 bytes in 1 blocks are definitely lost in loss record 8,440 >> of 8,549 >> ==132362== at 0x4C3B15F: memalign (vg_replace_malloc.c:1265) >> ==132362== by 0x4C3B288: posix_memalign (vg_replace_malloc.c:1429) >> ==132362== by 0xB41195: qemu_try_memalign (memalign.c:53) >> ==132362== by 0xB41204: qemu_memalign (memalign.c:73) >> ==132362== by 0x7131CB: kvm_init_xsave (kvm.c:1601) >> ==132362== by 0x7148ED: kvm_arch_init_vcpu (kvm.c:2031) >> ==132362== by 0x91D224: kvm_init_vcpu (kvm-all.c:516) >> ==132362== by 0x9242C9: kvm_vcpu_thread_fn (kvm-accel-ops.c:40) >> ==132362== by 0xB2EB26: qemu_thread_start (qemu-thread-posix.c:556) >> ==132362== by 0x7EB2159: start_thread (in /usr/lib64/libpthread-2.28.so) >> ==132362== by 0x9D45DD2: clone (in /usr/lib64/libc-2.28.so) >> >> Signed-off-by: Mark Kanda <mark.kanda@oracle.com> >> --- >> target/i386/cpu.c | 5 +++++ >> 1 file changed, 5 insertions(+) >> >> diff --git a/target/i386/cpu.c b/target/i386/cpu.c >> index a88d6554c8..014a716c36 100644 >> --- a/target/i386/cpu.c >> +++ b/target/i386/cpu.c >> @@ -6572,6 +6572,11 @@ static void x86_cpu_unrealizefn(DeviceState *dev) >> } >> xcc->parent_unrealize(dev); >> + >> +#if defined(CONFIG_KVM) || defined(CONFIG_HVF) >> + CPUX86State *env = &cpu->env; >> + g_free(env->xsave_buf); > > This belong to hvf_arch_vcpu_destroy(). > > And for KVM, in the missing kvm_arch_destroy_vcpu(). > Will fix in v3. Thanks Philippe, -Mark
diff --git a/target/i386/cpu.c b/target/i386/cpu.c index a88d6554c8..014a716c36 100644 --- a/target/i386/cpu.c +++ b/target/i386/cpu.c @@ -6572,6 +6572,11 @@ static void x86_cpu_unrealizefn(DeviceState *dev) } xcc->parent_unrealize(dev); + +#if defined(CONFIG_KVM) || defined(CONFIG_HVF) + CPUX86State *env = &cpu->env; + g_free(env->xsave_buf); +#endif } typedef struct BitProperty {
vCPU hotunplug related leak reported by Valgrind: ==132362== 4,096 bytes in 1 blocks are definitely lost in loss record 8,440 of 8,549 ==132362== at 0x4C3B15F: memalign (vg_replace_malloc.c:1265) ==132362== by 0x4C3B288: posix_memalign (vg_replace_malloc.c:1429) ==132362== by 0xB41195: qemu_try_memalign (memalign.c:53) ==132362== by 0xB41204: qemu_memalign (memalign.c:73) ==132362== by 0x7131CB: kvm_init_xsave (kvm.c:1601) ==132362== by 0x7148ED: kvm_arch_init_vcpu (kvm.c:2031) ==132362== by 0x91D224: kvm_init_vcpu (kvm-all.c:516) ==132362== by 0x9242C9: kvm_vcpu_thread_fn (kvm-accel-ops.c:40) ==132362== by 0xB2EB26: qemu_thread_start (qemu-thread-posix.c:556) ==132362== by 0x7EB2159: start_thread (in /usr/lib64/libpthread-2.28.so) ==132362== by 0x9D45DD2: clone (in /usr/lib64/libc-2.28.so) Signed-off-by: Mark Kanda <mark.kanda@oracle.com> --- target/i386/cpu.c | 5 +++++ 1 file changed, 5 insertions(+)