Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > linux.kernel > #1741121

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

From Willem de Bruijn <willemdebruijn.kernel@gmail.com>
Newsgroups linux.kernel
Subject Re: [PATCH net-next RFC 3/5] vhost: introduce vhost_add_used_idx()
Date 2017-09-28 03:10 +0200
Message-ID <uuvuW-2ck-1@gated-at.bofh.it> (permalink)
References <usrc5-3JR-5@gated-at.bofh.it> <usrc6-3JR-15@gated-at.bofh.it> <uu3yG-my-21@gated-at.bofh.it> <uu8yl-3sG-1@gated-at.bofh.it> <uutt7-J2-5@gated-at.bofh.it>
Organization linux.* mail to news gateway

Show all headers | View raw


>> > > @@ -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.

Back to linux.kernel | Previous | NextPrevious in thread | Next in thread | Find similar | Unroll thread


Thread

Re: [PATCH net-next RFC 3/5] vhost: introduce vhost_add_used_idx() "Michael S. Tsirkin" <mst@redhat.com> - 2017-09-26 21:20 +0200
  Re: [PATCH net-next RFC 3/5] vhost: introduce vhost_add_used_idx() Jason Wang <jasowang@redhat.com> - 2017-09-27 02:40 +0200
    Re: [PATCH net-next RFC 3/5] vhost: introduce vhost_add_used_idx() "Michael S. Tsirkin" <mst@redhat.com> - 2017-09-28 01:00 +0200
      Re: [PATCH net-next RFC 3/5] vhost: introduce vhost_add_used_idx() Willem de Bruijn <willemdebruijn.kernel@gmail.com> - 2017-09-28 03:10 +0200
      Re: [PATCH net-next RFC 3/5] vhost: introduce vhost_add_used_idx() Jason Wang <jasowang@redhat.com> - 2017-09-28 09:20 +0200

csiph-web