Commit c92a8a8c authored by Jason Wang's avatar Jason Wang Committed by David S. Miller

vhost_net: introduce tx_can_batch()

Introduce tx_can_batch() to determine whether TX could be
batched. This will help to reduce the code duplication in the future.
Signed-off-by: default avatarJason Wang <jasowang@redhat.com>
Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
parent a2a91a13
...@@ -514,6 +514,12 @@ static int get_tx_bufs(struct vhost_net *net, ...@@ -514,6 +514,12 @@ static int get_tx_bufs(struct vhost_net *net,
return ret; return ret;
} }
static bool tx_can_batch(struct vhost_virtqueue *vq, size_t total_len)
{
return total_len < VHOST_NET_WEIGHT &&
!vhost_vq_avail_empty(vq->dev, vq);
}
/* Expects to be always run from workqueue - which acts as /* Expects to be always run from workqueue - which acts as
* read-size critical section for our kind of RCU. */ * read-size critical section for our kind of RCU. */
static void handle_tx(struct vhost_net *net) static void handle_tx(struct vhost_net *net)
...@@ -598,8 +604,7 @@ static void handle_tx(struct vhost_net *net) ...@@ -598,8 +604,7 @@ static void handle_tx(struct vhost_net *net)
ubufs = NULL; ubufs = NULL;
} }
total_len += len; total_len += len;
if (total_len < VHOST_NET_WEIGHT && if (tx_can_batch(vq, total_len) &&
!vhost_vq_avail_empty(&net->dev, vq) &&
likely(!vhost_exceeds_maxpend(net))) { likely(!vhost_exceeds_maxpend(net))) {
msg.msg_flags |= MSG_MORE; msg.msg_flags |= MSG_MORE;
} else { } else {
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment