aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/vhost/test.c
diff options
context:
space:
mode:
Diffstat (limited to 'drivers/vhost/test.c')
-rw-r--r--drivers/vhost/test.c13
1 files changed, 9 insertions, 4 deletions
diff --git a/drivers/vhost/test.c b/drivers/vhost/test.c
index 9e90e969af55..7804869c6a31 100644
--- a/drivers/vhost/test.c
+++ b/drivers/vhost/test.c
@@ -22,6 +22,12 @@
22 * Using this limit prevents one virtqueue from starving others. */ 22 * Using this limit prevents one virtqueue from starving others. */
23#define VHOST_TEST_WEIGHT 0x80000 23#define VHOST_TEST_WEIGHT 0x80000
24 24
25/* Max number of packets transferred before requeueing the job.
26 * Using this limit prevents one virtqueue from starving others with
27 * pkts.
28 */
29#define VHOST_TEST_PKT_WEIGHT 256
30
25enum { 31enum {
26 VHOST_TEST_VQ = 0, 32 VHOST_TEST_VQ = 0,
27 VHOST_TEST_VQ_MAX = 1, 33 VHOST_TEST_VQ_MAX = 1,
@@ -80,10 +86,8 @@ static void handle_vq(struct vhost_test *n)
80 } 86 }
81 vhost_add_used_and_signal(&n->dev, vq, head, 0); 87 vhost_add_used_and_signal(&n->dev, vq, head, 0);
82 total_len += len; 88 total_len += len;
83 if (unlikely(total_len >= VHOST_TEST_WEIGHT)) { 89 if (unlikely(vhost_exceeds_weight(vq, 0, total_len)))
84 vhost_poll_queue(&vq->poll);
85 break; 90 break;
86 }
87 } 91 }
88 92
89 mutex_unlock(&vq->mutex); 93 mutex_unlock(&vq->mutex);
@@ -115,7 +119,8 @@ static int vhost_test_open(struct inode *inode, struct file *f)
115 dev = &n->dev; 119 dev = &n->dev;
116 vqs[VHOST_TEST_VQ] = &n->vqs[VHOST_TEST_VQ]; 120 vqs[VHOST_TEST_VQ] = &n->vqs[VHOST_TEST_VQ];
117 n->vqs[VHOST_TEST_VQ].handle_kick = handle_vq_kick; 121 n->vqs[VHOST_TEST_VQ].handle_kick = handle_vq_kick;
118 vhost_dev_init(dev, vqs, VHOST_TEST_VQ_MAX); 122 vhost_dev_init(dev, vqs, VHOST_TEST_VQ_MAX, UIO_MAXIOV,
123 VHOST_TEST_PKT_WEIGHT, VHOST_TEST_WEIGHT);
119 124
120 f->private_data = n; 125 f->private_data = n;
121 126