|
@@ -44,6 +44,10 @@ MODULE_PARM_DESC(experimental_zcopytx, "Enable Zero Copy TX;"
|
|
|
* Using this limit prevents one virtqueue from starving others. */
|
|
|
#define VHOST_NET_WEIGHT 0x80000
|
|
|
|
|
|
+/* Max number of packets transferred before requeueing the job.
|
|
|
+ * Using this limit prevents one virtqueue from starving rx. */
|
|
|
+#define VHOST_NET_PKT_WEIGHT(vq) ((vq)->num * 2)
|
|
|
+
|
|
|
/* MAX number of TX used buffers for outstanding zerocopy */
|
|
|
#define VHOST_MAX_PEND 128
|
|
|
#define VHOST_GOODCOPY_LEN 256
|
|
@@ -473,6 +477,7 @@ static void handle_tx(struct vhost_net *net)
|
|
|
struct socket *sock;
|
|
|
struct vhost_net_ubuf_ref *uninitialized_var(ubufs);
|
|
|
bool zcopy, zcopy_used;
|
|
|
+ int sent_pkts = 0;
|
|
|
|
|
|
mutex_lock(&vq->mutex);
|
|
|
sock = vq->private_data;
|
|
@@ -580,7 +585,8 @@ static void handle_tx(struct vhost_net *net)
|
|
|
else
|
|
|
vhost_zerocopy_signal_used(net, vq);
|
|
|
vhost_net_tx_packet(net);
|
|
|
- if (unlikely(total_len >= VHOST_NET_WEIGHT)) {
|
|
|
+ if (unlikely(total_len >= VHOST_NET_WEIGHT) ||
|
|
|
+ unlikely(++sent_pkts >= VHOST_NET_PKT_WEIGHT(vq))) {
|
|
|
vhost_poll_queue(&vq->poll);
|
|
|
break;
|
|
|
}
|