Thread (35 messages) 35 messages, 4 authors, 2017-09-28

Re: [PATCH net-next RFC 3/5] vhost: introduce vhost_add_used_idx()

From: Willem de Bruijn <willemdebruijn.kernel@gmail.com>
Date: 2017-09-28 01:00:36
Also in: kvm, lkml

quoted
quoted
quoted
@@ -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.
Keyboard shortcuts
hback out one level
jnext message in thread
kprevious message in thread
ldrill in
Escclose help / fold thread tree
?toggle this help