diff options
author | Marcelo Tosatti <mtosatti@redhat.com> | 2009-12-23 11:35:21 -0500 |
---|---|---|
committer | Marcelo Tosatti <mtosatti@redhat.com> | 2010-03-01 10:35:44 -0500 |
commit | bc6678a33d9b952981a8e44a4f876c3ad64ca4d8 (patch) | |
tree | e26027179eb0d76f234509145a395dd6e5910074 /virt/kvm/assigned-dev.c | |
parent | 3ad26d8139a82b0510b1e0435ee82ae461d33401 (diff) |
KVM: introduce kvm->srcu and convert kvm_set_memory_region to SRCU update
Use two steps for memslot deletion: mark the slot invalid (which stops
instantiation of new shadow pages for that slot, but allows destruction),
then instantiate the new empty slot.
Also simplifies kvm_handle_hva locking.
Signed-off-by: Marcelo Tosatti <mtosatti@redhat.com>
Diffstat (limited to 'virt/kvm/assigned-dev.c')
-rw-r--r-- | virt/kvm/assigned-dev.c | 8 |
1 files changed, 4 insertions, 4 deletions
diff --git a/virt/kvm/assigned-dev.c b/virt/kvm/assigned-dev.c index f73de631e3ee..f51e684dd238 100644 --- a/virt/kvm/assigned-dev.c +++ b/virt/kvm/assigned-dev.c | |||
@@ -504,12 +504,12 @@ out: | |||
504 | static int kvm_vm_ioctl_assign_device(struct kvm *kvm, | 504 | static int kvm_vm_ioctl_assign_device(struct kvm *kvm, |
505 | struct kvm_assigned_pci_dev *assigned_dev) | 505 | struct kvm_assigned_pci_dev *assigned_dev) |
506 | { | 506 | { |
507 | int r = 0; | 507 | int r = 0, idx; |
508 | struct kvm_assigned_dev_kernel *match; | 508 | struct kvm_assigned_dev_kernel *match; |
509 | struct pci_dev *dev; | 509 | struct pci_dev *dev; |
510 | 510 | ||
511 | mutex_lock(&kvm->lock); | 511 | mutex_lock(&kvm->lock); |
512 | down_read(&kvm->slots_lock); | 512 | idx = srcu_read_lock(&kvm->srcu); |
513 | 513 | ||
514 | match = kvm_find_assigned_dev(&kvm->arch.assigned_dev_head, | 514 | match = kvm_find_assigned_dev(&kvm->arch.assigned_dev_head, |
515 | assigned_dev->assigned_dev_id); | 515 | assigned_dev->assigned_dev_id); |
@@ -573,7 +573,7 @@ static int kvm_vm_ioctl_assign_device(struct kvm *kvm, | |||
573 | } | 573 | } |
574 | 574 | ||
575 | out: | 575 | out: |
576 | up_read(&kvm->slots_lock); | 576 | srcu_read_unlock(&kvm->srcu, idx); |
577 | mutex_unlock(&kvm->lock); | 577 | mutex_unlock(&kvm->lock); |
578 | return r; | 578 | return r; |
579 | out_list_del: | 579 | out_list_del: |
@@ -585,7 +585,7 @@ out_put: | |||
585 | pci_dev_put(dev); | 585 | pci_dev_put(dev); |
586 | out_free: | 586 | out_free: |
587 | kfree(match); | 587 | kfree(match); |
588 | up_read(&kvm->slots_lock); | 588 | srcu_read_unlock(&kvm->srcu, idx); |
589 | mutex_unlock(&kvm->lock); | 589 | mutex_unlock(&kvm->lock); |
590 | return r; | 590 | return r; |
591 | } | 591 | } |