aboutsummaryrefslogtreecommitdiffstats
path: root/arch/x86/kvm/mmu.c
diff options
context:
space:
mode:
authorXiao Guangrong <xiaoguangrong@cn.fujitsu.com>2010-05-12 22:06:02 -0400
committerAvi Kivity <avi@redhat.com>2010-08-01 03:35:46 -0400
commite8ad9a707496c163312bcdd6aa3b90603d45dc9b (patch)
treeef153fdb9a441e2d9a21115e7a00684a702b6806 /arch/x86/kvm/mmu.c
parent48bb09eee4e102544808c00f43bc40a4a2e43e50 (diff)
KVM: MMU: use proper cache object freeing function
Use kmem_cache_free to free objects allocated by kmem_cache_alloc. Signed-off-by: Xiao Guangrong <xiaoguangrong@cn.fujitsu.com> Signed-off-by: Marcelo Tosatti <mtosatti@redhat.com>
Diffstat (limited to 'arch/x86/kvm/mmu.c')
-rw-r--r--arch/x86/kvm/mmu.c18
1 files changed, 10 insertions, 8 deletions
diff --git a/arch/x86/kvm/mmu.c b/arch/x86/kvm/mmu.c
index c075542648cd..bb48b0ca5f8c 100644
--- a/arch/x86/kvm/mmu.c
+++ b/arch/x86/kvm/mmu.c
@@ -305,10 +305,11 @@ static int mmu_topup_memory_cache(struct kvm_mmu_memory_cache *cache,
305 return 0; 305 return 0;
306} 306}
307 307
308static void mmu_free_memory_cache(struct kvm_mmu_memory_cache *mc) 308static void mmu_free_memory_cache(struct kvm_mmu_memory_cache *mc,
309 struct kmem_cache *cache)
309{ 310{
310 while (mc->nobjs) 311 while (mc->nobjs)
311 kfree(mc->objects[--mc->nobjs]); 312 kmem_cache_free(cache, mc->objects[--mc->nobjs]);
312} 313}
313 314
314static int mmu_topup_memory_cache_page(struct kvm_mmu_memory_cache *cache, 315static int mmu_topup_memory_cache_page(struct kvm_mmu_memory_cache *cache,
@@ -356,10 +357,11 @@ out:
356 357
357static void mmu_free_memory_caches(struct kvm_vcpu *vcpu) 358static void mmu_free_memory_caches(struct kvm_vcpu *vcpu)
358{ 359{
359 mmu_free_memory_cache(&vcpu->arch.mmu_pte_chain_cache); 360 mmu_free_memory_cache(&vcpu->arch.mmu_pte_chain_cache, pte_chain_cache);
360 mmu_free_memory_cache(&vcpu->arch.mmu_rmap_desc_cache); 361 mmu_free_memory_cache(&vcpu->arch.mmu_rmap_desc_cache, rmap_desc_cache);
361 mmu_free_memory_cache_page(&vcpu->arch.mmu_page_cache); 362 mmu_free_memory_cache_page(&vcpu->arch.mmu_page_cache);
362 mmu_free_memory_cache(&vcpu->arch.mmu_page_header_cache); 363 mmu_free_memory_cache(&vcpu->arch.mmu_page_header_cache,
364 mmu_page_header_cache);
363} 365}
364 366
365static void *mmu_memory_cache_alloc(struct kvm_mmu_memory_cache *mc, 367static void *mmu_memory_cache_alloc(struct kvm_mmu_memory_cache *mc,
@@ -380,7 +382,7 @@ static struct kvm_pte_chain *mmu_alloc_pte_chain(struct kvm_vcpu *vcpu)
380 382
381static void mmu_free_pte_chain(struct kvm_pte_chain *pc) 383static void mmu_free_pte_chain(struct kvm_pte_chain *pc)
382{ 384{
383 kfree(pc); 385 kmem_cache_free(pte_chain_cache, pc);
384} 386}
385 387
386static struct kvm_rmap_desc *mmu_alloc_rmap_desc(struct kvm_vcpu *vcpu) 388static struct kvm_rmap_desc *mmu_alloc_rmap_desc(struct kvm_vcpu *vcpu)
@@ -391,7 +393,7 @@ static struct kvm_rmap_desc *mmu_alloc_rmap_desc(struct kvm_vcpu *vcpu)
391 393
392static void mmu_free_rmap_desc(struct kvm_rmap_desc *rd) 394static void mmu_free_rmap_desc(struct kvm_rmap_desc *rd)
393{ 395{
394 kfree(rd); 396 kmem_cache_free(rmap_desc_cache, rd);
395} 397}
396 398
397/* 399/*
@@ -898,7 +900,7 @@ static void kvm_mmu_free_page(struct kvm *kvm, struct kvm_mmu_page *sp)
898 list_del(&sp->link); 900 list_del(&sp->link);
899 __free_page(virt_to_page(sp->spt)); 901 __free_page(virt_to_page(sp->spt));
900 __free_page(virt_to_page(sp->gfns)); 902 __free_page(virt_to_page(sp->gfns));
901 kfree(sp); 903 kmem_cache_free(mmu_page_header_cache, sp);
902 ++kvm->arch.n_free_mmu_pages; 904 ++kvm->arch.n_free_mmu_pages;
903} 905}
904 906