Hi Stefan,

On 12/21/2017 05:41 PM, Stefan Hajnoczi wrote:
+int
+rte_vhost_vring_call(int vid, uint16_t vring_idx)
+{
+       struct virtio_net *dev;
+       struct vhost_virtqueue *vq;
+
+       dev = get_device(vid);
+       if (!dev)
+               return -1;
+
+       if (vring_idx >= VHOST_MAX_VRING)
+               return -1;
+
+       vq = dev->virtqueue[vring_idx];
+       if (!vq)
+               return -1;
+
+       /* flush used->idx update before we read avail->flags. */
+       rte_mb();
+
+       /* Kick the guest if necessary. */
+       if (!(vq->avail->flags & VRING_AVAIL_F_NO_INTERRUPT)
+                       && (vq->callfd >= 0))
+               eventfd_write(vq->callfd, (eventfd_t)1);
+       return 0;
+}

I think it may be better to have an internal function that just take the
vq as argument to avoid getting again the vq from the vid & vring index
in the hot path.

Also, this internal function could be tagged as always inlined.

Thanks,
Maxime

Reply via email to