virtualization.lists.linux-foundation.org archive mirror
 help / color / mirror / Atom feed
From: Jason Wang <jasowang@redhat.com>
To: Eugenio Perez Martin <eperezma@redhat.com>
Cc: Laurent Vivier <lvivier@redhat.com>,
	Parav Pandit <parav@mellanox.com>, Cindy Lu <lulu@redhat.com>,
	"Michael S. Tsirkin" <mst@redhat.com>,
	Richard Henderson <richard.henderson@linaro.org>,
	qemu-level <qemu-devel@nongnu.org>,
	Gautam Dawar <gdawar@xilinx.com>,
	Markus Armbruster <armbru@redhat.com>,
	Eduardo Habkost <ehabkost@redhat.com>,
	Harpreet Singh Anand <hanand@xilinx.com>,
	Xiao W Wang <xiao.w.wang@intel.com>,
	Stefan Hajnoczi <stefanha@redhat.com>,
	Eli Cohen <eli@mellanox.com>, Paolo Bonzini <pbonzini@redhat.com>,
	Zhu Lingshan <lingshan.zhu@intel.com>,
	virtualization <virtualization@lists.linux-foundation.org>,
	Eric Blake <eblake@redhat.com>
Subject: Re: [PATCH 09/31] vhost-vdpa: Take into account SVQ in vhost_vdpa_set_vring_call
Date: Mon, 21 Feb 2022 15:39:37 +0800	[thread overview]
Message-ID: <bccdecdd-fa2d-48c0-43b8-7afe7b230b7b@redhat.com> (raw)
In-Reply-To: <CAJaqyWeisXmZ9+xw2Rj50K7aKx4khNZZjLZEz4MY97B9pQQm3w@mail.gmail.com>


在 2022/2/18 下午8:35, Eugenio Perez Martin 写道:
> On Tue, Feb 8, 2022 at 4:23 AM Jason Wang <jasowang@redhat.com> wrote:
>>
>> 在 2022/1/31 下午11:34, Eugenio Perez Martin 写道:
>>> On Sat, Jan 29, 2022 at 9:06 AM Jason Wang <jasowang@redhat.com> wrote:
>>>> 在 2022/1/22 上午4:27, Eugenio Pérez 写道:
>>>>> Signed-off-by: Eugenio Pérez <eperezma@redhat.com>
>>>>> ---
>>>>>     hw/virtio/vhost-vdpa.c | 20 ++++++++++++++++++--
>>>>>     1 file changed, 18 insertions(+), 2 deletions(-)
>>>>>
>>>>> diff --git a/hw/virtio/vhost-vdpa.c b/hw/virtio/vhost-vdpa.c
>>>>> index 18de14f0fb..029f98feee 100644
>>>>> --- a/hw/virtio/vhost-vdpa.c
>>>>> +++ b/hw/virtio/vhost-vdpa.c
>>>>> @@ -687,13 +687,29 @@ static int vhost_vdpa_set_vring_kick(struct vhost_dev *dev,
>>>>>         }
>>>>>     }
>>>>>
>>>>> -static int vhost_vdpa_set_vring_call(struct vhost_dev *dev,
>>>>> -                                       struct vhost_vring_file *file)
>>>>> +static int vhost_vdpa_set_vring_dev_call(struct vhost_dev *dev,
>>>>> +                                         struct vhost_vring_file *file)
>>>>>     {
>>>>>         trace_vhost_vdpa_set_vring_call(dev, file->index, file->fd);
>>>>>         return vhost_vdpa_call(dev, VHOST_SET_VRING_CALL, file);
>>>>>     }
>>>>>
>>>>> +static int vhost_vdpa_set_vring_call(struct vhost_dev *dev,
>>>>> +                                     struct vhost_vring_file *file)
>>>>> +{
>>>>> +    struct vhost_vdpa *v = dev->opaque;
>>>>> +
>>>>> +    if (v->shadow_vqs_enabled) {
>>>>> +        int vdpa_idx = vhost_vdpa_get_vq_index(dev, file->index);
>>>>> +        VhostShadowVirtqueue *svq = g_ptr_array_index(v->shadow_vqs, vdpa_idx);
>>>>> +
>>>>> +        vhost_svq_set_guest_call_notifier(svq, file->fd);
>>>> Two questions here (had similar questions for vring kick):
>>>>
>>>> 1) Any reason that we setup the eventfd for vhost-vdpa in
>>>> vhost_vdpa_svq_setup() not here?
>>>>
>>> I'm not sure what you mean.
>>>
>>> The guest->SVQ call and kick fds are set here and at
>>> vhost_vdpa_set_vring_kick. The event notifier handler of the guest ->
>>> SVQ kick_fd is set at vhost_vdpa_set_vring_kick /
>>> vhost_svq_set_svq_kick_fd. The guest -> SVQ call fd has no event
>>> notifier handler since we don't poll it.
>>>
>>> On the other hand, the connection SVQ <-> device uses the same fds
>>> from the beginning to the end, and they will not change with, for
>>> example, call fd masking. That's why it's setup from
>>> vhost_vdpa_svq_setup. Delaying to vhost_vdpa_set_vring_call would make
>>> us add way more logic there.
>>
>> More logic in general shadow vq code but less codes for vhost-vdpa
>> specific code I think.
>>
>> E.g for we can move the kick set logic from vhost_vdpa_svq_set_fds() to
>> here.
>>
> But they are different fds. vhost_vdpa_svq_set_fds sets the
> SVQ<->device. This function sets the SVQ->guest call file descriptor.
>
> To move the logic of vhost_vdpa_svq_set_fds here would imply either:
> a) Logic to know if we are receiving the first call fd or not.


Any reason for this? I guess you meant multiqueue. If yes, it should not 
be much difference since we have idx as the parameter.


>   That
> code is not in the series at the moment, because setting at
> vhost_vdpa_dev_start tells the difference for free. Is just adding
> code, not moving.
> b) Logic to set again *the same* file descriptor to device, with logic
> to tell if we have missed calls. That logic is not implemented for
> device->SVQ call file descriptor, because we are assuming it never
> changes from vhost_vdpa_svq_set_fds. So this is again adding code.
>
> At this moment, we have:
> vhost_vdpa_svq_set_fds:
>    set SVQ<->device fds
>
> vhost_vdpa_set_vring_call:
>    set guest<-SVQ call
>
> vhost_vdpa_set_vring_kick:
>    set guest->SVQ kick.
>
> If I understood correctly, the alternative would be something like:
> vhost_vdpa_set_vring_call:
>    set guest<-SVQ call
>    if(!vq->call_set) {
>      - set SVQ<-device call.
>      - vq->call_set = true
>    }
>
> vhost_vdpa_set_vring_kick:
>    set guest<-SVQ call
>    if(!vq->dev_kick_set) {
>      - set guest->device kick.
>      - vq->dev_kick_set = true
>    }
>
> dev_reset / dev_stop:
> for vq in vqs:
>    vq->dev_kick_set = vq->dev_call_set = false
> ...
>
> Or have I misunderstood something?


I wonder what happens if MSI-X is masking in guest. So if I understand 
correctly, we don't disable the eventfd from device? If yes, this seems 
suboptinal.

Thanks


>
> Thanks!
>
>> Thanks
>>
>>
>>>> 2) The call could be disabled by using -1 as the fd, I don't see any
>>>> code to deal with that.
>>>>
>>> Right, I didn't take that into account. vhost-kernel takes also -1 as
>>> kick_fd to unbind, so SVQ can be reworked to take that into account
>>> for sure.
>>>
>>> Thanks!
>>>
>>>> Thanks
>>>>
>>>>
>>>>> +        return 0;
>>>>> +    } else {
>>>>> +        return vhost_vdpa_set_vring_dev_call(dev, file);
>>>>> +    }
>>>>> +}
>>>>> +
>>>>>     /**
>>>>>      * Set shadow virtqueue descriptors to the device
>>>>>      *

_______________________________________________
Virtualization mailing list
Virtualization@lists.linux-foundation.org
https://lists.linuxfoundation.org/mailman/listinfo/virtualization

  parent reply	other threads:[~2022-02-21  7:39 UTC|newest]

Thread overview: 52+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
     [not found] <20220121202733.404989-1-eperezma@redhat.com>
     [not found] ` <20220121202733.404989-22-eperezma@redhat.com>
2022-01-24  4:32   ` [PATCH 21/31] util: Add iova_tree_alloc Peter Xu
     [not found]     ` <CAJaqyWf--wbNZz5ZzbpixD9op_fO5fV01kbYXzG097c_NkqYrw@mail.gmail.com>
2022-01-24 11:07       ` Peter Xu
     [not found]         ` <CAJaqyWcdpTr2X4VuAN2NLmpviCjDoAaY269+VQGZ7-F6myOhSw@mail.gmail.com>
2022-01-27  8:06           ` Peter Xu
     [not found]             ` <CAJaqyWczZ7C_vbwugyN9bEgOVuRokGqVMb_g5UK_R4F8O+qKOA@mail.gmail.com>
2022-01-28  3:57               ` Peter Xu
2022-01-28  5:55                 ` Jason Wang
2022-01-30  5:06       ` Jason Wang
     [not found] ` <20220121202733.404989-2-eperezma@redhat.com>
2022-01-28  5:59   ` [PATCH 01/31] vdpa: Reorder virtio/vhost-vdpa.c functions Jason Wang
     [not found]     ` <CAJaqyWffGzYv2+HufFZzzBPtu5z3_vaKh4evGXqj7hqTB0WU3A@mail.gmail.com>
2022-02-21  7:31       ` Jason Wang
     [not found] ` <20220121202733.404989-3-eperezma@redhat.com>
2022-01-28  6:00   ` [PATCH 02/31] vhost: Add VhostShadowVirtqueue Jason Wang
2022-01-28  6:02 ` [PATCH 00/31] vDPA shadow virtqueue Jason Wang
     [not found]   ` <CAJaqyWfWxQSJc3YMpF6g7VwZBN_ab0Z+1nXgWH1sg+uBaOYgBQ@mail.gmail.com>
2022-02-08  8:27     ` Jason Wang
     [not found] ` <20220121202733.404989-4-eperezma@redhat.com>
2022-01-28  6:03   ` [PATCH 03/31] vdpa: Add vhost_svq_get_dev_kick_notifier Jason Wang
     [not found] ` <20220121202733.404989-5-eperezma@redhat.com>
2022-01-28  6:29   ` [PATCH 04/31] vdpa: Add vhost_svq_set_svq_kick_fd Jason Wang
     [not found]     ` <CAJaqyWc7fbgN-W7y3=iFqHsJzj+1Mg0cuwSu+my=62nu9vGOqA@mail.gmail.com>
2022-02-08  8:47       ` Jason Wang
     [not found] ` <20220121202733.404989-6-eperezma@redhat.com>
2022-01-28  6:32   ` [PATCH 05/31] vhost: Add Shadow VirtQueue kick forwarding capabilities Jason Wang
     [not found] ` <20220121202733.404989-7-eperezma@redhat.com>
2022-01-28  6:56   ` [PATCH 06/31] vhost: Route guest->host notification through shadow virtqueue Jason Wang
     [not found]     ` <CAJaqyWeRbmwW80q3q52nFw=iz1xcPRFviFaRHo0nzXpEb+3m3A@mail.gmail.com>
2022-02-08  9:02       ` Jason Wang
     [not found] ` <20220121202733.404989-8-eperezma@redhat.com>
2022-01-29  7:57   ` [PATCH 07/31] vhost: dd vhost_svq_get_svq_call_notifier Jason Wang
     [not found] ` <20220121202733.404989-10-eperezma@redhat.com>
2022-01-29  8:05   ` [PATCH 09/31] vhost-vdpa: Take into account SVQ in vhost_vdpa_set_vring_call Jason Wang
     [not found]     ` <CAJaqyWda5sBw9VGBrz8g60OJ07Eeq45RRYu9vwgOPZFwten9rw@mail.gmail.com>
2022-02-08  3:23       ` Jason Wang
     [not found]         ` <CAJaqyWeisXmZ9+xw2Rj50K7aKx4khNZZjLZEz4MY97B9pQQm3w@mail.gmail.com>
2022-02-21  7:39           ` Jason Wang [this message]
     [not found]             ` <CAJaqyWc5uR70a=hTpVpomuahF9iZouLmRpXPnWidga5CFxJOpA@mail.gmail.com>
2022-02-22  7:18               ` Jason Wang
     [not found] ` <20220121202733.404989-12-eperezma@redhat.com>
2022-01-29  8:11   ` [PATCH 11/31] vhost: Add vhost_svq_valid_device_features to shadow vq Jason Wang
     [not found]     ` <CAJaqyWfaf0RG9AzW4ktH2L3wyfOGuSk=rNm-j7xRkpdfVvkY-g@mail.gmail.com>
     [not found]       ` <CAJaqyWc6BqJBDcUE36AQ=bgWjJYkyMo1ZYxRwmc5ZgGj4T-pVg@mail.gmail.com>
2022-02-08  3:37         ` Jason Wang
     [not found] ` <20220121202733.404989-16-eperezma@redhat.com>
2022-01-29  8:14   ` [PATCH 15/31] vdpa: Add vhost_svq_get_num Jason Wang
     [not found] ` <20220121202733.404989-17-eperezma@redhat.com>
2022-01-29  8:20   ` [PATCH 16/31] vhost: pass queue index to vhost_vq_get_addr Jason Wang
     [not found]     ` <CAJaqyWexu=VroHQxmtJDQm=iu1va-s1VGR8hqGOreG0SOisjYg@mail.gmail.com>
2022-02-08  6:58       ` Jason Wang
     [not found] ` <20220121202733.404989-18-eperezma@redhat.com>
2022-01-30  4:03   ` [PATCH 17/31] vdpa: adapt vhost_ops callbacks to svq Jason Wang
     [not found]     ` <CAJaqyWdRKZp6CwnE+HAr0JALhSRh-trJbZ01kddnLTuRX_tMKQ@mail.gmail.com>
2022-02-08  3:57       ` Jason Wang
     [not found]         ` <CAJaqyWfEEg2PKgxBAFwYhF9LD1oDtwVYXSjHHnCbstT3dvL2GA@mail.gmail.com>
2022-02-21  7:15           ` Jason Wang
     [not found]             ` <CAJaqyWcoHgToqsR-bVRctTnhgufmarR_2hh4O_VoCbCGp8WNhg@mail.gmail.com>
2022-02-22  3:16               ` Jason Wang
     [not found]                 ` <CAJaqyWd2PQFedaEOV7YVZgp0m37snn-4LYYtNw7g4u+7hrtq=Q@mail.gmail.com>
2022-02-22  7:59                   ` Jason Wang
     [not found] ` <20220121202733.404989-19-eperezma@redhat.com>
2022-01-30  4:42   ` [PATCH 18/31] vhost: Shadow virtqueue buffers forwarding Jason Wang
     [not found]     ` <CAJaqyWdDax2+e3ZUEYyYNe5xAL=Oocu+72n89ygayrzYrQz2Yw@mail.gmail.com>
2022-02-08  8:11       ` Jason Wang
     [not found]         ` <CAJaqyWfRWexq7jrCkJrPzLB4g_fK42pE8BarMhZwKNYtNXi7XA@mail.gmail.com>
2022-02-23  2:03           ` Jason Wang
2022-01-30  6:46   ` Jason Wang
     [not found]     ` <CAJaqyWfF01k3LntM7RLEmFcej=EY2d4+2MARKXPptQ2J7VnB9A@mail.gmail.com>
2022-02-08  8:15       ` Jason Wang
     [not found]         ` <CAJaqyWedqtzRW=ur7upchneSc-oOkvkr3FUph_BfphV3zTmnkw@mail.gmail.com>
2022-02-21  7:43           ` Jason Wang
     [not found]             ` <CAJaqyWcHhMpjJ4kde1ejV5c_vP7_8PvfXpi5u9rdWuaORFt_zg@mail.gmail.com>
2022-02-22  7:26               ` Jason Wang
     [not found]                 ` <CAJaqyWePWg+eeQjjcMh24k0K+yUQUF2x0yXH32tPPWEw_wYP0Q@mail.gmail.com>
2022-02-23  2:26                   ` Jason Wang
     [not found] ` <20220121202733.404989-23-eperezma@redhat.com>
2022-01-30  5:21   ` [PATCH 22/31] vhost: Add VhostIOVATree Jason Wang
     [not found]     ` <CAJaqyWePW6hJKAm7nk+syqmXAgdTQSTtuv9jACu_+hgbg2bRHg@mail.gmail.com>
2022-02-08  8:17       ` Jason Wang
     [not found] ` <20220121202733.404989-24-eperezma@redhat.com>
2022-01-30  5:57   ` [PATCH 23/31] vdpa: Add custom IOTLB translations to SVQ Jason Wang
     [not found]     ` <CAJaqyWe1zH8bfaoxTyz_RXH=0q+Yk9H7QyUffaRB1fCV9oVLZQ@mail.gmail.com>
2022-02-08  8:19       ` Jason Wang
     [not found] ` <20220121202733.404989-29-eperezma@redhat.com>
2022-01-30  6:50   ` [PATCH 28/31] vdpa: Expose VHOST_F_LOG_ALL on SVQ Jason Wang
     [not found]     ` <CAJaqyWdBLU+maEhByepzeH7iwLmqUba0rRb8PM4VwBy2P8Vtow@mail.gmail.com>
2022-02-08  8:25       ` Jason Wang
     [not found]         ` <CAJaqyWcvWjPas0=xp+U-c-kG+e6k73jg=C4phFD7S-tZY=niSQ@mail.gmail.com>
2022-02-17  6:02           ` Jason Wang
     [not found]             ` <CAJaqyWdhHmD+tB_bY_YEMnBU1p7-LW=LP8f+3e_ZXDcOfSRiNA@mail.gmail.com>
2022-02-22  7:41               ` Jason Wang
     [not found]                 ` <CAJaqyWfFC4SgxQ4zQeHgtDDJSd0tBa-W4HmtW0UASA2cVDWDUg@mail.gmail.com>
2022-02-23  3:46                   ` Jason Wang
     [not found]                     ` <CAJaqyWds=97TjEpORiqhsj57KNxJ482jwcRS8TN59a4aank7-w@mail.gmail.com>
2022-02-24  3:45                       ` Jason Wang
     [not found] ` <20220121202733.404989-30-eperezma@redhat.com>
2022-01-30  6:51   ` [PATCH 29/31] vdpa: Make ncs autofree Jason Wang
     [not found] ` <20220121202733.404989-31-eperezma@redhat.com>
2022-01-30  6:53   ` [PATCH 30/31] vdpa: Move vhost_vdpa_get_iova_range to net/vhost-vdpa.c Jason Wang

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=bccdecdd-fa2d-48c0-43b8-7afe7b230b7b@redhat.com \
    --to=jasowang@redhat.com \
    --cc=armbru@redhat.com \
    --cc=eblake@redhat.com \
    --cc=ehabkost@redhat.com \
    --cc=eli@mellanox.com \
    --cc=eperezma@redhat.com \
    --cc=gdawar@xilinx.com \
    --cc=hanand@xilinx.com \
    --cc=lingshan.zhu@intel.com \
    --cc=lulu@redhat.com \
    --cc=lvivier@redhat.com \
    --cc=mst@redhat.com \
    --cc=parav@mellanox.com \
    --cc=pbonzini@redhat.com \
    --cc=qemu-devel@nongnu.org \
    --cc=richard.henderson@linaro.org \
    --cc=stefanha@redhat.com \
    --cc=virtualization@lists.linux-foundation.org \
    --cc=xiao.w.wang@intel.com \
    /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).