Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > linux.kernel > #1411176

Re: [PATCH v3 2/2] iommu: Remove cpu-local spinlock

From Joonas Lahtinen <joonas.lahtinen@linux.intel.com>
Newsgroups linux.kernel
Subject Re: [PATCH v3 2/2] iommu: Remove cpu-local spinlock
Date 2016-06-01 14:50 +0200
Message-ID <rFdKX-8sS-39@gated-at.bofh.it> (permalink)
References <rFbzr-7br-21@gated-at.bofh.it> <rFclP-7HG-9@gated-at.bofh.it> <rFclP-7HG-7@gated-at.bofh.it>
Organization Intel Finland Oy - BIC 0357606-4 - Westendinkatu 7, 02160 Espoo

Show all headers | View raw


On ke, 2016-06-01 at 12:10 +0100, Chris Wilson wrote:
> By avoiding cross-CPU usage of the per-cpu iova cache, we can forgo
> having a spinlock inside the per-cpu struct. The only place where we
> actually may touch another CPU's data is when performing a cache flush
> after running out of memory. Here, we can instead schedule a task to run
> on the other CPU to do the flush before trying again.
> 
> Signed-off-by: Chris Wilson <chris@chris-wilson.co.uk>
> Cc: Joonas Lahtinen <joonas.lahtinen@linux.intel.com>
> Cc: Joerg Roedel <joro@8bytes.org>
> Cc: iommu@lists.linux-foundation.org
> Cc: linux-kernel@vger.kernel.org
> ---
>  drivers/iommu/iova.c | 29 ++++++-----------------------
>  1 file changed, 6 insertions(+), 23 deletions(-)
> 
> diff --git a/drivers/iommu/iova.c b/drivers/iommu/iova.c
> index e23001bfcfee..36cdc8eeab1c 100644
> --- a/drivers/iommu/iova.c
> +++ b/drivers/iommu/iova.c
> @@ -390,6 +390,11 @@ free_iova(struct iova_domain *iovad, unsigned long pfn)
>  }
>  EXPORT_SYMBOL_GPL(free_iova);
>  
> +static void free_this_cached_iovas(void *info)
> +{
> +	free_cpu_cached_iovas(smp_processor_id(), info);
> +}
> +
>  /**
>   * alloc_iova_fast - allocates an iova from rcache
>   * @iovad: - iova domain in question
> @@ -413,17 +418,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 (flushed_rcache)
>  			return 0;
>  
>  		/* Try replenishing IOVAs by flushing rcache. */
>  		flushed_rcache = true;
> -		preempt_disable();
> -		for_each_online_cpu(cpu)
> -			free_cpu_cached_iovas(cpu, iovad);
> -		preempt_enable();
> +		on_each_cpu(free_this_cached_iovas, iovad, true);

This is not on a hot path, so should be worthy change.

Reviewed-by: Joonas Lahtinen <joonas.lahtinen@linux.intel.com>

Regards, Joonas

>  		goto retry;
>  	}
>  
Joonas Lahtinen
Open Source Technology Center
Intel Corporation

Back to linux.kernel | Previous | NextPrevious in thread | Next in thread | Find similar | Unroll thread


Thread

[PATCH] iommu: Disable preemption around use of this_cpu_ptr() Chris Wilson <chris@chris-wilson.co.uk> - 2016-05-31 18:40 +0200
  [PATCH v2] iommu: Disable preemption around use of this_cpu_ptr() Chris Wilson <chris@chris-wilson.co.uk> - 2016-06-01 12:30 +0200
    [PATCH v3 2/2] iommu: Remove cpu-local spinlock Chris Wilson <chris@chris-wilson.co.uk> - 2016-06-01 13:20 +0200
      Re: [PATCH v3 2/2] iommu: Remove cpu-local spinlock Joonas Lahtinen <joonas.lahtinen@linux.intel.com> - 2016-06-01 14:50 +0200
    [PATCH v3 1/2] iommu: Disable preemption around use of this_cpu_ptr() Chris Wilson <chris@chris-wilson.co.uk> - 2016-06-01 13:20 +0200
      Re: [PATCH v3 1/2] iommu: Disable preemption around use of  this_cpu_ptr() Joonas Lahtinen <joonas.lahtinen@linux.intel.com> - 2016-06-01 14:30 +0200

csiph-web