KVM: X86: Fix x86_emulator slab cache leak
Subsystems (4)
PATCH 1/1 KVM: X86: Fix x86_emulator slab cache leak
From: Wanpeng Li <[email protected]>
Commit c9b8b07cded58 (KVM: x86: Dynamically allocate per-vCPU emulation context) tries to allocate per-vCPU emulation context dynamically, however, the x86_emulator slab cache is still exiting after the kvm module is unload as below after destroying the VM and unloading the kvm module.
grep x86_emulator /proc/slabinfox86_emulator 36 36 2672 12 8 : tunables 0 0 0 : slabdata 3 3 0
This patch fixes this slab cache leak by destroying the x86_emulator slab cache when the kvm module is unloaded.
--- arch/x86/kvm/x86.c | 1 + 1 file changed, 1 insertion(+)
arch/x86/kvm/x86.c +1 -0
@@ -8258,6 +8258,7 @@ void kvm_arch_exit(void) kvm_x86_ops.hardware_enable =NULL ;kvm_mmu_module_exit ();free_percpu (user_return_msrs); +kmem_cache_destroy (x86_emulator_cache);kmem_cache_destroy (x86_fpu_cache);#ifdef CONFIG_KVM_XEN static_key_deferred_flush (&kvm_xen_enabled);
Signature · 1 line
2.25.1
Quoted 26 lines · Wanpeng Li
From: Wanpeng Li <[email protected]>
Commit
c9b8b07cded58(KVM: x86: Dynamically allocate per-vCPU emulation context) tries to allocate per-vCPU emulation context dynamically, however, thex86_emulatorslab cache is still exiting after the kvm module is unload as below after destroying the VM and unloading the kvm module.grep
x86_emulator/proc/slabinfox86_emulator36 36 2672 12 8 : tunables 0 0 0 : slabdata 3 3 0This patch fixes this slab cache leak by destroying the
x86_emulatorslab cache when the kvm module is unloaded.Fixes c9b8b07cded58 (KVM: x86: Dynamically allocate per-vCPU emulation context)Signed-off-by Wanpeng Li <[email protected]>--- arch/x86/kvm/x86.c | 1 + 1 file changed, 1 insertion(+)arch/x86/kvm/x86.c +0
-0
arch/x86/kvm/x86.c void kvm_arch_exit(void) · line 8264
Quoted 7 lines
arch/x86/kvm/x86.c +1
-0@@ -8258,6 +8258,7 @@ void kvm_arch_exit(void) kvm_x86_ops.hardware_enable =NULL ;kvm_mmu_module_exit ();free_percpu (user_return_msrs); +kmem_cache_destroy (x86_emulator_cache);kmem_cache_destroy (x86_fpu_cache);#ifdef CONFIG_KVM_XEN static_key_deferred_flush (&kvm_xen_enabled);
Queued, thanks
Paolo