>> > > @@ -199,6 +199,7 @@ int __vhost_get_vq_desc(struct vhost_virtqueue *vq, >> > > void vhost_discard_vq_desc(struct vhost_virtqueue *, int n); >> > > int vhost_vq_init_access(struct vhost_virtqueue *); >> > > +int vhost_add_used_idx(struct vhost_virtqueue *vq, int n); >> > > int vhost_add_used(struct vhost_virtqueue *, unsigned int head, int len); >> > > int vhost_add_used_n(struct vhost_virtqueue *, struct vring_used_elem *heads, >> > > unsigned count); >> > Please change the API to hide the fact that there's an index that needs >> > to be updated. >> >> In fact, an interesting optimization on top is just call >> vhost_add_used_idx(vq, n) instead of n vhost_add_used_idx(vq, 1). That's the >> reason I leave n in the API. >> >> Thanks > > Right but you could increment some internal counter in the vq > structure then update the used index using some api > with a generic name, e.g. add_used_complete or something like this. That adds a layer of information hiding. If the same variable can be kept close to the computation in a local variable and passed directly to vhost_add_used_idx_n that is easier to follow.