All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH v3] iommu/iova: put free_iova_mem() outside of spinlock iova_rbtree_lock
@ 2021-04-19  7:13 chenxiang
  2021-04-19  7:35 ` John Garry
  2021-05-18  9:08 ` Joerg Roedel
  0 siblings, 2 replies; 6+ messages in thread
From: chenxiang @ 2021-04-19  7:13 UTC (permalink / raw)
  To: robin.murphy, will, joro; +Cc: iommu, linuxarm, linuxarm

From: Xiang Chen <chenxiang66@hisilicon.com>

It is not necessary to put free_iova_mem() inside of spinlock/unlock
iova_rbtree_lock which only leads to more completion for the spinlock.
It has a small promote on the performance after the change. And also
rename private_free_iova() as remove_iova() because the function will not
free iova after that change.

Signed-off-by: Xiang Chen <chenxiang66@hisilicon.com>
---
 drivers/iommu/iova.c | 18 +++++++++++-------
 1 file changed, 11 insertions(+), 7 deletions(-)

diff --git a/drivers/iommu/iova.c b/drivers/iommu/iova.c
index b7ecd5b..b6cf5f1 100644
--- a/drivers/iommu/iova.c
+++ b/drivers/iommu/iova.c
@@ -412,12 +412,11 @@ private_find_iova(struct iova_domain *iovad, unsigned long pfn)
 	return NULL;
 }
 
-static void private_free_iova(struct iova_domain *iovad, struct iova *iova)
+static void remove_iova(struct iova_domain *iovad, struct iova *iova)
 {
 	assert_spin_locked(&iovad->iova_rbtree_lock);
 	__cached_rbnode_delete_update(iovad, iova);
 	rb_erase(&iova->node, &iovad->rbroot);
-	free_iova_mem(iova);
 }
 
 /**
@@ -452,8 +451,9 @@ __free_iova(struct iova_domain *iovad, struct iova *iova)
 	unsigned long flags;
 
 	spin_lock_irqsave(&iovad->iova_rbtree_lock, flags);
-	private_free_iova(iovad, iova);
+	remove_iova(iovad, iova);
 	spin_unlock_irqrestore(&iovad->iova_rbtree_lock, flags);
+	free_iova_mem(iova);
 }
 EXPORT_SYMBOL_GPL(__free_iova);
 
@@ -472,10 +472,13 @@ free_iova(struct iova_domain *iovad, unsigned long pfn)
 
 	spin_lock_irqsave(&iovad->iova_rbtree_lock, flags);
 	iova = private_find_iova(iovad, pfn);
-	if (iova)
-		private_free_iova(iovad, iova);
+	if (!iova) {
+		spin_unlock_irqrestore(&iovad->iova_rbtree_lock, flags);
+		return;
+	}
+	remove_iova(iovad, iova);
 	spin_unlock_irqrestore(&iovad->iova_rbtree_lock, flags);
-
+	free_iova_mem(iova);
 }
 EXPORT_SYMBOL_GPL(free_iova);
 
@@ -825,7 +828,8 @@ iova_magazine_free_pfns(struct iova_magazine *mag, struct iova_domain *iovad)
 		if (WARN_ON(!iova))
 			continue;
 
-		private_free_iova(iovad, iova);
+		remove_iova(iovad, iova);
+		free_iova_mem(iova);
 	}
 
 	spin_unlock_irqrestore(&iovad->iova_rbtree_lock, flags);
-- 
2.8.1

_______________________________________________
iommu mailing list
iommu@lists.linux-foundation.org
https://lists.linuxfoundation.org/mailman/listinfo/iommu

^ permalink raw reply related	[flat|nested] 6+ messages in thread

* Re: [PATCH v3] iommu/iova: put free_iova_mem() outside of spinlock iova_rbtree_lock
  2021-04-19  7:13 [PATCH v3] iommu/iova: put free_iova_mem() outside of spinlock iova_rbtree_lock chenxiang
@ 2021-04-19  7:35 ` John Garry
  2021-05-18  9:08 ` Joerg Roedel
  1 sibling, 0 replies; 6+ messages in thread
From: John Garry @ 2021-04-19  7:35 UTC (permalink / raw)
  To: chenxiang, robin.murphy, will, joro; +Cc: iommu, linuxarm, linuxarm

On 19/04/2021 08:13, chenxiang wrote:
> From: Xiang Chen<chenxiang66@hisilicon.com>
> 
> It is not necessary to put free_iova_mem() inside of spinlock/unlock
> iova_rbtree_lock which only leads to more completion for the spinlock.
> It has a small promote on the performance after the change. And also
> rename private_free_iova() as remove_iova() because the function will not
> free iova after that change.
> 
> Signed-off-by: Xiang Chen<chenxiang66@hisilicon.com>

I think that you will need to resend after v5.13-rc1 comes out, however:

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

> ---
>   drivers/iommu/



_______________________________________________
iommu mailing list
iommu@lists.linux-foundation.org
https://lists.linuxfoundation.org/mailman/listinfo/iommu

^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: [PATCH v3] iommu/iova: put free_iova_mem() outside of spinlock iova_rbtree_lock
  2021-04-19  7:13 [PATCH v3] iommu/iova: put free_iova_mem() outside of spinlock iova_rbtree_lock chenxiang
  2021-04-19  7:35 ` John Garry
@ 2021-05-18  9:08 ` Joerg Roedel
  2021-05-18  9:25   ` chenxiang (M)
                     ` (2 more replies)
  1 sibling, 3 replies; 6+ messages in thread
From: Joerg Roedel @ 2021-05-18  9:08 UTC (permalink / raw)
  To: chenxiang; +Cc: will, iommu, robin.murphy, linuxarm, linuxarm

On Mon, Apr 19, 2021 at 03:13:35PM +0800, chenxiang wrote:
> From: Xiang Chen <chenxiang66@hisilicon.com>
> 
> It is not necessary to put free_iova_mem() inside of spinlock/unlock
> iova_rbtree_lock which only leads to more completion for the spinlock.
> It has a small promote on the performance after the change. And also
> rename private_free_iova() as remove_iova() because the function will not
> free iova after that change.
> 
> Signed-off-by: Xiang Chen <chenxiang66@hisilicon.com>
> ---
>  drivers/iommu/iova.c | 18 +++++++++++-------
>  1 file changed, 11 insertions(+), 7 deletions(-)

Looks good to me, but I'll wait for Robins opinion before applying.

_______________________________________________
iommu mailing list
iommu@lists.linux-foundation.org
https://lists.linuxfoundation.org/mailman/listinfo/iommu

^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: [PATCH v3] iommu/iova: put free_iova_mem() outside of spinlock iova_rbtree_lock
  2021-05-18  9:08 ` Joerg Roedel
@ 2021-05-18  9:25   ` chenxiang (M)
  2021-05-18  9:25   ` Robin Murphy
  2021-05-18  9:26   ` Joerg Roedel
  2 siblings, 0 replies; 6+ messages in thread
From: chenxiang (M) @ 2021-05-18  9:25 UTC (permalink / raw)
  To: Joerg Roedel; +Cc: will, iommu, robin.murphy, linuxarm, linuxarm

Hi Joerg,

在 2021/5/18 17:08, Joerg Roedel 写道:
> On Mon, Apr 19, 2021 at 03:13:35PM +0800, chenxiang wrote:
>> From: Xiang Chen <chenxiang66@hisilicon.com>
>>
>> It is not necessary to put free_iova_mem() inside of spinlock/unlock
>> iova_rbtree_lock which only leads to more completion for the spinlock.
>> It has a small promote on the performance after the change. And also
>> rename private_free_iova() as remove_iova() because the function will not
>> free iova after that change.
>>
>> Signed-off-by: Xiang Chen <chenxiang66@hisilicon.com>
>> ---
>>   drivers/iommu/iova.c | 18 +++++++++++-------
>>   1 file changed, 11 insertions(+), 7 deletions(-)
> Looks good to me, but I'll wait for Robins opinion before applying.

I have re-sent v3, and Robin has given his acked-by:
https://www.mail-archive.com/iommu@lists.linux-foundation.org/msg50950.html

>
>
> .
>


_______________________________________________
iommu mailing list
iommu@lists.linux-foundation.org
https://lists.linuxfoundation.org/mailman/listinfo/iommu

^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: [PATCH v3] iommu/iova: put free_iova_mem() outside of spinlock iova_rbtree_lock
  2021-05-18  9:08 ` Joerg Roedel
  2021-05-18  9:25   ` chenxiang (M)
@ 2021-05-18  9:25   ` Robin Murphy
  2021-05-18  9:26   ` Joerg Roedel
  2 siblings, 0 replies; 6+ messages in thread
From: Robin Murphy @ 2021-05-18  9:25 UTC (permalink / raw)
  To: Joerg Roedel, chenxiang; +Cc: iommu, will, linuxarm, linuxarm

On 2021-05-18 10:08, Joerg Roedel wrote:
> On Mon, Apr 19, 2021 at 03:13:35PM +0800, chenxiang wrote:
>> From: Xiang Chen <chenxiang66@hisilicon.com>
>>
>> It is not necessary to put free_iova_mem() inside of spinlock/unlock
>> iova_rbtree_lock which only leads to more completion for the spinlock.
>> It has a small promote on the performance after the change. And also
>> rename private_free_iova() as remove_iova() because the function will not
>> free iova after that change.
>>
>> Signed-off-by: Xiang Chen <chenxiang66@hisilicon.com>
>> ---
>>   drivers/iommu/iova.c | 18 +++++++++++-------
>>   1 file changed, 11 insertions(+), 7 deletions(-)
> 
> Looks good to me, but I'll wait for Robins opinion before applying.

Go ahead - I acked the resend[1] :)

Thanks,
Robin.

[1] 
https://lore.kernel.org/linux-iommu/9edc6849-f9ff-f6fc-30a0-8bb2e8d3bd0d@arm.com/
_______________________________________________
iommu mailing list
iommu@lists.linux-foundation.org
https://lists.linuxfoundation.org/mailman/listinfo/iommu

^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: [PATCH v3] iommu/iova: put free_iova_mem() outside of spinlock iova_rbtree_lock
  2021-05-18  9:08 ` Joerg Roedel
  2021-05-18  9:25   ` chenxiang (M)
  2021-05-18  9:25   ` Robin Murphy
@ 2021-05-18  9:26   ` Joerg Roedel
  2 siblings, 0 replies; 6+ messages in thread
From: Joerg Roedel @ 2021-05-18  9:26 UTC (permalink / raw)
  To: chenxiang; +Cc: will, iommu, robin.murphy, linuxarm, linuxarm

On Tue, May 18, 2021 at 11:08:47AM +0200, Joerg Roedel wrote:
> Looks good to me, but I'll wait for Robins opinion before applying.

Nevermind, just found the new version which Robin already acked.
_______________________________________________
iommu mailing list
iommu@lists.linux-foundation.org
https://lists.linuxfoundation.org/mailman/listinfo/iommu

^ permalink raw reply	[flat|nested] 6+ messages in thread

end of thread, other threads:[~2021-05-18  9:26 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-04-19  7:13 [PATCH v3] iommu/iova: put free_iova_mem() outside of spinlock iova_rbtree_lock chenxiang
2021-04-19  7:35 ` John Garry
2021-05-18  9:08 ` Joerg Roedel
2021-05-18  9:25   ` chenxiang (M)
2021-05-18  9:25   ` Robin Murphy
2021-05-18  9:26   ` Joerg Roedel

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.