Commit 7ec4fb44962f611241bcb974fa97c5f49ddcb2f1
1 parent
f924d66d27
Exists in
smarc-l5.0.0_1.0.0-ga
and in
5 other branches
KVM: move the code that installs new slots array to a separate function.
Move repetitive code sequence to a separate function. Reviewed-by: Alex Williamson <alex.williamson@redhat.com> Signed-off-by: Gleb Natapov <gleb@redhat.com>
Showing 1 changed file with 13 additions and 8 deletions Side-by-side Diff
virt/kvm/kvm_main.c
... | ... | @@ -702,6 +702,17 @@ |
702 | 702 | return 0; |
703 | 703 | } |
704 | 704 | |
705 | +static struct kvm_memslots *install_new_memslots(struct kvm *kvm, | |
706 | + struct kvm_memslots *slots, struct kvm_memory_slot *new) | |
707 | +{ | |
708 | + struct kvm_memslots *old_memslots = kvm->memslots; | |
709 | + | |
710 | + update_memslots(slots, new, kvm->memslots->generation); | |
711 | + rcu_assign_pointer(kvm->memslots, slots); | |
712 | + synchronize_srcu_expedited(&kvm->srcu); | |
713 | + return old_memslots; | |
714 | +} | |
715 | + | |
705 | 716 | /* |
706 | 717 | * Allocate some memory and give it an address in the guest physical address |
707 | 718 | * space. |
708 | 719 | |
... | ... | @@ -820,11 +831,8 @@ |
820 | 831 | slot = id_to_memslot(slots, mem->slot); |
821 | 832 | slot->flags |= KVM_MEMSLOT_INVALID; |
822 | 833 | |
823 | - update_memslots(slots, NULL, kvm->memslots->generation); | |
834 | + old_memslots = install_new_memslots(kvm, slots, NULL); | |
824 | 835 | |
825 | - old_memslots = kvm->memslots; | |
826 | - rcu_assign_pointer(kvm->memslots, slots); | |
827 | - synchronize_srcu_expedited(&kvm->srcu); | |
828 | 836 | /* slot was deleted or moved, clear iommu mapping */ |
829 | 837 | kvm_iommu_unmap_pages(kvm, &old); |
830 | 838 | /* From this point no new shadow pages pointing to a deleted, |
... | ... | @@ -868,10 +876,7 @@ |
868 | 876 | memset(&new.arch, 0, sizeof(new.arch)); |
869 | 877 | } |
870 | 878 | |
871 | - update_memslots(slots, &new, kvm->memslots->generation); | |
872 | - old_memslots = kvm->memslots; | |
873 | - rcu_assign_pointer(kvm->memslots, slots); | |
874 | - synchronize_srcu_expedited(&kvm->srcu); | |
879 | + old_memslots = install_new_memslots(kvm, slots, &new); | |
875 | 880 | |
876 | 881 | kvm_arch_commit_memory_region(kvm, mem, old, user_alloc); |
877 | 882 |