History

vhost: introduce vhost_vq_avail_empty()

This patch introduces a helper which will return true if we're sure that the available ring is empty for a specific vq. When we're not sure, e.g vq access failure, return false instead. This could be used for busy polling code to exit the busy loop.

Jason Wang committed 10 years ago

Commit d4a60601 parent 526d3e72 files · +15 −0Browse files

Unified · Split

2 files
  1. drivers/vhost/vhost.c +14 −0
  2. drivers/vhost/vhost.h +1 −0
drivers/vhost/vhost.c+14−0
@@ -1658,6 +1658,20 @@ void vhost_add_used_and_signal_n(struct vhost_dev *dev, · 1657 unmodified lines
16581658 }
16591659 EXPORT_SYMBOL_GPL(vhost_add_used_and_signal_n);
16601660
1661+/* return true if we're sure that avaiable ring is empty */
1662+bool vhost_vq_avail_empty(struct vhost_dev *dev, struct vhost_virtqueue *vq)
1663+{
1664+ __virtio16 avail_idx;
1665+ int r;
1666+
1667+ r = __get_user(avail_idx, &vq->avail->idx);
1668+ if (r)
1669+ return false;
1670+
1671+ return vhost16_to_cpu(vq, avail_idx) == vq->avail_idx;
1672+}
1673+EXPORT_SYMBOL_GPL(vhost_vq_avail_empty);
1674+
16611675 /* OK, now we need to know about added descriptors. */
16621676 bool vhost_enable_notify(struct vhost_dev *dev, struct vhost_virtqueue *vq)
16631677 {
drivers/vhost/vhost.h+1−0
@@ -159,6 +159,7 @@ void vhost_add_used_and_signal_n(struct vhost_dev *, struct vhost_virtqueue *, · 158 unmodified lines
159159 struct vring_used_elem *heads, unsigned count);
160160 void vhost_signal(struct vhost_dev *, struct vhost_virtqueue *);
161161 void vhost_disable_notify(struct vhost_dev *, struct vhost_virtqueue *);
162+bool vhost_vq_avail_empty(struct vhost_dev *, struct vhost_virtqueue *);
162163 bool vhost_enable_notify(struct vhost_dev *, struct vhost_virtqueue *);
163164
164165 int vhost_log_write(struct vhost_virtqueue *vq, struct vhost_log *log,

Keyboard shortcuts

General

Show keyboard shortcuts
?
Focus the current search
/

Issues and pull requests

Open filters
f

Issues, pull requests and Inbox

Select next item
j↓
Select previous item
k↑
Open selected item
Enter
Dismiss filters or clear selection
Esc

Repository code

Go to file
t