Commit 35c51e09 authored by Xianting Tian's avatar Xianting Tian Committed by Michael S. Tsirkin

virtio_ring: remove unnecessary to_vvq call in vring hot path

It passes '_vq' to virtqueue_use_indirect(), which still calls
to_vvq to get 'vq', let's directly pass 'vq'. It can avoid
unnecessary call of to_vvq in hot path.
Signed-off-by: default avatarXianting Tian <xianting.tian@linux.alibaba.com>
Message-Id: <20220328105817.1028065-1-xianting.tian@linux.alibaba.com>
Signed-off-by: default avatarMichael S. Tsirkin <mst@redhat.com>
Acked-by: default avatarJason Wang <jasowang@redhat.com>
Reviewed-by: default avatarStefano Garzarella <sgarzare@redhat.com>
parent 0e9911fa
...@@ -205,11 +205,9 @@ struct vring_virtqueue { ...@@ -205,11 +205,9 @@ struct vring_virtqueue {
#define to_vvq(_vq) container_of(_vq, struct vring_virtqueue, vq) #define to_vvq(_vq) container_of(_vq, struct vring_virtqueue, vq)
static inline bool virtqueue_use_indirect(struct virtqueue *_vq, static inline bool virtqueue_use_indirect(struct vring_virtqueue *vq,
unsigned int total_sg) unsigned int total_sg)
{ {
struct vring_virtqueue *vq = to_vvq(_vq);
/* /*
* If the host supports indirect descriptor tables, and we have multiple * If the host supports indirect descriptor tables, and we have multiple
* buffers, then go indirect. FIXME: tune this threshold * buffers, then go indirect. FIXME: tune this threshold
...@@ -499,7 +497,7 @@ static inline int virtqueue_add_split(struct virtqueue *_vq, ...@@ -499,7 +497,7 @@ static inline int virtqueue_add_split(struct virtqueue *_vq,
head = vq->free_head; head = vq->free_head;
if (virtqueue_use_indirect(_vq, total_sg)) if (virtqueue_use_indirect(vq, total_sg))
desc = alloc_indirect_split(_vq, total_sg, gfp); desc = alloc_indirect_split(_vq, total_sg, gfp);
else { else {
desc = NULL; desc = NULL;
...@@ -1178,7 +1176,7 @@ static inline int virtqueue_add_packed(struct virtqueue *_vq, ...@@ -1178,7 +1176,7 @@ static inline int virtqueue_add_packed(struct virtqueue *_vq,
BUG_ON(total_sg == 0); BUG_ON(total_sg == 0);
if (virtqueue_use_indirect(_vq, total_sg)) { if (virtqueue_use_indirect(vq, total_sg)) {
err = virtqueue_add_indirect_packed(vq, sgs, total_sg, out_sgs, err = virtqueue_add_indirect_packed(vq, sgs, total_sg, out_sgs,
in_sgs, data, gfp); in_sgs, data, gfp);
if (err != -ENOMEM) { if (err != -ENOMEM) {
......
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