* Re: [PATCH RESEND v5 1/5] iommu: Refactor iommu_group_store_type()
[not found] ` <1649071634-188535-2-git-send-email-john.garry@huawei.com>
@ 2022-07-06 12:00 ` Will Deacon
[not found] ` <5ab934ff-0b16-0b55-e0f1-36366cd33e84@huawei.com>
0 siblings, 1 reply; 4+ messages in thread
From: Will Deacon @ 2022-07-06 12:00 UTC (permalink / raw)
To: John Garry
Cc: jean-philippe, mst, joro, chenxiang66, linuxarm, linux-kernel,
virtualization, iommu, thunder.leizhen, robin.murphy
On Mon, Apr 04, 2022 at 07:27:10PM +0800, John Garry wrote:
> Function iommu_group_store_type() supports changing the default domain
> of an IOMMU group.
>
> Many conditions need to be satisfied and steps taken for this action to be
> successful.
>
> Satisfying these conditions and steps will be required for setting other
> IOMMU group attributes, so factor into a common part and a part specific
> to update the IOMMU group attribute.
>
> No functional change intended.
>
> Some code comments are tidied up also.
>
> Signed-off-by: John Garry <john.garry@huawei.com>
> ---
> drivers/iommu/iommu.c | 96 ++++++++++++++++++++++++++++---------------
> 1 file changed, 62 insertions(+), 34 deletions(-)
Acked-by: Will Deacon <will@kernel.org>
Will
_______________________________________________
Virtualization mailing list
Virtualization@lists.linux-foundation.org
https://lists.linuxfoundation.org/mailman/listinfo/virtualization
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [PATCH RESEND v5 2/5] iova: Allow rcache range upper limit to be flexible
[not found] ` <1649071634-188535-3-git-send-email-john.garry@huawei.com>
@ 2022-07-06 12:10 ` Will Deacon
[not found] ` <834447a0-675a-5978-8ffe-285ce09f4213@huawei.com>
1 sibling, 0 replies; 4+ messages in thread
From: Will Deacon @ 2022-07-06 12:10 UTC (permalink / raw)
To: John Garry
Cc: jean-philippe, mst, joro, chenxiang66, linuxarm, linux-kernel,
virtualization, iommu, thunder.leizhen, robin.murphy
On Mon, Apr 04, 2022 at 07:27:11PM +0800, John Garry wrote:
> Some low-level drivers may request DMA mappings whose IOVA length exceeds
> that of the current rcache upper limit.
>
> This means that allocations for those IOVAs will never be cached, and
> always must be allocated and freed from the RB tree per DMA mapping cycle.
> This has a significant effect on performance, more so since commit
> 4e89dce72521 ("iommu/iova: Retry from last rb tree node if iova search
> fails"), as discussed at [0].
>
> As a first step towards allowing the rcache range upper limit be
> configured, hold this value in the IOVA rcache structure, and allocate
> the rcaches separately.
>
> Delete macro IOVA_RANGE_CACHE_MAX_SIZE in case it's reused by mistake.
>
> [0] https://lore.kernel.org/linux-iommu/20210129092120.1482-1-thunder.leizhen@huawei.com/
>
> Signed-off-by: John Garry <john.garry@huawei.com>
> ---
> drivers/iommu/iova.c | 20 ++++++++++----------
> include/linux/iova.h | 3 +++
> 2 files changed, 13 insertions(+), 10 deletions(-)
Acked-by: Will Deacon <will@kernel.org>
Will
_______________________________________________
Virtualization mailing list
Virtualization@lists.linux-foundation.org
https://lists.linuxfoundation.org/mailman/listinfo/virtualization
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [PATCH RESEND v5 2/5] iova: Allow rcache range upper limit to be flexible
[not found] ` <834447a0-675a-5978-8ffe-285ce09f4213@huawei.com>
@ 2022-07-06 12:11 ` Will Deacon
0 siblings, 0 replies; 4+ messages in thread
From: Will Deacon @ 2022-07-06 12:11 UTC (permalink / raw)
To: Leizhen (ThunderTown)
Cc: chenxiang66, mst, joro, John Garry, linuxarm, linux-kernel,
virtualization, iommu, jean-philippe, robin.murphy
On Thu, Apr 07, 2022 at 03:52:53PM +0800, Leizhen (ThunderTown) wrote:
> On 2022/4/4 19:27, John Garry wrote:
> > Some low-level drivers may request DMA mappings whose IOVA length exceeds
> > that of the current rcache upper limit.
> >
> > This means that allocations for those IOVAs will never be cached, and
> > always must be allocated and freed from the RB tree per DMA mapping cycle.
> > This has a significant effect on performance, more so since commit
> > 4e89dce72521 ("iommu/iova: Retry from last rb tree node if iova search
> > fails"), as discussed at [0].
> >
> > As a first step towards allowing the rcache range upper limit be
> > configured, hold this value in the IOVA rcache structure, and allocate
> > the rcaches separately.
> >
> > Delete macro IOVA_RANGE_CACHE_MAX_SIZE in case it's reused by mistake.
> >
> > [0] https://lore.kernel.org/linux-iommu/20210129092120.1482-1-thunder.leizhen@huawei.com/
> >
> > Signed-off-by: John Garry <john.garry@huawei.com>
> > ---
> > drivers/iommu/iova.c | 20 ++++++++++----------
> > include/linux/iova.h | 3 +++
> > 2 files changed, 13 insertions(+), 10 deletions(-)
> >
> > diff --git a/drivers/iommu/iova.c b/drivers/iommu/iova.c
> > index db77aa675145..5c22b9187b79 100644
> > --- a/drivers/iommu/iova.c
> > +++ b/drivers/iommu/iova.c
> > @@ -15,8 +15,6 @@
> > /* The anchor node sits above the top of the usable address space */
> > #define IOVA_ANCHOR ~0UL
> >
> > -#define IOVA_RANGE_CACHE_MAX_SIZE 6 /* log of max cached IOVA range size (in pages) */
> > -
> > static bool iova_rcache_insert(struct iova_domain *iovad,
> > unsigned long pfn,
> > unsigned long size);
> > @@ -443,7 +441,7 @@ alloc_iova_fast(struct iova_domain *iovad, unsigned long size,
> > * rounding up anything cacheable to make sure that can't happen. The
> > * order of the unadjusted size will still match upon freeing.
> > */
> > - if (size < (1 << (IOVA_RANGE_CACHE_MAX_SIZE - 1)))
> > + if (size < (1 << (iovad->rcache_max_size - 1)))
> > size = roundup_pow_of_two(size);
> >
> > iova_pfn = iova_rcache_get(iovad, size, limit_pfn + 1);
> > @@ -713,13 +711,15 @@ int iova_domain_init_rcaches(struct iova_domain *iovad)
> > unsigned int cpu;
> > int i, ret;
> >
> > - iovad->rcaches = kcalloc(IOVA_RANGE_CACHE_MAX_SIZE,
> > + iovad->rcache_max_size = 6; /* Arbitrarily high default */
>
> It would be better to assign this constant value to iovad->rcache_max_size
> in init_iova_domain().
I think it's fine where it is as it's a meaningless number outside of the
rcache code.
Will
_______________________________________________
Virtualization mailing list
Virtualization@lists.linux-foundation.org
https://lists.linuxfoundation.org/mailman/listinfo/virtualization
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [PATCH RESEND v5 1/5] iommu: Refactor iommu_group_store_type()
[not found] ` <5ab934ff-0b16-0b55-e0f1-36366cd33e84@huawei.com>
@ 2022-07-06 12:12 ` Will Deacon
0 siblings, 0 replies; 4+ messages in thread
From: Will Deacon @ 2022-07-06 12:12 UTC (permalink / raw)
To: John Garry
Cc: jean-philippe, mst, joro, chenxiang66, linuxarm, linux-kernel,
virtualization, iommu, thunder.leizhen, robin.murphy
On Wed, Jul 06, 2022 at 01:03:44PM +0100, John Garry wrote:
> On 06/07/2022 13:00, Will Deacon wrote:
> > On Mon, Apr 04, 2022 at 07:27:10PM +0800, John Garry wrote:
> > > Function iommu_group_store_type() supports changing the default domain
> > > of an IOMMU group.
> > >
> > > Many conditions need to be satisfied and steps taken for this action to be
> > > successful.
> > >
> > > Satisfying these conditions and steps will be required for setting other
> > > IOMMU group attributes, so factor into a common part and a part specific
> > > to update the IOMMU group attribute.
> > >
> > > No functional change intended.
> > >
> > > Some code comments are tidied up also.
> > >
> > > Signed-off-by: John Garry<john.garry@huawei.com>
> > > ---
> > > drivers/iommu/iommu.c | 96 ++++++++++++++++++++++++++++---------------
> > > 1 file changed, 62 insertions(+), 34 deletions(-)
> > Acked-by: Will Deacon<will@kernel.org>
> >
>
> Thanks, but currently I have no plans to progress this series, in favour of
> this https://lore.kernel.org/linux-iommu/1656590892-42307-1-git-send-email-john.garry@huawei.com/T/#me0e806913050c95f6e6ba2c7f7d96d51ce191204
heh, then I'll stop reviewing it then :) Shame, I quite liked it so far!
Will
_______________________________________________
Virtualization mailing list
Virtualization@lists.linux-foundation.org
https://lists.linuxfoundation.org/mailman/listinfo/virtualization
^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~2022-07-06 12:12 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
[not found] <1649071634-188535-1-git-send-email-john.garry@huawei.com>
[not found] ` <1649071634-188535-2-git-send-email-john.garry@huawei.com>
2022-07-06 12:00 ` [PATCH RESEND v5 1/5] iommu: Refactor iommu_group_store_type() Will Deacon
[not found] ` <5ab934ff-0b16-0b55-e0f1-36366cd33e84@huawei.com>
2022-07-06 12:12 ` Will Deacon
[not found] ` <1649071634-188535-3-git-send-email-john.garry@huawei.com>
2022-07-06 12:10 ` [PATCH RESEND v5 2/5] iova: Allow rcache range upper limit to be flexible Will Deacon
[not found] ` <834447a0-675a-5978-8ffe-285ce09f4213@huawei.com>
2022-07-06 12:11 ` Will Deacon
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox