Skip to content

Commit

Permalink
KVM: switch coalesced mmio changes to slots_lock
Browse files Browse the repository at this point in the history
switch coalesced mmio slots_lock.  slots_lock is already taken for read
everywhere, so we only need to take it for write when changing zones.
This is in preparation to removing in_range and kvm->lock around it.

[avi: fix build]

Signed-off-by: Michael S. Tsirkin <mst@redhat.com>
Signed-off-by: Avi Kivity <avi@redhat.com>
  • Loading branch information
mstsirkin authored and avikivity committed Sep 10, 2009
1 parent 69fa2d7 commit d5c2dcc
Showing 1 changed file with 5 additions and 5 deletions.
10 changes: 5 additions & 5 deletions virt/kvm/coalesced_mmio.c
Original file line number Diff line number Diff line change
Expand Up @@ -115,16 +115,16 @@ int kvm_vm_ioctl_register_coalesced_mmio(struct kvm *kvm,
if (dev == NULL)
return -EINVAL;

mutex_lock(&kvm->lock);
down_write(&kvm->slots_lock);
if (dev->nb_zones >= KVM_COALESCED_MMIO_ZONE_MAX) {
mutex_unlock(&kvm->lock);
up_write(&kvm->slots_lock);
return -ENOBUFS;
}

dev->zone[dev->nb_zones] = *zone;
dev->nb_zones++;

mutex_unlock(&kvm->lock);
up_write(&kvm->slots_lock);
return 0;
}

Expand All @@ -138,7 +138,7 @@ int kvm_vm_ioctl_unregister_coalesced_mmio(struct kvm *kvm,
if (dev == NULL)
return -EINVAL;

mutex_lock(&kvm->lock);
down_write(&kvm->slots_lock);

i = dev->nb_zones;
while(i) {
Expand All @@ -156,7 +156,7 @@ int kvm_vm_ioctl_unregister_coalesced_mmio(struct kvm *kvm,
i--;
}

mutex_unlock(&kvm->lock);
up_write(&kvm->slots_lock);

return 0;
}

0 comments on commit d5c2dcc

Please sign in to comment.