diff options
author | Jason Wang <jasowang@redhat.com> | 2019-05-17 00:29:49 -0400 |
---|---|---|
committer | Michael S. Tsirkin <mst@redhat.com> | 2019-05-27 11:08:22 -0400 |
commit | e82b9b0727ff6d665fff2d326162b460dded554d (patch) | |
tree | c88a7558ef9b90b1de6415a9cf99bb0206b71fad /drivers/vhost/vhost.h | |
parent | 6166e5330c3828699859a6ec1af21eef7c58778c (diff) |
vhost: introduce vhost_exceeds_weight()
We used to have vhost_exceeds_weight() for vhost-net to:
- prevent vhost kthread from hogging the cpu
- balance the time spent between TX and RX
This function could be useful for vsock and scsi as well. So move it
to vhost.c. Device must specify a weight which counts the number of
requests, or it can also specific a byte_weight which counts the
number of bytes that has been processed.
Signed-off-by: Jason Wang <jasowang@redhat.com>
Reviewed-by: Stefan Hajnoczi <stefanha@redhat.com>
Signed-off-by: Michael S. Tsirkin <mst@redhat.com>
Diffstat (limited to 'drivers/vhost/vhost.h')
-rw-r--r-- | drivers/vhost/vhost.h | 5 |
1 files changed, 4 insertions, 1 deletions
diff --git a/drivers/vhost/vhost.h b/drivers/vhost/vhost.h index 9490e7ddb340..27a78a9b8cc7 100644 --- a/drivers/vhost/vhost.h +++ b/drivers/vhost/vhost.h | |||
@@ -171,10 +171,13 @@ struct vhost_dev { | |||
171 | struct list_head pending_list; | 171 | struct list_head pending_list; |
172 | wait_queue_head_t wait; | 172 | wait_queue_head_t wait; |
173 | int iov_limit; | 173 | int iov_limit; |
174 | int weight; | ||
175 | int byte_weight; | ||
174 | }; | 176 | }; |
175 | 177 | ||
178 | bool vhost_exceeds_weight(struct vhost_virtqueue *vq, int pkts, int total_len); | ||
176 | void vhost_dev_init(struct vhost_dev *, struct vhost_virtqueue **vqs, | 179 | void vhost_dev_init(struct vhost_dev *, struct vhost_virtqueue **vqs, |
177 | int nvqs, int iov_limit); | 180 | int nvqs, int iov_limit, int weight, int byte_weight); |
178 | long vhost_dev_set_owner(struct vhost_dev *dev); | 181 | long vhost_dev_set_owner(struct vhost_dev *dev); |
179 | bool vhost_dev_has_owner(struct vhost_dev *dev); | 182 | bool vhost_dev_has_owner(struct vhost_dev *dev); |
180 | long vhost_dev_check_owner(struct vhost_dev *); | 183 | long vhost_dev_check_owner(struct vhost_dev *); |