aboutsummaryrefslogtreecommitdiffstats
path: root/arch/x86/kvm
diff options
context:
space:
mode:
authorXiao Guangrong <xiaoguangrong@cn.fujitsu.com>2011-03-04 05:59:21 -0500
committerMarcelo Tosatti <mtosatti@redhat.com>2011-03-17 12:08:32 -0400
commit48c0e4e9067eb085e7b300628c9640df071aac55 (patch)
tree27cf74fd8a321df3be33954446236576b3b5b0a7 /arch/x86/kvm
parent1b7fd45c32fcc170246bf10ba8d33871840319b8 (diff)
KVM: MMU: move mmu pages calculated out of mmu lock
kvm_mmu_calculate_mmu_pages need to walk all memslots and it's protected by kvm->slots_lock, so move it out of mmu spinlock Signed-off-by: Xiao Guangrong <xiaoguangrong@cn.fujitsu.com> Signed-off-by: Avi Kivity <avi@redhat.com>
Diffstat (limited to 'arch/x86/kvm')
-rw-r--r--arch/x86/kvm/x86.c10
1 files changed, 5 insertions, 5 deletions
diff --git a/arch/x86/kvm/x86.c b/arch/x86/kvm/x86.c
index 785ae0c300f7..b9c2b8e6c70c 100644
--- a/arch/x86/kvm/x86.c
+++ b/arch/x86/kvm/x86.c
@@ -6105,7 +6105,7 @@ void kvm_arch_commit_memory_region(struct kvm *kvm,
6105 int user_alloc) 6105 int user_alloc)
6106{ 6106{
6107 6107
6108 int npages = mem->memory_size >> PAGE_SHIFT; 6108 int nr_mmu_pages = 0, npages = mem->memory_size >> PAGE_SHIFT;
6109 6109
6110 if (!user_alloc && !old.user_alloc && old.rmap && !npages) { 6110 if (!user_alloc && !old.user_alloc && old.rmap && !npages) {
6111 int ret; 6111 int ret;
@@ -6120,12 +6120,12 @@ void kvm_arch_commit_memory_region(struct kvm *kvm,
6120 "failed to munmap memory\n"); 6120 "failed to munmap memory\n");
6121 } 6121 }
6122 6122
6123 if (!kvm->arch.n_requested_mmu_pages)
6124 nr_mmu_pages = kvm_mmu_calculate_mmu_pages(kvm);
6125
6123 spin_lock(&kvm->mmu_lock); 6126 spin_lock(&kvm->mmu_lock);
6124 if (!kvm->arch.n_requested_mmu_pages) { 6127 if (nr_mmu_pages)
6125 unsigned int nr_mmu_pages = kvm_mmu_calculate_mmu_pages(kvm);
6126 kvm_mmu_change_mmu_pages(kvm, nr_mmu_pages); 6128 kvm_mmu_change_mmu_pages(kvm, nr_mmu_pages);
6127 }
6128
6129 kvm_mmu_slot_remove_write_access(kvm, mem->slot); 6129 kvm_mmu_slot_remove_write_access(kvm, mem->slot);
6130 spin_unlock(&kvm->mmu_lock); 6130 spin_unlock(&kvm->mmu_lock);
6131} 6131}