@@ -11609,22 +11609,24 @@ void kvm_arch_commit_memory_region(struct kvm *kvm,
const struct kvm_memory_slot *new,
enum kvm_mr_change change)
{
- if (change == KVM_MR_CREATE)
- kvm->arch.n_memslots_pages += new->npages;
- else if (change == KVM_MR_DELETE) {
- WARN_ON(kvm->arch.n_memslots_pages < old->npages);
- kvm->arch.n_memslots_pages -= old->npages;
- }
-
- if (!kvm->arch.n_requested_mmu_pages) {
- u64 memslots_pages;
- unsigned long nr_mmu_pages;
-
- memslots_pages = kvm->arch.n_memslots_pages * KVM_PERMILLE_MMU_PAGES;
- do_div(memslots_pages, 1000);
- nr_mmu_pages = max_t(typeof(nr_mmu_pages),
- memslots_pages, KVM_MIN_ALLOC_MMU_PAGES);
- kvm_mmu_change_mmu_pages(kvm, nr_mmu_pages);
+ if (change == KVM_MR_CREATE || change == KVM_MR_DELETE) {
+ if (change == KVM_MR_CREATE)
+ kvm->arch.n_memslots_pages += new->npages;
+ else {
+ WARN_ON(kvm->arch.n_memslots_pages < old->npages);
+ kvm->arch.n_memslots_pages -= old->npages;
+ }
+
+ if (!kvm->arch.n_requested_mmu_pages) {
+ u64 memslots_pages;
+ unsigned long nr_mmu_pages;
+
+ memslots_pages = kvm->arch.n_memslots_pages * KVM_PERMILLE_MMU_PAGES;
+ do_div(memslots_pages, 1000);
+ nr_mmu_pages = max_t(typeof(nr_mmu_pages),
+ memslots_pages, KVM_MIN_ALLOC_MMU_PAGES);
+ kvm_mmu_change_mmu_pages(kvm, nr_mmu_pages);
+ }
}
kvm_mmu_slot_apply_flags(kvm, old, new, change);