lkml.org 
[lkml]   [2019]   [Dec]   [19]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
/
SubjectRe: [Patch v3 3/3] iommu: avoid taking iova_rbtree_lock twice
From
Date
On 18/12/2019 04:39, Cong Wang wrote:
> Both find_iova() and __free_iova() take iova_rbtree_lock,
> there is no reason to take and release it twice inside
> free_iova().
>
> Fold them into one critical section by calling the unlock
> versions instead.
>
> Cc: Joerg Roedel <joro@8bytes.org>
> Cc: John Garry <john.garry@huawei.com>
> Signed-off-by: Cong Wang <xiyou.wangcong@gmail.com>

FWIW:
Reviewed-by: John Garry <john.garry@huawei.com>

> ---
> drivers/iommu/iova.c | 8 ++++++--
> 1 file changed, 6 insertions(+), 2 deletions(-)
>
> diff --git a/drivers/iommu/iova.c b/drivers/iommu/iova.c
> index 184d4c0e20b5..f46f8f794678 100644
> --- a/drivers/iommu/iova.c
> +++ b/drivers/iommu/iova.c
> @@ -390,10 +390,14 @@ EXPORT_SYMBOL_GPL(__free_iova);
> void
> free_iova(struct iova_domain *iovad, unsigned long pfn)
> {
> - struct iova *iova = find_iova(iovad, pfn);
> + unsigned long flags;
> + struct iova *iova;
>
> + spin_lock_irqsave(&iovad->iova_rbtree_lock, flags);
> + iova = private_find_iova(iovad, pfn);
> if (iova)
> - __free_iova(iovad, iova);
> + private_free_iova(iovad, iova);
> + spin_unlock_irqrestore(&iovad->iova_rbtree_lock, flags);
>
> }
> EXPORT_SYMBOL_GPL(free_iova);
>

\
 
 \ /
  Last update: 2019-12-19 10:52    [W:0.441 / U:2.988 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site