From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1757974AbcFAMkO (ORCPT ); Wed, 1 Jun 2016 08:40:14 -0400 Received: from mga11.intel.com ([192.55.52.93]:9324 "EHLO mga11.intel.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751570AbcFAMkN (ORCPT ); Wed, 1 Jun 2016 08:40:13 -0400 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.26,401,1459839600"; d="scan'208";a="988830938" Message-ID: <1464784808.6283.4.camel@linux.intel.com> Subject: Re: [PATCH v3 2/2] iommu: Remove cpu-local spinlock From: Joonas Lahtinen To: Chris Wilson , Joerg Roedel Cc: intel-gfx@lists.freedesktop.org, iommu@lists.linux-foundation.org, linux-kernel@vger.kernel.org Date: Wed, 01 Jun 2016 15:40:08 +0300 In-Reply-To: <1464779409-26711-2-git-send-email-chris@chris-wilson.co.uk> References: <1464776603-11998-1-git-send-email-chris@chris-wilson.co.uk> <1464779409-26711-1-git-send-email-chris@chris-wilson.co.uk> <1464779409-26711-2-git-send-email-chris@chris-wilson.co.uk> Organization: Intel Finland Oy - BIC 0357606-4 - Westendinkatu 7, 02160 Espoo Content-Type: text/plain; charset="UTF-8" X-Mailer: Evolution 3.18.5.2 (3.18.5.2-1.fc23) Mime-Version: 1.0 Content-Transfer-Encoding: 8bit Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 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 > Cc: Joonas Lahtinen > Cc: Joerg Roedel > 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 Regards, Joonas >   goto retry; >   } >   Joonas Lahtinen Open Source Technology Center Intel Corporation