From: Jason Gunthorpe via iommu <iommu@lists.linux-foundation.org>
To: Robin Murphy <robin.murphy@arm.com>
Cc: "Tian, Kevin" <kevin.tian@intel.com>,
"Raj, Ashok" <ashok.raj@intel.com>,
Jean-Philippe Brucker <jean-philippe@linaro.com>,
"linux-kernel@vger.kernel.org" <linux-kernel@vger.kernel.org>,
Christoph Hellwig <hch@infradead.org>,
"iommu@lists.linux-foundation.org"
<iommu@lists.linux-foundation.org>,
"Pan, Jacob jun" <jacob.jun.pan@intel.com>,
Will Deacon <will@kernel.org>
Subject: Re: [PATCH RFC v2 03/11] iommu/sva: Add iommu_domain type for SVA
Date: Wed, 6 Apr 2022 11:01:44 -0300 [thread overview]
Message-ID: <20220406140144.GD2120790@nvidia.com> (raw)
In-Reply-To: <b7639218-2d10-fd71-0f4b-3af3f8fa224b@arm.com>
On Wed, Apr 06, 2022 at 02:37:40PM +0100, Robin Murphy wrote:
> On 2022-04-06 14:06, Jason Gunthorpe wrote:
> > On Wed, Apr 06, 2022 at 01:32:07PM +0100, Robin Murphy wrote:
> > > a particular IOMMU instance, and potentially allocate separate domains for
> > > separate devices to represent the same address space, much like
> > > vfio_iommu_type1_attach_group() does.
> >
> > I think this VFIO code also needs some more work, it currently assumes
> > that if the domain ops are the same then the domains are compatible,
> > and that is not true for ARM SMMU drivers.
>
> Well, strictly it uses the ops as a "negative" heuristic that the domains
> are not definitely incompatible, and only then consolidates domains if
> cross-attaching actually succeeds. So I don't think it's really so bad.
Oh that is sneaky, I didn't appreciate that bit of logic..
> > I've been thinking of adding a domain callback 'can device attach' and
> > replacing the ops compare with that instead.
>
> Previous comment notwithstanding, much as I do tend to prefer "just try the
> operation and see what happens" APIs, that might be more reliable in the
> long run than trying to encode specific "sorry, you'll need to allocate a
> separate domain for this device" vs. "this should have worked but something
> went wrong" semantics in the return value from attach.
Overall the way vfio is doing this has alot of overhead. Not only does
it create a domain it may not use it also does this:
iommu_detach_group(domain->domain, group->iommu_group);
if (!iommu_attach_group(d->domain,
group->iommu_group)) {
list_add(&group->next, &d->group_list);
iommu_domain_free(domain->domain);
kfree(domain);
goto done;
}
ret = iommu_attach_group(domain->domain,
group->iommu_group);
So, if we already have a compatible domain VFIO does an extra domain
alloc/dealloc and 3 extra attach/detatches per domain it tests.
It is not very elegant at least..
> > > It's not really worth IOMMU drivers trying to support a domain spanning
> > > potentially-heterogeneous instances internally, since they can't reasonably
> > > know what matters in any particular situation.
> >
> > In the long run I think it will be worth optimizing. If the SMMU
> > instances can share IOPTE memory then we get two wins - memory
> > reduction and reduced work to read dirty bits.
> >
> > The dirty read in particular is very performance sensitive so if real
> > work loads have many SMMUs per VM it will become a pain point.
>
> In the ideal case though, the SVA domains are only there to logically bridge
> between an existing process pagetable and IOMMU instances at the API level,
> right? Surely if we're shadowing physical pagetables for SVA we've basically
> already lost the performance game?
Sorry, I was not talking about SVA with that remark, speaking
generally about normal iommu_domains and sharing between SMMU
instances.
For SVA I see no issue with duplicating it per instance since it is
very small/etc - the only drawback is that the common code has to do
the 'can device attach' dance and keep a domain list per
mm-struct. Which seems OK to me.
Jason
_______________________________________________
iommu mailing list
iommu@lists.linux-foundation.org
https://lists.linuxfoundation.org/mailman/listinfo/iommu
WARNING: multiple messages have this Message-ID (diff)
From: Jason Gunthorpe <jgg@nvidia.com>
To: Robin Murphy <robin.murphy@arm.com>
Cc: "Tian, Kevin" <kevin.tian@intel.com>,
Lu Baolu <baolu.lu@linux.intel.com>,
Joerg Roedel <joro@8bytes.org>,
Christoph Hellwig <hch@infradead.org>,
"Raj, Ashok" <ashok.raj@intel.com>, Will Deacon <will@kernel.org>,
Jean-Philippe Brucker <jean-philippe@linaro.com>,
Eric Auger <eric.auger@redhat.com>,
"Liu, Yi L" <yi.l.liu@intel.com>,
"Pan, Jacob jun" <jacob.jun.pan@intel.com>,
"iommu@lists.linux-foundation.org"
<iommu@lists.linux-foundation.org>,
"linux-kernel@vger.kernel.org" <linux-kernel@vger.kernel.org>
Subject: Re: [PATCH RFC v2 03/11] iommu/sva: Add iommu_domain type for SVA
Date: Wed, 6 Apr 2022 11:01:44 -0300 [thread overview]
Message-ID: <20220406140144.GD2120790@nvidia.com> (raw)
In-Reply-To: <b7639218-2d10-fd71-0f4b-3af3f8fa224b@arm.com>
On Wed, Apr 06, 2022 at 02:37:40PM +0100, Robin Murphy wrote:
> On 2022-04-06 14:06, Jason Gunthorpe wrote:
> > On Wed, Apr 06, 2022 at 01:32:07PM +0100, Robin Murphy wrote:
> > > a particular IOMMU instance, and potentially allocate separate domains for
> > > separate devices to represent the same address space, much like
> > > vfio_iommu_type1_attach_group() does.
> >
> > I think this VFIO code also needs some more work, it currently assumes
> > that if the domain ops are the same then the domains are compatible,
> > and that is not true for ARM SMMU drivers.
>
> Well, strictly it uses the ops as a "negative" heuristic that the domains
> are not definitely incompatible, and only then consolidates domains if
> cross-attaching actually succeeds. So I don't think it's really so bad.
Oh that is sneaky, I didn't appreciate that bit of logic..
> > I've been thinking of adding a domain callback 'can device attach' and
> > replacing the ops compare with that instead.
>
> Previous comment notwithstanding, much as I do tend to prefer "just try the
> operation and see what happens" APIs, that might be more reliable in the
> long run than trying to encode specific "sorry, you'll need to allocate a
> separate domain for this device" vs. "this should have worked but something
> went wrong" semantics in the return value from attach.
Overall the way vfio is doing this has alot of overhead. Not only does
it create a domain it may not use it also does this:
iommu_detach_group(domain->domain, group->iommu_group);
if (!iommu_attach_group(d->domain,
group->iommu_group)) {
list_add(&group->next, &d->group_list);
iommu_domain_free(domain->domain);
kfree(domain);
goto done;
}
ret = iommu_attach_group(domain->domain,
group->iommu_group);
So, if we already have a compatible domain VFIO does an extra domain
alloc/dealloc and 3 extra attach/detatches per domain it tests.
It is not very elegant at least..
> > > It's not really worth IOMMU drivers trying to support a domain spanning
> > > potentially-heterogeneous instances internally, since they can't reasonably
> > > know what matters in any particular situation.
> >
> > In the long run I think it will be worth optimizing. If the SMMU
> > instances can share IOPTE memory then we get two wins - memory
> > reduction and reduced work to read dirty bits.
> >
> > The dirty read in particular is very performance sensitive so if real
> > work loads have many SMMUs per VM it will become a pain point.
>
> In the ideal case though, the SVA domains are only there to logically bridge
> between an existing process pagetable and IOMMU instances at the API level,
> right? Surely if we're shadowing physical pagetables for SVA we've basically
> already lost the performance game?
Sorry, I was not talking about SVA with that remark, speaking
generally about normal iommu_domains and sharing between SMMU
instances.
For SVA I see no issue with duplicating it per instance since it is
very small/etc - the only drawback is that the common code has to do
the 'can device attach' dance and keep a domain list per
mm-struct. Which seems OK to me.
Jason
next prev parent reply other threads:[~2022-04-06 14:01 UTC|newest]
Thread overview: 124+ messages / expand[flat|nested] mbox.gz Atom feed top
2022-03-29 5:37 [PATCH RFC v2 00/11] iommu: SVA and IOPF refactoring Lu Baolu
2022-03-29 5:37 ` Lu Baolu
2022-03-29 5:37 ` [PATCH RFC v2 01/11] iommu: Add pasid_bits field in struct dev_iommu Lu Baolu
2022-03-29 5:37 ` Lu Baolu
2022-03-29 21:00 ` Jacob Pan
2022-03-29 21:00 ` Jacob Pan
2022-03-30 4:30 ` Lu Baolu
2022-03-30 4:30 ` Lu Baolu
2022-03-30 7:05 ` Tian, Kevin
2022-03-30 7:05 ` Tian, Kevin
2022-03-30 11:58 ` Lu Baolu
2022-03-30 11:58 ` Lu Baolu
2022-03-29 5:37 ` [PATCH RFC v2 02/11] iommu: Add iommu_group_singleton_lockdown() Lu Baolu
2022-03-29 5:37 ` Lu Baolu
2022-03-29 8:42 ` Tian, Kevin
2022-03-29 8:42 ` Tian, Kevin
2022-03-29 11:42 ` Jason Gunthorpe via iommu
2022-03-29 11:42 ` Jason Gunthorpe
2022-03-30 6:50 ` Tian, Kevin
2022-03-30 6:50 ` Tian, Kevin
2022-03-30 11:57 ` Lu Baolu
2022-03-30 11:57 ` Lu Baolu
2022-03-30 11:58 ` Jason Gunthorpe via iommu
2022-03-30 11:58 ` Jason Gunthorpe
2022-03-30 14:12 ` Tian, Kevin
2022-03-30 14:12 ` Tian, Kevin
2022-03-30 14:30 ` Jason Gunthorpe via iommu
2022-03-30 14:30 ` Jason Gunthorpe
2022-04-02 7:12 ` Tian, Kevin
2022-04-02 7:12 ` Tian, Kevin
2022-04-02 23:29 ` Jason Gunthorpe via iommu
2022-04-02 23:29 ` Jason Gunthorpe
2022-04-06 10:02 ` Lu Baolu
2022-04-06 10:02 ` Lu Baolu
2022-04-06 10:44 ` Tian, Kevin
2022-04-06 10:44 ` Tian, Kevin
2022-04-06 11:03 ` Lu Baolu
2022-04-06 11:03 ` Lu Baolu
2022-04-06 23:56 ` Tian, Kevin
2022-04-06 23:56 ` Tian, Kevin
2022-03-30 14:18 ` Tian, Kevin
2022-03-30 14:18 ` Tian, Kevin
2022-03-30 15:04 ` Alex Williamson
2022-03-30 15:04 ` Alex Williamson
2022-04-04 5:43 ` Lu Baolu
2022-04-04 5:43 ` Lu Baolu
2022-04-04 17:24 ` Jason Gunthorpe via iommu
2022-04-04 17:24 ` Jason Gunthorpe
2022-04-05 6:12 ` Lu Baolu
2022-04-05 6:12 ` Lu Baolu
2022-04-05 14:10 ` Jason Gunthorpe via iommu
2022-04-05 14:10 ` Jason Gunthorpe
2022-04-06 9:51 ` Lu Baolu
2022-04-06 9:51 ` Lu Baolu
2022-04-01 6:20 ` Yi Liu
2022-04-01 6:20 ` Yi Liu
2022-04-01 11:52 ` Jason Gunthorpe via iommu
2022-04-01 11:52 ` Jason Gunthorpe
2022-03-30 4:59 ` Lu Baolu
2022-03-30 4:59 ` Lu Baolu
2022-03-30 6:55 ` Tian, Kevin
2022-03-30 6:55 ` Tian, Kevin
2022-04-01 5:49 ` Yi Liu
2022-04-01 5:49 ` Yi Liu
2022-03-29 5:37 ` [PATCH RFC v2 03/11] iommu/sva: Add iommu_domain type for SVA Lu Baolu
2022-03-29 5:37 ` Lu Baolu
2022-03-29 21:38 ` Jacob Pan
2022-03-29 21:38 ` Jacob Pan
2022-03-30 4:35 ` Lu Baolu
2022-03-30 4:35 ` Lu Baolu
2022-03-30 19:02 ` Jason Gunthorpe via iommu
2022-03-30 19:02 ` Jason Gunthorpe
2022-04-02 8:43 ` Tian, Kevin
2022-04-02 8:43 ` Tian, Kevin
2022-04-02 23:32 ` Jason Gunthorpe via iommu
2022-04-02 23:32 ` Jason Gunthorpe
2022-04-04 6:09 ` Lu Baolu
2022-04-04 6:09 ` Lu Baolu
2022-04-06 1:00 ` Tian, Kevin
2022-04-06 1:00 ` Tian, Kevin
2022-04-06 1:23 ` Jason Gunthorpe via iommu
2022-04-06 1:23 ` Jason Gunthorpe
2022-04-06 5:58 ` Tian, Kevin
2022-04-06 5:58 ` Tian, Kevin
2022-04-06 12:32 ` Robin Murphy
2022-04-06 12:32 ` Robin Murphy
2022-04-06 13:06 ` Jason Gunthorpe via iommu
2022-04-06 13:06 ` Jason Gunthorpe
2022-04-06 13:37 ` Robin Murphy
2022-04-06 13:37 ` Robin Murphy
2022-04-06 14:01 ` Jason Gunthorpe via iommu [this message]
2022-04-06 14:01 ` Jason Gunthorpe
2022-04-07 0:11 ` Tian, Kevin
2022-04-07 0:11 ` Tian, Kevin
2022-03-29 5:37 ` [PATCH RFC v2 04/11] iommu: Add attach/detach_dev_pasid domain ops Lu Baolu
2022-03-29 5:37 ` Lu Baolu
2022-03-30 19:08 ` Jason Gunthorpe via iommu
2022-03-30 19:08 ` Jason Gunthorpe
2022-04-04 6:47 ` Lu Baolu
2022-04-04 6:47 ` Lu Baolu
2022-03-29 5:37 ` [PATCH RFC v2 05/11] iommu/vt-d: Remove SVM_FLAG_SUPERVISOR_MODE suport Lu Baolu
2022-03-29 5:37 ` Lu Baolu
2022-03-29 5:37 ` [PATCH RFC v2 06/11] iommu/vt-d: Add SVA domain support Lu Baolu
2022-03-29 5:37 ` Lu Baolu
2022-03-30 19:09 ` Jason Gunthorpe via iommu
2022-03-30 19:09 ` Jason Gunthorpe
2022-04-04 6:52 ` Lu Baolu
2022-04-04 6:52 ` Lu Baolu
2022-03-29 5:37 ` [PATCH RFC v2 07/11] arm-smmu-v3/sva: " Lu Baolu
2022-03-29 5:37 ` Lu Baolu
2022-03-29 5:37 ` [PATCH RFC v2 08/11] iommu/sva: Use attach/detach_pasid_dev in SVA interfaces Lu Baolu
2022-03-29 5:37 ` Lu Baolu
2022-03-31 20:59 ` Jacob Pan
2022-03-31 20:59 ` Jacob Pan
2022-03-31 22:26 ` Jason Gunthorpe via iommu
2022-03-31 22:26 ` Jason Gunthorpe
2022-04-04 5:55 ` Lu Baolu
2022-04-04 5:55 ` Lu Baolu
2022-03-29 5:37 ` [PATCH RFC v2 09/11] iommu: Remove SVA related callbacks from iommu ops Lu Baolu
2022-03-29 5:37 ` Lu Baolu
2022-03-29 5:37 ` [PATCH RFC v2 10/11] iommu: Per-domain I/O page fault handling Lu Baolu
2022-03-29 5:37 ` Lu Baolu
2022-03-29 5:38 ` [PATCH RFC v2 11/11] iommu: Rename iommu-sva-lib.{c,h} Lu Baolu
2022-03-29 5:38 ` Lu Baolu
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=20220406140144.GD2120790@nvidia.com \
--to=iommu@lists.linux-foundation.org \
--cc=ashok.raj@intel.com \
--cc=hch@infradead.org \
--cc=jacob.jun.pan@intel.com \
--cc=jean-philippe@linaro.com \
--cc=jgg@nvidia.com \
--cc=kevin.tian@intel.com \
--cc=linux-kernel@vger.kernel.org \
--cc=robin.murphy@arm.com \
--cc=will@kernel.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.