From: "Michael S. Tsirkin" <mst@redhat.com>
To: Jason Wang <jasowang@redhat.com>
Cc: Laurent Vivier <lvivier@redhat.com>,
kvm@vger.kernel.org, Parav Pandit <parav@mellanox.com>,
Cindy Lu <lulu@redhat.com>, Cornelia Huck <cohuck@redhat.com>,
qemu-devel@nongnu.org, Gautam Dawar <gdawar@xilinx.com>,
virtualization@lists.linux-foundation.org,
Eugenio Perez Martin <eperezma@redhat.com>,
Harpreet Singh Anand <hanand@xilinx.com>,
Stefan Hajnoczi <stefanha@redhat.com>,
Eli Cohen <eli@mellanox.com>, Paolo Bonzini <pbonzini@redhat.com>,
Liuxiangdong <liuxiangdong5@huawei.com>,
Longpeng <longpeng2@huawei.com>
Subject: Re: [PATCH v9 06/12] vdpa: request iova_range only once
Date: Wed, 21 Dec 2022 06:47:03 -0500 [thread overview]
Message-ID: <20221221064619-mutt-send-email-mst@kernel.org> (raw)
In-Reply-To: <CACGkMEtkWJQVrnuG7CKJ+zFcMFhhZs3=iFPjv85U7KAjkpd=EA@mail.gmail.com>
On Wed, Dec 21, 2022 at 04:21:52PM +0800, Jason Wang wrote:
> On Fri, Dec 16, 2022 at 5:53 PM Eugenio Perez Martin
> <eperezma@redhat.com> wrote:
> >
> > On Fri, Dec 16, 2022 at 8:29 AM Jason Wang <jasowang@redhat.com> wrote:
> > >
> > > On Thu, Dec 15, 2022 at 7:32 PM Eugenio Pérez <eperezma@redhat.com> wrote:
> > > >
> > > > Currently iova range is requested once per queue pair in the case of
> > > > net. Reduce the number of ioctls asking it once at initialization and
> > > > reusing that value for each vhost_vdpa.
> > > >
> > > > Signed-off-by: Eugenio Pérez <eperezma@redhat.com>
> > > > ---
> > > > hw/virtio/vhost-vdpa.c | 15 ---------------
> > > > net/vhost-vdpa.c | 27 ++++++++++++++-------------
> > > > 2 files changed, 14 insertions(+), 28 deletions(-)
> > > >
> > > > diff --git a/hw/virtio/vhost-vdpa.c b/hw/virtio/vhost-vdpa.c
> > > > index 691bcc811a..9b7f4ef083 100644
> > > > --- a/hw/virtio/vhost-vdpa.c
> > > > +++ b/hw/virtio/vhost-vdpa.c
> > > > @@ -365,19 +365,6 @@ static int vhost_vdpa_add_status(struct vhost_dev *dev, uint8_t status)
> > > > return 0;
> > > > }
> > > >
> > > > -static void vhost_vdpa_get_iova_range(struct vhost_vdpa *v)
> > > > -{
> > > > - int ret = vhost_vdpa_call(v->dev, VHOST_VDPA_GET_IOVA_RANGE,
> > > > - &v->iova_range);
> > > > - if (ret != 0) {
> > > > - v->iova_range.first = 0;
> > > > - v->iova_range.last = UINT64_MAX;
> > > > - }
> > > > -
> > > > - trace_vhost_vdpa_get_iova_range(v->dev, v->iova_range.first,
> > > > - v->iova_range.last);
> > > > -}
> > > > -
> > > > /*
> > > > * The use of this function is for requests that only need to be
> > > > * applied once. Typically such request occurs at the beginning
> > > > @@ -465,8 +452,6 @@ static int vhost_vdpa_init(struct vhost_dev *dev, void *opaque, Error **errp)
> > > > goto err;
> > > > }
> > > >
> > > > - vhost_vdpa_get_iova_range(v);
> > > > -
> > > > if (!vhost_vdpa_first_dev(dev)) {
> > > > return 0;
> > > > }
> > > > diff --git a/net/vhost-vdpa.c b/net/vhost-vdpa.c
> > > > index 2c0ff6d7b0..b6462f0192 100644
> > > > --- a/net/vhost-vdpa.c
> > > > +++ b/net/vhost-vdpa.c
> > > > @@ -541,14 +541,15 @@ static const VhostShadowVirtqueueOps vhost_vdpa_net_svq_ops = {
> > > > };
> > > >
> > > > static NetClientState *net_vhost_vdpa_init(NetClientState *peer,
> > > > - const char *device,
> > > > - const char *name,
> > > > - int vdpa_device_fd,
> > > > - int queue_pair_index,
> > > > - int nvqs,
> > > > - bool is_datapath,
> > > > - bool svq,
> > > > - VhostIOVATree *iova_tree)
> > > > + const char *device,
> > > > + const char *name,
> > > > + int vdpa_device_fd,
> > > > + int queue_pair_index,
> > > > + int nvqs,
> > > > + bool is_datapath,
> > > > + bool svq,
> > > > + struct vhost_vdpa_iova_range iova_range,
> > > > + VhostIOVATree *iova_tree)
> > >
> > > Nit: it's better not mix style changes.
> > >
> >
> > The style changes are because the new parameter is longer than 80
> > characters, do you prefer me to send a previous patch reducing
> > indentation?
> >
>
> Michale, what's your preference? I'm fine with both.
>
> Thanks
I think it doesn't matter much, but generally 80 char limit is
not a hard limit. We can just let it be.
> > Thanks!
> >
> > > Other than this:
> > >
> > > Acked-by: Jason Wang <jasonwang@redhat.com>
> > >
> > > Thanks
> > >
> > > > {
> > > > NetClientState *nc = NULL;
> > > > VhostVDPAState *s;
> > > > @@ -567,6 +568,7 @@ static NetClientState *net_vhost_vdpa_init(NetClientState *peer,
> > > > s->vhost_vdpa.device_fd = vdpa_device_fd;
> > > > s->vhost_vdpa.index = queue_pair_index;
> > > > s->vhost_vdpa.shadow_vqs_enabled = svq;
> > > > + s->vhost_vdpa.iova_range = iova_range;
> > > > s->vhost_vdpa.iova_tree = iova_tree;
> > > > if (!is_datapath) {
> > > > s->cvq_cmd_out_buffer = qemu_memalign(qemu_real_host_page_size(),
> > > > @@ -646,6 +648,7 @@ int net_init_vhost_vdpa(const Netdev *netdev, const char *name,
> > > > int vdpa_device_fd;
> > > > g_autofree NetClientState **ncs = NULL;
> > > > g_autoptr(VhostIOVATree) iova_tree = NULL;
> > > > + struct vhost_vdpa_iova_range iova_range;
> > > > NetClientState *nc;
> > > > int queue_pairs, r, i = 0, has_cvq = 0;
> > > >
> > > > @@ -689,14 +692,12 @@ int net_init_vhost_vdpa(const Netdev *netdev, const char *name,
> > > > return queue_pairs;
> > > > }
> > > >
> > > > + vhost_vdpa_get_iova_range(vdpa_device_fd, &iova_range);
> > > > if (opts->x_svq) {
> > > > - struct vhost_vdpa_iova_range iova_range;
> > > > -
> > > > if (!vhost_vdpa_net_valid_svq_features(features, errp)) {
> > > > goto err_svq;
> > > > }
> > > >
> > > > - vhost_vdpa_get_iova_range(vdpa_device_fd, &iova_range);
> > > > iova_tree = vhost_iova_tree_new(iova_range.first, iova_range.last);
> > > > }
> > > >
> > > > @@ -705,7 +706,7 @@ int net_init_vhost_vdpa(const Netdev *netdev, const char *name,
> > > > for (i = 0; i < queue_pairs; i++) {
> > > > ncs[i] = net_vhost_vdpa_init(peer, TYPE_VHOST_VDPA, name,
> > > > vdpa_device_fd, i, 2, true, opts->x_svq,
> > > > - iova_tree);
> > > > + iova_range, iova_tree);
> > > > if (!ncs[i])
> > > > goto err;
> > > > }
> > > > @@ -713,7 +714,7 @@ int net_init_vhost_vdpa(const Netdev *netdev, const char *name,
> > > > if (has_cvq) {
> > > > nc = net_vhost_vdpa_init(peer, TYPE_VHOST_VDPA, name,
> > > > vdpa_device_fd, i, 1, false,
> > > > - opts->x_svq, iova_tree);
> > > > + opts->x_svq, iova_range, iova_tree);
> > > > if (!nc)
> > > > goto err;
> > > > }
> > > > --
> > > > 2.31.1
> > > >
> > >
> >
_______________________________________________
Virtualization mailing list
Virtualization@lists.linux-foundation.org
https://lists.linuxfoundation.org/mailman/listinfo/virtualization
WARNING: multiple messages have this Message-ID (diff)
From: "Michael S. Tsirkin" <mst@redhat.com>
To: Jason Wang <jasowang@redhat.com>
Cc: Eugenio Perez Martin <eperezma@redhat.com>,
qemu-devel@nongnu.org, Liuxiangdong <liuxiangdong5@huawei.com>,
Stefano Garzarella <sgarzare@redhat.com>,
Zhu Lingshan <lingshan.zhu@intel.com>,
Si-Wei Liu <si-wei.liu@oracle.com>,
Laurent Vivier <lvivier@redhat.com>,
"Gonglei (Arei)" <arei.gonglei@huawei.com>,
Stefan Hajnoczi <stefanha@redhat.com>, Cindy Lu <lulu@redhat.com>,
Gautam Dawar <gdawar@xilinx.com>, Eli Cohen <eli@mellanox.com>,
Cornelia Huck <cohuck@redhat.com>,
Paolo Bonzini <pbonzini@redhat.com>,
Longpeng <longpeng2@huawei.com>,
Harpreet Singh Anand <hanand@xilinx.com>,
Parav Pandit <parav@mellanox.com>,
kvm@vger.kernel.org, virtualization@lists.linux-foundation.org
Subject: Re: [PATCH v9 06/12] vdpa: request iova_range only once
Date: Wed, 21 Dec 2022 06:47:03 -0500 [thread overview]
Message-ID: <20221221064619-mutt-send-email-mst@kernel.org> (raw)
In-Reply-To: <CACGkMEtkWJQVrnuG7CKJ+zFcMFhhZs3=iFPjv85U7KAjkpd=EA@mail.gmail.com>
On Wed, Dec 21, 2022 at 04:21:52PM +0800, Jason Wang wrote:
> On Fri, Dec 16, 2022 at 5:53 PM Eugenio Perez Martin
> <eperezma@redhat.com> wrote:
> >
> > On Fri, Dec 16, 2022 at 8:29 AM Jason Wang <jasowang@redhat.com> wrote:
> > >
> > > On Thu, Dec 15, 2022 at 7:32 PM Eugenio Pérez <eperezma@redhat.com> wrote:
> > > >
> > > > Currently iova range is requested once per queue pair in the case of
> > > > net. Reduce the number of ioctls asking it once at initialization and
> > > > reusing that value for each vhost_vdpa.
> > > >
> > > > Signed-off-by: Eugenio Pérez <eperezma@redhat.com>
> > > > ---
> > > > hw/virtio/vhost-vdpa.c | 15 ---------------
> > > > net/vhost-vdpa.c | 27 ++++++++++++++-------------
> > > > 2 files changed, 14 insertions(+), 28 deletions(-)
> > > >
> > > > diff --git a/hw/virtio/vhost-vdpa.c b/hw/virtio/vhost-vdpa.c
> > > > index 691bcc811a..9b7f4ef083 100644
> > > > --- a/hw/virtio/vhost-vdpa.c
> > > > +++ b/hw/virtio/vhost-vdpa.c
> > > > @@ -365,19 +365,6 @@ static int vhost_vdpa_add_status(struct vhost_dev *dev, uint8_t status)
> > > > return 0;
> > > > }
> > > >
> > > > -static void vhost_vdpa_get_iova_range(struct vhost_vdpa *v)
> > > > -{
> > > > - int ret = vhost_vdpa_call(v->dev, VHOST_VDPA_GET_IOVA_RANGE,
> > > > - &v->iova_range);
> > > > - if (ret != 0) {
> > > > - v->iova_range.first = 0;
> > > > - v->iova_range.last = UINT64_MAX;
> > > > - }
> > > > -
> > > > - trace_vhost_vdpa_get_iova_range(v->dev, v->iova_range.first,
> > > > - v->iova_range.last);
> > > > -}
> > > > -
> > > > /*
> > > > * The use of this function is for requests that only need to be
> > > > * applied once. Typically such request occurs at the beginning
> > > > @@ -465,8 +452,6 @@ static int vhost_vdpa_init(struct vhost_dev *dev, void *opaque, Error **errp)
> > > > goto err;
> > > > }
> > > >
> > > > - vhost_vdpa_get_iova_range(v);
> > > > -
> > > > if (!vhost_vdpa_first_dev(dev)) {
> > > > return 0;
> > > > }
> > > > diff --git a/net/vhost-vdpa.c b/net/vhost-vdpa.c
> > > > index 2c0ff6d7b0..b6462f0192 100644
> > > > --- a/net/vhost-vdpa.c
> > > > +++ b/net/vhost-vdpa.c
> > > > @@ -541,14 +541,15 @@ static const VhostShadowVirtqueueOps vhost_vdpa_net_svq_ops = {
> > > > };
> > > >
> > > > static NetClientState *net_vhost_vdpa_init(NetClientState *peer,
> > > > - const char *device,
> > > > - const char *name,
> > > > - int vdpa_device_fd,
> > > > - int queue_pair_index,
> > > > - int nvqs,
> > > > - bool is_datapath,
> > > > - bool svq,
> > > > - VhostIOVATree *iova_tree)
> > > > + const char *device,
> > > > + const char *name,
> > > > + int vdpa_device_fd,
> > > > + int queue_pair_index,
> > > > + int nvqs,
> > > > + bool is_datapath,
> > > > + bool svq,
> > > > + struct vhost_vdpa_iova_range iova_range,
> > > > + VhostIOVATree *iova_tree)
> > >
> > > Nit: it's better not mix style changes.
> > >
> >
> > The style changes are because the new parameter is longer than 80
> > characters, do you prefer me to send a previous patch reducing
> > indentation?
> >
>
> Michale, what's your preference? I'm fine with both.
>
> Thanks
I think it doesn't matter much, but generally 80 char limit is
not a hard limit. We can just let it be.
> > Thanks!
> >
> > > Other than this:
> > >
> > > Acked-by: Jason Wang <jasonwang@redhat.com>
> > >
> > > Thanks
> > >
> > > > {
> > > > NetClientState *nc = NULL;
> > > > VhostVDPAState *s;
> > > > @@ -567,6 +568,7 @@ static NetClientState *net_vhost_vdpa_init(NetClientState *peer,
> > > > s->vhost_vdpa.device_fd = vdpa_device_fd;
> > > > s->vhost_vdpa.index = queue_pair_index;
> > > > s->vhost_vdpa.shadow_vqs_enabled = svq;
> > > > + s->vhost_vdpa.iova_range = iova_range;
> > > > s->vhost_vdpa.iova_tree = iova_tree;
> > > > if (!is_datapath) {
> > > > s->cvq_cmd_out_buffer = qemu_memalign(qemu_real_host_page_size(),
> > > > @@ -646,6 +648,7 @@ int net_init_vhost_vdpa(const Netdev *netdev, const char *name,
> > > > int vdpa_device_fd;
> > > > g_autofree NetClientState **ncs = NULL;
> > > > g_autoptr(VhostIOVATree) iova_tree = NULL;
> > > > + struct vhost_vdpa_iova_range iova_range;
> > > > NetClientState *nc;
> > > > int queue_pairs, r, i = 0, has_cvq = 0;
> > > >
> > > > @@ -689,14 +692,12 @@ int net_init_vhost_vdpa(const Netdev *netdev, const char *name,
> > > > return queue_pairs;
> > > > }
> > > >
> > > > + vhost_vdpa_get_iova_range(vdpa_device_fd, &iova_range);
> > > > if (opts->x_svq) {
> > > > - struct vhost_vdpa_iova_range iova_range;
> > > > -
> > > > if (!vhost_vdpa_net_valid_svq_features(features, errp)) {
> > > > goto err_svq;
> > > > }
> > > >
> > > > - vhost_vdpa_get_iova_range(vdpa_device_fd, &iova_range);
> > > > iova_tree = vhost_iova_tree_new(iova_range.first, iova_range.last);
> > > > }
> > > >
> > > > @@ -705,7 +706,7 @@ int net_init_vhost_vdpa(const Netdev *netdev, const char *name,
> > > > for (i = 0; i < queue_pairs; i++) {
> > > > ncs[i] = net_vhost_vdpa_init(peer, TYPE_VHOST_VDPA, name,
> > > > vdpa_device_fd, i, 2, true, opts->x_svq,
> > > > - iova_tree);
> > > > + iova_range, iova_tree);
> > > > if (!ncs[i])
> > > > goto err;
> > > > }
> > > > @@ -713,7 +714,7 @@ int net_init_vhost_vdpa(const Netdev *netdev, const char *name,
> > > > if (has_cvq) {
> > > > nc = net_vhost_vdpa_init(peer, TYPE_VHOST_VDPA, name,
> > > > vdpa_device_fd, i, 1, false,
> > > > - opts->x_svq, iova_tree);
> > > > + opts->x_svq, iova_range, iova_tree);
> > > > if (!nc)
> > > > goto err;
> > > > }
> > > > --
> > > > 2.31.1
> > > >
> > >
> >
next prev parent reply other threads:[~2022-12-21 11:47 UTC|newest]
Thread overview: 22+ messages / expand[flat|nested] mbox.gz Atom feed top
2022-12-15 11:31 [PATCH v9 00/12] ASID support in vhost-vdpa net Eugenio Pérez
2022-12-15 11:31 ` [PATCH v9 01/12] vdpa: use v->shadow_vqs_enabled in vhost_vdpa_svqs_start & stop Eugenio Pérez
2022-12-15 11:31 ` [PATCH v9 02/12] vhost: set SVQ device call handler at SVQ start Eugenio Pérez
2022-12-15 11:31 ` [PATCH v9 03/12] vhost: allocate SVQ device file descriptors at device start Eugenio Pérez
2022-12-15 11:31 ` [PATCH v9 04/12] vhost: move iova_tree set to vhost_svq_start Eugenio Pérez
2022-12-15 11:31 ` [PATCH v9 05/12] vdpa: add vhost_vdpa_net_valid_svq_features Eugenio Pérez
2022-12-15 11:31 ` [PATCH v9 06/12] vdpa: request iova_range only once Eugenio Pérez
2022-12-16 7:29 ` Jason Wang
2022-12-16 7:29 ` Jason Wang
2022-12-16 9:52 ` Eugenio Perez Martin
2022-12-21 8:21 ` Jason Wang
2022-12-21 8:21 ` Jason Wang
2022-12-21 11:47 ` Michael S. Tsirkin [this message]
2022-12-21 11:47 ` Michael S. Tsirkin
2022-12-15 11:31 ` [PATCH v9 07/12] vdpa: move SVQ vring features check to net/ Eugenio Pérez
2022-12-15 11:31 ` [PATCH v9 08/12] vdpa: allocate SVQ array unconditionally Eugenio Pérez
2022-12-15 11:31 ` [PATCH v9 09/12] vdpa: add asid parameter to vhost_vdpa_dma_map/unmap Eugenio Pérez
2022-12-15 11:31 ` [PATCH v9 10/12] vdpa: store x-svq parameter in VhostVDPAState Eugenio Pérez
2022-12-15 11:31 ` [PATCH v9 11/12] vdpa: add shadow_data to vhost_vdpa Eugenio Pérez
2022-12-15 11:31 ` [PATCH v9 12/12] vdpa: always start CVQ in SVQ mode if possible Eugenio Pérez
2022-12-16 7:35 ` Jason Wang
2022-12-16 7:35 ` 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=20221221064619-mutt-send-email-mst@kernel.org \
--to=mst@redhat.com \
--cc=cohuck@redhat.com \
--cc=eli@mellanox.com \
--cc=eperezma@redhat.com \
--cc=gdawar@xilinx.com \
--cc=hanand@xilinx.com \
--cc=jasowang@redhat.com \
--cc=kvm@vger.kernel.org \
--cc=liuxiangdong5@huawei.com \
--cc=longpeng2@huawei.com \
--cc=lulu@redhat.com \
--cc=lvivier@redhat.com \
--cc=parav@mellanox.com \
--cc=pbonzini@redhat.com \
--cc=qemu-devel@nongnu.org \
--cc=stefanha@redhat.com \
--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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.