qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
From: "Michael S. Tsirkin" <mst@redhat.com>
To: Jason Wang <jasowang@redhat.com>
Cc: pasic@linux.ibm.com, qemu-devel@nongnu.org, qemu-stable@nongnu.org
Subject: Re: [PATCH V2] vhost: correctly turn on VIRTIO_F_IOMMU_PLATFORM
Date: Wed, 26 Feb 2020 06:44:25 -0500	[thread overview]
Message-ID: <20200226064243-mutt-send-email-mst@kernel.org> (raw)
In-Reply-To: <bd592433-71b9-773f-97ef-f5da87734b05@redhat.com>

On Wed, Feb 26, 2020 at 06:17:34PM +0800, Jason Wang wrote:
> 
> On 2020/2/26 下午5:53, Michael S. Tsirkin wrote:
> > On Wed, Feb 26, 2020 at 05:43:57PM +0800, Jason Wang wrote:
> > > We turn on device IOTLB via VIRTIO_F_IOMMU_PLATFORM unconditionally on
> > > platform without IOMMU support. This can lead unnecessary IOTLB
> > > transactions which will damage the performance.
> > > 
> > > Fixing this by check whether the device is backed by IOMMU and disable
> > > device IOTLB.
> > > 
> > > Reported-by: Halil Pasic <pasic@linux.ibm.com>
> > > Fixes: c471ad0e9bd46 ("vhost_net: device IOTLB support")
> > Well it's just an optimization, isn't it?
> 
> 
> Kind of, or a fix for the performance.
> 

Given this wasn't a regression, it's a valuable enhancement
but Fixes: seems to agressive.

> > I don't think it's justified to push this to everyone using
> > vhost with IOTLB, is it?
> 
> 
> My understanding is that the function should be equivalent to IOTLB in this
> case.
> 
> Since no IOMMU is used and device may only see GPA.
> 
> Another possible direction is to qemu to update memory table via device
> IOTLB API, this seems less straightforward.
> 
> 
> > If you disagree, could you comment a bit on which configurations where tested?
> 
> 
> I just do dirty shortcut to emulate the platform without get_dma_as wth
> IOMMU_PLATFORM set.
> 
> Thanks

If you want Fixes tag with an expectation of everyone backporting,
then this also needs to be tested on a platform with a viommu,
such as dpdk within guest.

> 
> > 
> > > Cc: qemu-stable@nongnu.org
> > > Signed-off-by: Jason Wang <jasowang@redhat.com>
> > Halil could you test this pls? Does this help your performance issue?
> > 
> > > ---
> > > Changes from V1:
> > > - do not check acked_features
> > > - reuse vhost_dev_has_iommu()
> > > ---
> > >   hw/virtio/vhost.c | 12 +++++++++++-
> > >   1 file changed, 11 insertions(+), 1 deletion(-)
> > > 
> > > diff --git a/hw/virtio/vhost.c b/hw/virtio/vhost.c
> > > index 9edfadc81d..9182a00495 100644
> > > --- a/hw/virtio/vhost.c
> > > +++ b/hw/virtio/vhost.c
> > > @@ -290,7 +290,14 @@ static int vhost_dev_has_iommu(struct vhost_dev *dev)
> > >   {
> > >       VirtIODevice *vdev = dev->vdev;
> > > -    return virtio_host_has_feature(vdev, VIRTIO_F_IOMMU_PLATFORM);
> > > +    /*
> > > +     * For vhost, VIRTIO_F_IOMMU_PLATFORM means the backend support
> > > +     * incremental memory mapping API via IOTLB API. For platform that
> > > +     * does not have IOMMU, there's no need to enable this feature
> > > +     * which may cause unnecessary IOTLB miss/update trnasactions.
> > > +     */
> > > +    return vdev->dma_as != &address_space_memory &&
> > > +           virtio_host_has_feature(vdev, VIRTIO_F_IOMMU_PLATFORM);
> > >   }
> > >   static void *vhost_memory_map(struct vhost_dev *dev, hwaddr addr,
> > > @@ -765,6 +772,9 @@ static int vhost_dev_set_features(struct vhost_dev *dev,
> > >       if (enable_log) {
> > >           features |= 0x1ULL << VHOST_F_LOG_ALL;
> > >       }
> > > +    if (!vhost_dev_has_iommu(dev)) {
> > > +        features &= ~(0x1ULL << VIRTIO_F_IOMMU_PLATFORM);
> > > +    }
> > >       r = dev->vhost_ops->vhost_set_features(dev, features);
> > >       if (r < 0) {
> > >           VHOST_OPS_DEBUG("vhost_set_features failed");
> > > -- 
> > > 2.19.1



  reply	other threads:[~2020-02-26 11:48 UTC|newest]

Thread overview: 30+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-02-26  9:43 [PATCH V2] vhost: correctly turn on VIRTIO_F_IOMMU_PLATFORM Jason Wang
2020-02-26  9:53 ` Michael S. Tsirkin
2020-02-26 10:17   ` Jason Wang
2020-02-26 11:44     ` Michael S. Tsirkin [this message]
2020-02-26 12:50       ` Halil Pasic
2020-02-26 12:55   ` Halil Pasic
2020-02-26 13:45     ` Michael S. Tsirkin
2020-02-26 13:28 ` Halil Pasic
2020-02-26 13:37   ` Michael S. Tsirkin
2020-02-26 15:36     ` Halil Pasic
2020-02-26 16:52       ` Michael S. Tsirkin
2020-02-27 13:02         ` Halil Pasic
2020-02-27 15:47           ` Michael S. Tsirkin
2020-03-03 14:44             ` Halil Pasic
2020-03-13 12:44             ` Halil Pasic
2020-03-13 15:29               ` Michael S. Tsirkin
2020-03-13 16:31                 ` Peter Xu
2020-03-16 16:57                   ` Halil Pasic
2020-03-16 17:31                     ` Peter Xu
2020-03-16 17:19                   ` Michael S. Tsirkin
2020-03-16 18:14                     ` Peter Xu
2020-03-17  3:04                       ` Jason Wang
2020-03-17 14:13                         ` Peter Xu
2020-03-18  2:06                           ` Jason Wang
2020-03-17  6:28                       ` Michael S. Tsirkin
2020-03-17 14:39                         ` Peter Xu
2020-03-17 14:55                           ` Michael S. Tsirkin
2020-03-13 20:27               ` Brijesh Singh
2020-03-14 18:22                 ` Michael S. Tsirkin
2020-02-27 20:36           ` Tom Lendacky

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=20200226064243-mutt-send-email-mst@kernel.org \
    --to=mst@redhat.com \
    --cc=jasowang@redhat.com \
    --cc=pasic@linux.ibm.com \
    --cc=qemu-devel@nongnu.org \
    --cc=qemu-stable@nongnu.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).