virtualization.lists.linux-foundation.org archive mirror
 help / color / mirror / Atom feed
From: Jason Wang <jasowang@redhat.com>
To: "Michael S. Tsirkin" <mst@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 11:02:57 +0800	[thread overview]
Message-ID: <76b14132-407a-48bf-c4d5-9d0b2c700bb0@redhat.com> (raw)
In-Reply-To: <20200610070259-mutt-send-email-mst@kernel.org>


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

  reply	other threads:[~2020-06-11  3:02 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 [this message]
2020-06-11  9:06         ` Michael S. Tsirkin
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=76b14132-407a-48bf-c4d5-9d0b2c700bb0@redhat.com \
    --to=jasowang@redhat.com \
    --cc=eperezma@redhat.com \
    --cc=kvm@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=mst@redhat.com \
    --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).