Skip to content

Commit 9d098a6

Browse files
committed
Merge tag 'for_linus' of git://git.kernel.org/pub/scm/linux/kernel/git/mst/vhost
Pull virtio fixes from Michael Tsirkin: "virtio, vhost, and balloon bugfixes. A couple of last minute bugfixes. And a revert of a failed attempt at metadata access optimization - we'll try again in the next cycle" * tag 'for_linus' of git://git.kernel.org/pub/scm/linux/kernel/git/mst/vhost: mm/balloon_compaction: suppress allocation warnings Revert "vhost: access vq metadata through kernel virtual address" vhost: Remove unnecessary variable virtio-net: lower min ring num_free for efficiency vhost/test: fix build for vhost test vhost/test: fix build for vhost test
2 parents 13da6ac + 02fa5d7 commit 9d098a6

File tree

5 files changed

+17
-562
lines changed

5 files changed

+17
-562
lines changed

drivers/net/virtio_net.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1331,7 +1331,7 @@ static int virtnet_receive(struct receive_queue *rq, int budget,
13311331
}
13321332
}
13331333

1334-
if (rq->vq->num_free > virtqueue_get_vring_size(rq->vq) / 2) {
1334+
if (rq->vq->num_free > min((unsigned int)budget, virtqueue_get_vring_size(rq->vq)) / 2) {
13351335
if (!try_fill_recv(vi, rq, GFP_ATOMIC))
13361336
schedule_delayed_work(&vi->refill, 0);
13371337
}

drivers/vhost/test.c

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,12 @@
2222
* Using this limit prevents one virtqueue from starving others. */
2323
#define VHOST_TEST_WEIGHT 0x80000
2424

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+
2531
enum {
2632
VHOST_TEST_VQ = 0,
2733
VHOST_TEST_VQ_MAX = 1,
@@ -80,10 +86,8 @@ static void handle_vq(struct vhost_test *n)
8086
}
8187
vhost_add_used_and_signal(&n->dev, vq, head, 0);
8288
total_len += len;
83-
if (unlikely(total_len >= VHOST_TEST_WEIGHT)) {
84-
vhost_poll_queue(&vq->poll);
89+
if (unlikely(vhost_exceeds_weight(vq, 0, total_len)))
8590
break;
86-
}
8791
}
8892

8993
mutex_unlock(&vq->mutex);
@@ -115,7 +119,8 @@ static int vhost_test_open(struct inode *inode, struct file *f)
115119
dev = &n->dev;
116120
vqs[VHOST_TEST_VQ] = &n->vqs[VHOST_TEST_VQ];
117121
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);
119124

120125
f->private_data = n;
121126

0 commit comments

Comments
 (0)