[<prev] [next>] [thread-next>] [day] [month] [year] [list]
Message-Id: <20180419171234.11053-1-ganapatrao.kulkarni@cavium.com>
Date: Thu, 19 Apr 2018 22:42:34 +0530
From: Ganapatrao Kulkarni <ganapatrao.kulkarni@...ium.com>
To: joro@...tes.org, iommu@...ts.linux-foundation.org,
linux-kernel@...r.kernel.org, robin.murphy@....com
Cc: tomasz.nowicki@...ium.com, jnair@...iumnetworks.com,
Robert.Richter@...ium.com, Vadim.Lomovtsev@...ium.com,
Jan.Glauber@...ium.com, gklkml16@...il.com
Subject: [PATCH] iommu/iova: Update cached node pointer when current node fails to get any free IOVA
The performance drop is observed with long hours iperf testing using 40G
cards. This is mainly due to long iterations in finding the free iova
range in 32bit address space.
In current implementation for 64bit PCI devices, there is always first
attempt to allocate iova from 32bit(SAC preferred over DAC) address
range. Once we run out 32bit range, there is allocation from higher range,
however due to cached32_node optimization it does not suppose to be
painful. cached32_node always points to recently allocated 32-bit node.
When address range is full, it will be pointing to last allocated node
(leaf node), so walking rbtree to find the available range is not
expensive affair. However this optimization does not behave well when
one of the middle node is freed. In that case cached32_node is updated
to point to next iova range. The next iova allocation will consume free
range and again update cached32_node to itself. From now on, walking
over 32-bit range is more expensive.
This patch adds fix to update cached node to leaf node when there are no
iova free range left, which avoids unnecessary long iterations.
Signed-off-by: Ganapatrao Kulkarni <ganapatrao.kulkarni@...ium.com>
---
drivers/iommu/iova.c | 6 ++++++
1 file changed, 6 insertions(+)
diff --git a/drivers/iommu/iova.c b/drivers/iommu/iova.c
index 83fe262..e6ee2ea 100644
--- a/drivers/iommu/iova.c
+++ b/drivers/iommu/iova.c
@@ -201,6 +201,12 @@ static int __alloc_and_insert_iova_range(struct iova_domain *iovad,
} while (curr && new_pfn <= curr_iova->pfn_hi);
if (limit_pfn < size || new_pfn < iovad->start_pfn) {
+ /* No more cached node points to free hole, update to leaf node.
+ */
+ struct iova *prev_iova;
+
+ prev_iova = rb_entry(prev, struct iova, node);
+ __cached_rbnode_insert_update(iovad, prev_iova);
spin_unlock_irqrestore(&iovad->iova_rbtree_lock, flags);
return -ENOMEM;
}
--
2.9.4
Powered by blists - more mailing lists