Re: [RESEND PATCH v3 1/4] iommu/iova: Add free_all_cpu_cached_iovas()

2020-12-09 Thread John Garry

On 09/12/2020 08:58, Leizhen (ThunderTown) wrote:

goto retry;
}
  

Reviewed-by: Zhen Lei




Thanks, incidentally this needs to be rebased, which I'll do now.


Re: [RESEND PATCH v3 1/4] iommu/iova: Add free_all_cpu_cached_iovas()

2020-12-09 Thread Leizhen (ThunderTown)
On 2020/11/17 18:25, John Garry wrote:
> Add a helper function to free the CPU rcache for all online CPUs.
> 
> There also exists a function of the same name in
> drivers/iommu/intel/iommu.c, but the parameters are different, and there
> should be no conflict.
> 
> Signed-off-by: John Garry 
> ---
>  drivers/iommu/iova.c | 13 +
>  1 file changed, 9 insertions(+), 4 deletions(-)
> 
> diff --git a/drivers/iommu/iova.c b/drivers/iommu/iova.c
> index 30d969a4c5fd..81b7399dd5e8 100644
> --- a/drivers/iommu/iova.c
> +++ b/drivers/iommu/iova.c
> @@ -227,6 +227,14 @@ static int __alloc_and_insert_iova_range(struct 
> iova_domain *iovad,
>   return -ENOMEM;
>  }
>  
> +static void free_all_cpu_cached_iovas(struct iova_domain *iovad)
> +{
> + unsigned int cpu;
> +
> + for_each_online_cpu(cpu)
> + free_cpu_cached_iovas(cpu, iovad);
> +}
> +
>  static struct kmem_cache *iova_cache;
>  static unsigned int iova_cache_users;
>  static DEFINE_MUTEX(iova_cache_mutex);
> @@ -422,15 +430,12 @@ alloc_iova_fast(struct iova_domain *iovad, unsigned 
> long size,
>  retry:
>   new_iova = alloc_iova(iovad, size, limit_pfn, true);
>   if (!new_iova) {
> - unsigned int cpu;
> -
>   if (!flush_rcache)
>   return 0;
>  
>   /* Try replenishing IOVAs by flushing rcache. */
>   flush_rcache = false;
> - for_each_online_cpu(cpu)
> - free_cpu_cached_iovas(cpu, iovad);
> + free_all_cpu_cached_iovas(iovad);
>   goto retry;
>   }
>  

Reviewed-by: Zhen Lei 

> 



[RESEND PATCH v3 1/4] iommu/iova: Add free_all_cpu_cached_iovas()

2020-11-17 Thread John Garry
Add a helper function to free the CPU rcache for all online CPUs.

There also exists a function of the same name in
drivers/iommu/intel/iommu.c, but the parameters are different, and there
should be no conflict.

Signed-off-by: John Garry 
---
 drivers/iommu/iova.c | 13 +
 1 file changed, 9 insertions(+), 4 deletions(-)

diff --git a/drivers/iommu/iova.c b/drivers/iommu/iova.c
index 30d969a4c5fd..81b7399dd5e8 100644
--- a/drivers/iommu/iova.c
+++ b/drivers/iommu/iova.c
@@ -227,6 +227,14 @@ static int __alloc_and_insert_iova_range(struct 
iova_domain *iovad,
return -ENOMEM;
 }
 
+static void free_all_cpu_cached_iovas(struct iova_domain *iovad)
+{
+   unsigned int cpu;
+
+   for_each_online_cpu(cpu)
+   free_cpu_cached_iovas(cpu, iovad);
+}
+
 static struct kmem_cache *iova_cache;
 static unsigned int iova_cache_users;
 static DEFINE_MUTEX(iova_cache_mutex);
@@ -422,15 +430,12 @@ alloc_iova_fast(struct iova_domain *iovad, unsigned long 
size,
 retry:
new_iova = alloc_iova(iovad, size, limit_pfn, true);
if (!new_iova) {
-   unsigned int cpu;
-
if (!flush_rcache)
return 0;
 
/* Try replenishing IOVAs by flushing rcache. */
flush_rcache = false;
-   for_each_online_cpu(cpu)
-   free_cpu_cached_iovas(cpu, iovad);
+   free_all_cpu_cached_iovas(iovad);
goto retry;
}
 
-- 
2.26.2