[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[RFC PATCH 17/27] vhost: add vhost_vring_set_notification_rcu
From: |
Eugenio Pérez |
Subject: |
[RFC PATCH 17/27] vhost: add vhost_vring_set_notification_rcu |
Date: |
Fri, 20 Nov 2020 19:50:55 +0100 |
Signed-off-by: Eugenio Pérez <eperezma@redhat.com>
---
hw/virtio/vhost-sw-lm-ring.h | 4 ++++
hw/virtio/vhost-sw-lm-ring.c | 23 +++++++++++++++++++++++
2 files changed, 27 insertions(+)
diff --git a/hw/virtio/vhost-sw-lm-ring.h b/hw/virtio/vhost-sw-lm-ring.h
index 29d21feaf4..c537500d9e 100644
--- a/hw/virtio/vhost-sw-lm-ring.h
+++ b/hw/virtio/vhost-sw-lm-ring.h
@@ -19,6 +19,10 @@ typedef struct VhostShadowVirtqueue VhostShadowVirtqueue;
bool vhost_vring_kick(VhostShadowVirtqueue *vq);
int vhost_vring_add(VhostShadowVirtqueue *vq, VirtQueueElement *elem);
+
+/* Called within rcu_read_lock(). */
+void vhost_vring_set_notification_rcu(VhostShadowVirtqueue *vq, bool enable);
+
void vhost_vring_write_addr(const VhostShadowVirtqueue *vq,
struct vhost_vring_addr *addr);
diff --git a/hw/virtio/vhost-sw-lm-ring.c b/hw/virtio/vhost-sw-lm-ring.c
index aed005c2d9..c3244c550e 100644
--- a/hw/virtio/vhost-sw-lm-ring.c
+++ b/hw/virtio/vhost-sw-lm-ring.c
@@ -34,6 +34,9 @@ typedef struct VhostShadowVirtqueue {
/* Next free descriptor */
uint16_t free_head;
+ /* Cache for exposed notification flag */
+ bool notification;
+
vring_desc_t descs[];
} VhostShadowVirtqueue;
@@ -60,6 +63,26 @@ bool vhost_vring_kick(VhostShadowVirtqueue *vq)
: true;
}
+void vhost_vring_set_notification_rcu(VhostShadowVirtqueue *vq, bool enable)
+{
+ uint16_t notification_flag;
+
+ if (vq->notification == enable) {
+ return;
+ }
+
+ notification_flag = virtio_tswap16(vq->vdev, VRING_AVAIL_F_NO_INTERRUPT);
+
+ vq->notification = enable;
+ if (enable) {
+ vq->vring.avail->flags &= ~notification_flag;
+ } else {
+ vq->vring.avail->flags |= notification_flag;
+ }
+
+ smp_mb();
+}
+
static void vhost_vring_write_descs(VhostShadowVirtqueue *vq,
const struct iovec *iovec,
size_t num, bool more_descs, bool write)
--
2.18.4
- [RFC PATCH 07/27] vhost: Route guest->host notification through qemu, (continued)
- [RFC PATCH 07/27] vhost: Route guest->host notification through qemu, Eugenio Pérez, 2020/11/20
- [RFC PATCH 08/27] vhost: Add a flag for software assisted Live Migration, Eugenio Pérez, 2020/11/20
- [RFC PATCH 09/27] vhost: Route host->guest notification through qemu, Eugenio Pérez, 2020/11/20
- [RFC PATCH 10/27] vhost: Allocate shadow vring, Eugenio Pérez, 2020/11/20
- [RFC PATCH 11/27] virtio: const-ify all virtio_tswap* functions, Eugenio Pérez, 2020/11/20
- [RFC PATCH 12/27] virtio: Add virtio_queue_full, Eugenio Pérez, 2020/11/20
- [RFC PATCH 13/27] vhost: Send buffers to device, Eugenio Pérez, 2020/11/20
- [RFC PATCH 14/27] virtio: Remove virtio_queue_get_used_notify_split, Eugenio Pérez, 2020/11/20
- [RFC PATCH 15/27] vhost: Do not invalidate signalled used, Eugenio Pérez, 2020/11/20
- [RFC PATCH 16/27] virtio: Expose virtqueue_alloc_element, Eugenio Pérez, 2020/11/20
- [RFC PATCH 17/27] vhost: add vhost_vring_set_notification_rcu,
Eugenio Pérez <=
- [RFC PATCH 18/27] vhost: add vhost_vring_poll_rcu, Eugenio Pérez, 2020/11/20
- [RFC PATCH 19/27] vhost: add vhost_vring_get_buf_rcu, Eugenio Pérez, 2020/11/20
- [RFC PATCH 20/27] vhost: Return used buffers, Eugenio Pérez, 2020/11/20
- [RFC PATCH 21/27] vhost: Add vhost_virtqueue_memory_unmap, Eugenio Pérez, 2020/11/20
- [RFC PATCH 22/27] vhost: Add vhost_virtqueue_memory_map, Eugenio Pérez, 2020/11/20
- [RFC PATCH 23/27] vhost: unmap qemu's shadow virtqueues on sw live migration, Eugenio Pérez, 2020/11/20
- [RFC PATCH 24/27] vhost: iommu changes, Eugenio Pérez, 2020/11/20
- [RFC PATCH 25/27] vhost: Do not commit vhost used idx on vhost_virtqueue_stop, Eugenio Pérez, 2020/11/20