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
1658}1658}
1659EXPORT_SYMBOL_GPL(vhost_add_used_and_signal_n);1659EXPORT_SYMBOL_GPL(vhost_add_used_and_signal_n);
1660 1660
1661/* return true if we're sure that avaiable ring is empty */
1662bool 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}
1673EXPORT_SYMBOL_GPL(vhost_vq_avail_empty);
1674
1661/* OK, now we need to know about added descriptors. */1675/* OK, now we need to know about added descriptors. */
1662bool vhost_enable_notify(struct vhost_dev *dev, struct vhost_virtqueue *vq)1676bool vhost_enable_notify(struct vhost_dev *dev, struct vhost_virtqueue *vq)
1663{1677{
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
159 struct vring_used_elem *heads, unsigned count);159 struct vring_used_elem *heads, unsigned count);
160void vhost_signal(struct vhost_dev *, struct vhost_virtqueue *);160void vhost_signal(struct vhost_dev *, struct vhost_virtqueue *);
161void vhost_disable_notify(struct vhost_dev *, struct vhost_virtqueue *);161void vhost_disable_notify(struct vhost_dev *, struct vhost_virtqueue *);
162bool vhost_vq_avail_empty(struct vhost_dev *, struct vhost_virtqueue *);
162bool vhost_enable_notify(struct vhost_dev *, struct vhost_virtqueue *);163bool vhost_enable_notify(struct vhost_dev *, struct vhost_virtqueue *);
163 164
164int vhost_log_write(struct vhost_virtqueue *vq, struct vhost_log *log,165int 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