]> git.karo-electronics.de Git - linux-beck.git/commitdiff
vhost-net: check the support of mergeable buffer outside the receive loop
authorJason Wang <jasowang@redhat.com>
Mon, 17 Jan 2011 08:10:59 +0000 (16:10 +0800)
committerMichael S. Tsirkin <mst@redhat.com>
Sun, 13 Mar 2011 14:57:30 +0000 (16:57 +0200)
No need to check the support of mergeable buffer inside the recevie
loop as the whole handle_rx()_xx is in the read critical region.  So
this patch move it ahead of the receiving loop.

Signed-off-by: Jason Wang <jasowang@redhat.com>
Signed-off-by: Michael S. Tsirkin <mst@redhat.com>
drivers/vhost/net.c

index 59dad9fe52ddc5537d4a167df080e6a813d0470f..9f57cd45fe8ffcd8da040c4b41cb09f77b16a74c 100644 (file)
@@ -411,7 +411,7 @@ static void handle_rx_mergeable(struct vhost_net *net)
                .hdr.gso_type = VIRTIO_NET_HDR_GSO_NONE
        };
        size_t total_len = 0;
-       int err, headcount;
+       int err, headcount, mergeable;
        size_t vhost_hlen, sock_hlen;
        size_t vhost_len, sock_len;
        /* TODO: check that we are running from vhost_worker? */
@@ -427,6 +427,7 @@ static void handle_rx_mergeable(struct vhost_net *net)
 
        vq_log = unlikely(vhost_has_feature(&net->dev, VHOST_F_LOG_ALL)) ?
                vq->log : NULL;
+       mergeable = vhost_has_feature(&net->dev, VIRTIO_NET_F_MRG_RXBUF);
 
        while ((sock_len = peek_head_len(sock->sk))) {
                sock_len += sock_hlen;
@@ -476,7 +477,7 @@ static void handle_rx_mergeable(struct vhost_net *net)
                        break;
                }
                /* TODO: Should check and handle checksum. */
-               if (vhost_has_feature(&net->dev, VIRTIO_NET_F_MRG_RXBUF) &&
+               if (likely(mergeable) &&
                    memcpy_toiovecend(vq->hdr, (unsigned char *)&headcount,
                                      offsetof(typeof(hdr), num_buffers),
                                      sizeof hdr.num_buffers)) {