linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: "Michael S. Tsirkin" <mst@redhat.com>
To: Jason Wang <jasowang@redhat.com>
Cc: linux-kernel@vger.kernel.org, kvm@vger.kernel.org,
	virtualization@lists.linux-foundation.org,
	netdev@vger.kernel.org, eperezma@redhat.com
Subject: Re: [PATCH RFC v6 02/11] vhost: use batched get_vq_desc version
Date: Thu, 11 Jun 2020 05:06:38 -0400	[thread overview]
Message-ID: <20200611050416-mutt-send-email-mst@kernel.org> (raw)
In-Reply-To: <76b14132-407a-48bf-c4d5-9d0b2c700bb0@redhat.com>

On Thu, Jun 11, 2020 at 11:02:57AM +0800, Jason Wang wrote:
> 
> On 2020/6/10 下午7:05, Michael S. Tsirkin wrote:
> > > > +EXPORT_SYMBOL_GPL(vhost_get_vq_desc);
> > > >    /* Reverse the effect of vhost_get_vq_desc. Useful for error handling. */
> > > >    void vhost_discard_vq_desc(struct vhost_virtqueue *vq, int n)
> > > >    {
> > > > +	unfetch_descs(vq);
> > > >    	vq->last_avail_idx -= n;
> > > So unfetch_descs() has decreased last_avail_idx.
> > > Can we fix this by letting unfetch_descs() return the number and then we can
> > > do:
> > > 
> > > int d = unfetch_descs(vq);
> > > vq->last_avail_idx -= (n > d) ? n - d: 0;
> > > 
> > > Thanks
> > That's intentional I think - we need both.
> 
> 
> Yes, but:
> 
> 
> > 
> > Unfetch_descs drops the descriptors in the cache that were
> > *not returned to caller*  through get_vq_desc.
> > 
> > vhost_discard_vq_desc drops the ones that were returned through get_vq_desc.
> > 
> > Did I miss anything?
> 
> We could count some descriptors twice, consider the case e.g we only cache
> on descriptor:
> 
> fetch_descs()
>     fetch_buf()
>         last_avail_idx++;
> 
> Then we want do discard it:
> vhost_discard_avail_buf(1)
>     unfetch_descs()
>         last_avail_idx--;
>     last_avail_idx -= 1;
> 
> Thanks


I don't think that happens. vhost_discard_avail_buf(1) is only called
after get vhost_get_avail_buf. vhost_get_avail_buf increments
first_desc.  unfetch_descs only counts from first_desc to ndescs.

If I'm wrong, could you show values of first_desc and ndescs in this
scenario?

-- 
MST


  reply	other threads:[~2020-06-11  9:06 UTC|newest]

Thread overview: 20+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-06-08 12:52 [PATCH RFC v6 00/11] vhost: ring format independence Michael S. Tsirkin
2020-06-08 12:52 ` [PATCH RFC v6 01/11] vhost: option to fetch descriptors through an independent struct Michael S. Tsirkin
2020-06-08 12:52 ` [PATCH RFC v6 02/11] vhost: use batched get_vq_desc version Michael S. Tsirkin
2020-06-10  3:14   ` Jason Wang
2020-06-10 11:05     ` Michael S. Tsirkin
2020-06-11  3:02       ` Jason Wang
2020-06-11  9:06         ` Michael S. Tsirkin [this message]
2020-06-15  2:43           ` Jason Wang
2020-06-10 11:24   ` Eugenio Perez Martin
2020-06-08 12:52 ` [PATCH RFC v6 03/11] vhost/net: pass net specific struct pointer Michael S. Tsirkin
2020-06-08 12:53 ` [PATCH RFC v6 04/11] vhost: reorder functions Michael S. Tsirkin
2020-06-08 12:53 ` [PATCH RFC v6 05/11] vhost: format-independent API for used buffers Michael S. Tsirkin
2020-06-08 12:53 ` [PATCH RFC v6 06/11] vhost/net: convert to new API: heads->bufs Michael S. Tsirkin
2020-06-08 12:53 ` [PATCH RFC v6 07/11] vhost/net: avoid iov length math Michael S. Tsirkin
2020-06-08 12:53 ` [PATCH RFC v6 08/11] vhost/test: convert to the buf API Michael S. Tsirkin
2020-06-08 12:53 ` [PATCH RFC v6 09/11] vhost/scsi: switch to buf APIs Michael S. Tsirkin
2020-06-08 12:53 ` [PATCH RFC v6 10/11] vhost/vsock: switch to the buf API Michael S. Tsirkin
2020-06-08 17:08   ` Stefano Garzarella
2020-06-08 12:53 ` [PATCH RFC v6 11/11] vhost: drop head based APIs Michael S. Tsirkin
2020-06-08 17:30 ` [PATCH RFC v6 00/11] vhost: ring format independence Stefano Garzarella

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20200611050416-mutt-send-email-mst@kernel.org \
    --to=mst@redhat.com \
    --cc=eperezma@redhat.com \
    --cc=jasowang@redhat.com \
    --cc=kvm@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=netdev@vger.kernel.org \
    --cc=virtualization@lists.linux-foundation.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).