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>
此提交包含在:
@@ -57,6 +57,12 @@
|
||||
#define VHOST_SCSI_PREALLOC_UPAGES 2048
|
||||
#define VHOST_SCSI_PREALLOC_PROT_SGLS 2048
|
||||
|
||||
/* Max number of requests before requeueing the job.
|
||||
* Using this limit prevents one virtqueue from starving others with
|
||||
* request.
|
||||
*/
|
||||
#define VHOST_SCSI_WEIGHT 256
|
||||
|
||||
struct vhost_scsi_inflight {
|
||||
/* Wait for the flush operation to finish */
|
||||
struct completion comp;
|
||||
@@ -1621,7 +1627,8 @@ static int vhost_scsi_open(struct inode *inode, struct file *f)
|
||||
vqs[i] = &vs->vqs[i].vq;
|
||||
vs->vqs[i].vq.handle_kick = vhost_scsi_handle_kick;
|
||||
}
|
||||
vhost_dev_init(&vs->dev, vqs, VHOST_SCSI_MAX_VQ, UIO_MAXIOV);
|
||||
vhost_dev_init(&vs->dev, vqs, VHOST_SCSI_MAX_VQ, UIO_MAXIOV,
|
||||
VHOST_SCSI_WEIGHT, 0);
|
||||
|
||||
vhost_scsi_init_inflight(vs, NULL);
|
||||
|
||||
|
新增問題並參考
封鎖使用者