diff options
author | Jason Wang <jasowang@redhat.com> | 2016-03-04 06:24:51 -0500 |
---|---|---|
committer | Michael S. Tsirkin <mst@redhat.com> | 2016-03-10 19:18:45 -0500 |
commit | 526d3e7ff515582eaf7cf5d9da2a11bf681204e6 (patch) | |
tree | 0f8cb97f616c8b09c1c8dd90530006581b26a3da /drivers/vhost | |
parent | fd0e21c31e1e6383af978239d07ced6e4e5d82c3 (diff) |
vhost: introduce vhost_has_work()
This path introduces a helper which can give a hint for whether or not
there's a work queued in the work list. This could be used for busy
polling code to exit the busy loop.
Signed-off-by: Jason Wang <jasowang@redhat.com>
Signed-off-by: Michael S. Tsirkin <mst@redhat.com>
Diffstat (limited to 'drivers/vhost')
-rw-r--r-- | drivers/vhost/vhost.c | 7 | ||||
-rw-r--r-- | drivers/vhost/vhost.h | 1 |
2 files changed, 8 insertions, 0 deletions
diff --git a/drivers/vhost/vhost.c b/drivers/vhost/vhost.c index 328c54ab0154..596de212fe7e 100644 --- a/drivers/vhost/vhost.c +++ b/drivers/vhost/vhost.c | |||
@@ -263,6 +263,13 @@ void vhost_work_queue(struct vhost_dev *dev, struct vhost_work *work) | |||
263 | } | 263 | } |
264 | EXPORT_SYMBOL_GPL(vhost_work_queue); | 264 | EXPORT_SYMBOL_GPL(vhost_work_queue); |
265 | 265 | ||
266 | /* A lockless hint for busy polling code to exit the loop */ | ||
267 | bool vhost_has_work(struct vhost_dev *dev) | ||
268 | { | ||
269 | return !list_empty(&dev->work_list); | ||
270 | } | ||
271 | EXPORT_SYMBOL_GPL(vhost_has_work); | ||
272 | |||
266 | void vhost_poll_queue(struct vhost_poll *poll) | 273 | void vhost_poll_queue(struct vhost_poll *poll) |
267 | { | 274 | { |
268 | vhost_work_queue(poll->dev, &poll->work); | 275 | vhost_work_queue(poll->dev, &poll->work); |
diff --git a/drivers/vhost/vhost.h b/drivers/vhost/vhost.h index 8f0dd0d915d4..eef33b11a7ed 100644 --- a/drivers/vhost/vhost.h +++ b/drivers/vhost/vhost.h | |||
@@ -37,6 +37,7 @@ struct vhost_poll { | |||
37 | 37 | ||
38 | void vhost_work_init(struct vhost_work *work, vhost_work_fn_t fn); | 38 | void vhost_work_init(struct vhost_work *work, vhost_work_fn_t fn); |
39 | void vhost_work_queue(struct vhost_dev *dev, struct vhost_work *work); | 39 | void vhost_work_queue(struct vhost_dev *dev, struct vhost_work *work); |
40 | bool vhost_has_work(struct vhost_dev *dev); | ||
40 | 41 | ||
41 | void vhost_poll_init(struct vhost_poll *poll, vhost_work_fn_t fn, | 42 | void vhost_poll_init(struct vhost_poll *poll, vhost_work_fn_t fn, |
42 | unsigned long mask, struct vhost_dev *dev); | 43 | unsigned long mask, struct vhost_dev *dev); |