]> git.baikalelectronics.ru Git - kernel.git/commitdiff
virtio_ring: add unlikely annotation for free descs check
authorXianting Tian <xianting.tian@linux.alibaba.com>
Mon, 28 Mar 2022 10:58:17 +0000 (18:58 +0800)
committerMichael S. Tsirkin <mst@redhat.com>
Tue, 31 May 2022 16:44:25 +0000 (12:44 -0400)
The 'if (vq->vq.num_free < descs_used)' check will almost always be false.

Signed-off-by: Xianting Tian <xianting.tian@linux.alibaba.com>
Message-Id: <20220328105817.1028065-2-xianting.tian@linux.alibaba.com>
Signed-off-by: Michael S. Tsirkin <mst@redhat.com>
Acked-by: Jason Wang <jasowang@redhat.com>
Reviewed-by: Stefano Garzarella <sgarzare@redhat.com>
drivers/virtio/virtio_ring.c

index f72d5ae2cd8fd72c84c8d56421073e9c6a28e060..0dc930de72f5adba9ff367138382997b19cb087a 100644 (file)
@@ -517,7 +517,7 @@ static inline int virtqueue_add_split(struct virtqueue *_vq,
                descs_used = total_sg;
        }
 
-       if (vq->vq.num_free < descs_used) {
+       if (unlikely(vq->vq.num_free < descs_used)) {
                pr_debug("Can't add buf len %i - avail = %i\n",
                         descs_used, vq->vq.num_free);
                /* FIXME: for historical reasons, we force a notify here if