aboutsummaryrefslogtreecommitdiffstats
path: root/virt/kvm
diff options
context:
space:
mode:
authorAvi Kivity <avi@redhat.com>2009-06-04 11:09:08 -0400
committerAvi Kivity <avi@redhat.com>2009-09-10 01:32:47 -0400
commit105f8d40a737564100dc7dcd1d94d4e15fada20e (patch)
treecf94ec090c8a8677acfd312cbdf262f0321363eb /virt/kvm
parent596ae895653fe336b9b5815ad2c175d22bb26f21 (diff)
KVM: Calculate available entries in coalesced mmio ring
Instead of checking whether we'll wrap around, calculate how many entries are available, and check whether we have enough (just one) for the pending mmio. By itself, this doesn't change anything, but it paves the way for making this function lockless. Signed-off-by: Avi Kivity <avi@redhat.com>
Diffstat (limited to 'virt/kvm')
-rw-r--r--virt/kvm/coalesced_mmio.c10
1 files changed, 5 insertions, 5 deletions
diff --git a/virt/kvm/coalesced_mmio.c b/virt/kvm/coalesced_mmio.c
index c4c7ec2f9d30..754906800999 100644
--- a/virt/kvm/coalesced_mmio.c
+++ b/virt/kvm/coalesced_mmio.c
@@ -24,7 +24,8 @@ static int coalesced_mmio_in_range(struct kvm_io_device *this,
24{ 24{
25 struct kvm_coalesced_mmio_dev *dev = to_mmio(this); 25 struct kvm_coalesced_mmio_dev *dev = to_mmio(this);
26 struct kvm_coalesced_mmio_zone *zone; 26 struct kvm_coalesced_mmio_zone *zone;
27 int next; 27 struct kvm_coalesced_mmio_ring *ring;
28 unsigned avail;
28 int i; 29 int i;
29 30
30 if (!is_write) 31 if (!is_write)
@@ -40,10 +41,9 @@ static int coalesced_mmio_in_range(struct kvm_io_device *this,
40 * check if we don't meet the first used entry 41 * check if we don't meet the first used entry
41 * there is always one unused entry in the buffer 42 * there is always one unused entry in the buffer
42 */ 43 */
43 44 ring = dev->kvm->coalesced_mmio_ring;
44 next = (dev->kvm->coalesced_mmio_ring->last + 1) % 45 avail = (ring->first - ring->last - 1) % KVM_COALESCED_MMIO_MAX;
45 KVM_COALESCED_MMIO_MAX; 46 if (avail < 1) {
46 if (next == dev->kvm->coalesced_mmio_ring->first) {
47 /* full */ 47 /* full */
48 return 0; 48 return 0;
49 } 49 }