[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <dea0de02-cedc-7817-5b04-3888e0e86812@huawei.com>
Date: Fri, 29 Nov 2019 13:34:03 +0000
From: John Garry <john.garry@...wei.com>
To: Cong Wang <xiyou.wangcong@...il.com>,
<iommu@...ts.linux-foundation.org>
CC: <linux-kernel@...r.kernel.org>
Subject: Re: [Patch v2 3/3] iommu: avoid taking iova_rbtree_lock twice
On 29/11/2019 00:48, 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 the critical section by calling the unlock
> versions instead.
Since generally the iova would be non-NULL, this seems a reasonable
change (which could be mentioned in the commit log)
John
>
> Cc: Joerg Roedel <joro@...tes.org>
> Signed-off-by: Cong Wang <xiyou.wangcong@...il.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);
>
Powered by blists - more mailing lists