Skip to contentSkip to conversation

virtio: Dont add "config" to list for !per_vq_vector

RFC PATCH Applied Krishna Kumar 3 participants 3 messages Oct 5, 2011 – Oct 6, 2011

Subsystems (3)
lore
Share & tools
lore
#0 lore raw

RFC PATCH 1/1 virtio: Dont add "config" to list for !per_vq_vector

For the MSI but non-per_vq_vector case, the config/change vq also gets added to the list of vqs that need to process the MSI interrupt. This is not needed as config has it's own handler (vp_config_changed). In any case, vring_interrupt() finds nothing needs to be done on this vq.

I tested this patch by testing the "Fallback:" and "Finally fall back" cases in vp_find_vqs(). Please review.

---
 drivers/virtio/virtio_pci.c |   10 +++++++---
 1 file changed, 7 insertions(+), 3 deletions(-)
drivers/virtio/virtio_pci.c +7 -3
diff -ruNp org/drivers/virtio/virtio_pci.c new/drivers/virtio/virtio_pci.c
@@ -415,9 +415,13 @@ static struct virtqueue *setup_vq(struct
 		}
 	}
 
-	spin_lock_irqsave(&vp_dev->lock, flags);
-	list_add(&info->node, &vp_dev->virtqueues);
-	spin_unlock_irqrestore(&vp_dev->lock, flags);
+	if (callback) {
+		spin_lock_irqsave(&vp_dev->lock, flags);
+		list_add(&info->node, &vp_dev->virtqueues);
+		spin_unlock_irqrestore(&vp_dev->lock, flags);
+	} else {
+		INIT_LIST_HEAD(&info->node);
+	}
 
 	return vq;
maintainer Acked-by on v1 1/1
#1 lore raw
Quoted 10 lines · Krishna Kumar

For the MSI but non-per_vq_vector case, the config/change vq also gets added to the list of vqs that need to process the MSI interrupt. This is not needed as config has it's own handler (vp_config_changed). In any case, vring_interrupt() finds nothing needs to be done on this vq.

I tested this patch by testing the "Fallback:" and "Finally fall back" cases in vp_find_vqs(). Please review.

(note: this is not a bugfix so not 3.1 material).

Quoted 13 lines
---
 drivers/virtio/virtio_pci.c |   10 +++++++---
 1 file changed, 7 insertions(+), 3 deletions(-)

diff -ruNp org/drivers/virtio/virtio_pci.c new/drivers/virtio/virtio_pci.c

drivers/virtio/virtio_pci.c +0 -2
@@ -415,9 +415,13 @@ static struct virtqueue *setup_vq(struct
 		}
 	}
 
-	spin_lock_irqsave(&vp_dev->lock, flags);
-	list_add(&info->node, &vp_dev->virtqueues);

drivers/virtio/virtio_pci.c static struct virtqueue *setup_vq(struct · line 426

Quoted 10 lines
drivers/virtio/virtio_pci.c +7 -1
-	spin_unlock_irqrestore(&vp_dev->lock, flags);
+	if (callback) {
+		spin_lock_irqsave(&vp_dev->lock, flags);
+		list_add(&info->node, &vp_dev->virtqueues);
+		spin_unlock_irqrestore(&vp_dev->lock, flags);
+	} else {
+		INIT_LIST_HEAD(&info->node);
+	}
 
 	return vq;

Some further enhancement suggestions for this shared case:
- we don't really need a lock, do we? and how about replacing vq list with an array?
- vring_interrupt calls

        if (!more_used(vq))

outside any lock.
This looks scary - don't we need a read barrier somewhere?

Signature · 1 line
MST
#2 lore raw
Quoted 7 lines · Michael S. Tsirkin
Quoted 6 lines · Krishna Kumar

For the MSI but non-per_vq_vector case, the config/change vq also gets added to the list of vqs that need to process the MSI interrupt. This is not needed as config has it's own handler (vp_config_changed). In any case, vring_interrupt() finds nothing needs to be done on this vq.

Quoted 7 lines
Quoted 4 lines

I tested this patch by testing the "Fallback:" and "Finally fall back" cases in vp_find_vqs(). Please review.

(note: this is not a bugfix so not 3.1 material).

Thanks, applied.

Cheers,
Rusty.