Re: [PATCH v11 01/12] iova: Export alloc_iova_fast() and free_iova_fast()

2021-08-27 Thread John Garry

On 25/08/2021 13:17, Yongji Xie wrote:

JFYI, There was a preliminary discussion to move the iova rcache code
(which the iova fast alloc and free functions are based on) out of the
iova code and maybe into dma-iommu (being the only user). There was
other motivation.


Would it be better to move the code into ./lib as a general library?


For a start we/I think that the rcache could be removed from the IOVA 
code, but prob should stay in drivers/iommu. I had another IOVA issue to 
solve, which complicates things. No solid plans. Need to talk to Robin more.





https://lore.kernel.org/linux-iommu/83de3911-145d-77c8-17c1-981e4ff82...@arm.com/

Having more users complicates that...


Do we have some plan for this work? From our test [1],
iova_alloc_fast() is much better than iova_alloc(). So I'd like to use
it as much as possible

[1]https://lore.kernel.org/kvm/cacyct3stexfeg7nrbwpo2j59dpycumzcvm2zcpjave40-ev...@mail.gmail.com/


Well if you're alloc'ing and free'ing IOVAs a lot then I can imagine it is.

Thanks,
John
___
iommu mailing list
iommu@lists.linux-foundation.org
https://lists.linuxfoundation.org/mailman/listinfo/iommu


Re: [PATCH v11 01/12] iova: Export alloc_iova_fast() and free_iova_fast()

2021-08-25 Thread Yongji Xie
On Wed, Aug 25, 2021 at 6:35 PM John Garry  wrote:
>
> On 25/08/2021 10:55, Will Deacon wrote:
> > On Tue, Aug 24, 2021 at 02:08:33PM -0400, Michael S. Tsirkin wrote:
> >> On Wed, Aug 18, 2021 at 08:06:31PM +0800, Xie Yongji wrote:
> >>> Export alloc_iova_fast() and free_iova_fast() so that
> >>> some modules can make use of the per-CPU cache to get
> >>> rid of rbtree spinlock in alloc_iova() and free_iova()
> >>> during IOVA allocation.
> >>>
> >>> Signed-off-by: Xie Yongji 
> >>
> >>
> >> This needs ack from iommu maintainers. Guys?
> >
> > Looks fine to me:
> >
> > Acked-by: Will Deacon 
> >
> > Will
> > ___
> > iommu mailing list
> > iommu@lists.linux-foundation.org
> > https://lists.linuxfoundation.org/mailman/listinfo/iommu
> > .
> >
>
> JFYI, There was a preliminary discussion to move the iova rcache code
> (which the iova fast alloc and free functions are based on) out of the
> iova code and maybe into dma-iommu (being the only user). There was
> other motivation.
>

Would it be better to move the code into ./lib as a general library?

> https://lore.kernel.org/linux-iommu/83de3911-145d-77c8-17c1-981e4ff82...@arm.com/
>
> Having more users complicates that...
>

Do we have some plan for this work? From our test [1],
iova_alloc_fast() is much better than iova_alloc(). So I'd like to use
it as much as possible

[1] 
https://lore.kernel.org/kvm/cacyct3stexfeg7nrbwpo2j59dpycumzcvm2zcpjave40-ev...@mail.gmail.com/

Thanks,
Yongji
___
iommu mailing list
iommu@lists.linux-foundation.org
https://lists.linuxfoundation.org/mailman/listinfo/iommu


Re: [PATCH v11 01/12] iova: Export alloc_iova_fast() and free_iova_fast()

2021-08-25 Thread John Garry

On 25/08/2021 10:55, Will Deacon wrote:

On Tue, Aug 24, 2021 at 02:08:33PM -0400, Michael S. Tsirkin wrote:

On Wed, Aug 18, 2021 at 08:06:31PM +0800, Xie Yongji wrote:

Export alloc_iova_fast() and free_iova_fast() so that
some modules can make use of the per-CPU cache to get
rid of rbtree spinlock in alloc_iova() and free_iova()
during IOVA allocation.

Signed-off-by: Xie Yongji 



This needs ack from iommu maintainers. Guys?


Looks fine to me:

Acked-by: Will Deacon 

Will
___
iommu mailing list
iommu@lists.linux-foundation.org
https://lists.linuxfoundation.org/mailman/listinfo/iommu
.



JFYI, There was a preliminary discussion to move the iova rcache code 
(which the iova fast alloc and free functions are based on) out of the 
iova code and maybe into dma-iommu (being the only user). There was 
other motivation.


https://lore.kernel.org/linux-iommu/83de3911-145d-77c8-17c1-981e4ff82...@arm.com/

Having more users complicates that...

Thanks,
John
___
iommu mailing list
iommu@lists.linux-foundation.org
https://lists.linuxfoundation.org/mailman/listinfo/iommu


Re: [PATCH v11 01/12] iova: Export alloc_iova_fast() and free_iova_fast()

2021-08-25 Thread Will Deacon
On Tue, Aug 24, 2021 at 02:08:33PM -0400, Michael S. Tsirkin wrote:
> On Wed, Aug 18, 2021 at 08:06:31PM +0800, Xie Yongji wrote:
> > Export alloc_iova_fast() and free_iova_fast() so that
> > some modules can make use of the per-CPU cache to get
> > rid of rbtree spinlock in alloc_iova() and free_iova()
> > during IOVA allocation.
> > 
> > Signed-off-by: Xie Yongji 
> 
> 
> This needs ack from iommu maintainers. Guys?

Looks fine to me:

Acked-by: Will Deacon 

Will
___
iommu mailing list
iommu@lists.linux-foundation.org
https://lists.linuxfoundation.org/mailman/listinfo/iommu


Re: [PATCH v11 01/12] iova: Export alloc_iova_fast() and free_iova_fast()

2021-08-24 Thread Michael S. Tsirkin
On Wed, Aug 18, 2021 at 08:06:31PM +0800, Xie Yongji wrote:
> Export alloc_iova_fast() and free_iova_fast() so that
> some modules can make use of the per-CPU cache to get
> rid of rbtree spinlock in alloc_iova() and free_iova()
> during IOVA allocation.
> 
> Signed-off-by: Xie Yongji 


This needs ack from iommu maintainers. Guys?

> ---
>  drivers/iommu/iova.c | 2 ++
>  1 file changed, 2 insertions(+)
> 
> diff --git a/drivers/iommu/iova.c b/drivers/iommu/iova.c
> index b6cf5f16123b..3941ed6bb99b 100644
> --- a/drivers/iommu/iova.c
> +++ b/drivers/iommu/iova.c
> @@ -521,6 +521,7 @@ alloc_iova_fast(struct iova_domain *iovad, unsigned long 
> size,
>  
>   return new_iova->pfn_lo;
>  }
> +EXPORT_SYMBOL_GPL(alloc_iova_fast);
>  
>  /**
>   * free_iova_fast - free iova pfn range into rcache
> @@ -538,6 +539,7 @@ free_iova_fast(struct iova_domain *iovad, unsigned long 
> pfn, unsigned long size)
>  
>   free_iova(iovad, pfn);
>  }
> +EXPORT_SYMBOL_GPL(free_iova_fast);
>  
>  #define fq_ring_for_each(i, fq) \
>   for ((i) = (fq)->head; (i) != (fq)->tail; (i) = ((i) + 1) % 
> IOVA_FQ_SIZE)
> -- 
> 2.11.0

___
iommu mailing list
iommu@lists.linux-foundation.org
https://lists.linuxfoundation.org/mailman/listinfo/iommu


Re: [PATCH v11 01/12] iova: Export alloc_iova_fast() and free_iova_fast()

2021-08-22 Thread Jason Wang


在 2021/8/18 下午8:06, Xie Yongji 写道:

Export alloc_iova_fast() and free_iova_fast() so that
some modules can make use of the per-CPU cache to get
rid of rbtree spinlock in alloc_iova() and free_iova()
during IOVA allocation.

Signed-off-by: Xie Yongji 



Acked-by: Jason Wang 

(If we need respin, I'd suggest to put the numbers you measured here)

Thanks



---
  drivers/iommu/iova.c | 2 ++
  1 file changed, 2 insertions(+)

diff --git a/drivers/iommu/iova.c b/drivers/iommu/iova.c
index b6cf5f16123b..3941ed6bb99b 100644
--- a/drivers/iommu/iova.c
+++ b/drivers/iommu/iova.c
@@ -521,6 +521,7 @@ alloc_iova_fast(struct iova_domain *iovad, unsigned long 
size,
  
  	return new_iova->pfn_lo;

  }
+EXPORT_SYMBOL_GPL(alloc_iova_fast);
  
  /**

   * free_iova_fast - free iova pfn range into rcache
@@ -538,6 +539,7 @@ free_iova_fast(struct iova_domain *iovad, unsigned long 
pfn, unsigned long size)
  
  	free_iova(iovad, pfn);

  }
+EXPORT_SYMBOL_GPL(free_iova_fast);
  
  #define fq_ring_for_each(i, fq) \

for ((i) = (fq)->head; (i) != (fq)->tail; (i) = ((i) + 1) % 
IOVA_FQ_SIZE)


___
iommu mailing list
iommu@lists.linux-foundation.org
https://lists.linuxfoundation.org/mailman/listinfo/iommu

[PATCH v11 01/12] iova: Export alloc_iova_fast() and free_iova_fast()

2021-08-18 Thread Xie Yongji
Export alloc_iova_fast() and free_iova_fast() so that
some modules can make use of the per-CPU cache to get
rid of rbtree spinlock in alloc_iova() and free_iova()
during IOVA allocation.

Signed-off-by: Xie Yongji 
---
 drivers/iommu/iova.c | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/drivers/iommu/iova.c b/drivers/iommu/iova.c
index b6cf5f16123b..3941ed6bb99b 100644
--- a/drivers/iommu/iova.c
+++ b/drivers/iommu/iova.c
@@ -521,6 +521,7 @@ alloc_iova_fast(struct iova_domain *iovad, unsigned long 
size,
 
return new_iova->pfn_lo;
 }
+EXPORT_SYMBOL_GPL(alloc_iova_fast);
 
 /**
  * free_iova_fast - free iova pfn range into rcache
@@ -538,6 +539,7 @@ free_iova_fast(struct iova_domain *iovad, unsigned long 
pfn, unsigned long size)
 
free_iova(iovad, pfn);
 }
+EXPORT_SYMBOL_GPL(free_iova_fast);
 
 #define fq_ring_for_each(i, fq) \
for ((i) = (fq)->head; (i) != (fq)->tail; (i) = ((i) + 1) % 
IOVA_FQ_SIZE)
-- 
2.11.0

___
iommu mailing list
iommu@lists.linux-foundation.org
https://lists.linuxfoundation.org/mailman/listinfo/iommu