From: Zaid Alali <zaidal@os.amperecomputing.com>
To: Robin Murphy <robin.murphy@arm.com>,
Joerg Roedel <joro@8bytes.org>, Will Deacon <will@kernel.org>,
iommu@lists.linux.dev
Cc: D Scott Phillips <scott@os.amperecomputing.com>
Subject: [PATCH] iommu/iova: Don't reset cached_node in dac deallocation
Date: Thu, 4 May 2023 05:56:43 -0700 [thread overview]
Message-ID: <ZFOri/cwNVeEIPAf@zaid-VirtualBox> (raw)
The iova allocator has two rbtrees for allocations that are not satisfied
by rcache. The two rbtrees track iovas for the ranges of 32bit address
space and larger address space >32bit. On deallocation, the cached_node
is updated to point to the deallocated iova.
Because the cached_node is moved to point to the recently deallocated
iova with higher address, the first-fit allocator needs to walk the
rbtree backwards skipping holes that do not fit while holding
iova_rbtree_lock, which impacts performance and can cause soft-lockups.
On deallocation, do not reset the cached_node to the freed iova for the
rbtree tracking the dac addresses and keep moving forward with new
allocations. This only affects addresses > 32bit.
This patch was tested with ‘iommu.forcedac=1’ and 20 dd read instances
of 8GB from nvme as well as kernel compilation running in parallel.
The test results obtained from /proc/lock_stat shows the following
improvements for iovad->iova_rbtree_lock:
Wait time average: reduced by 31%
Hold time average: reduced by 60%
Signed-off-by: D Scott Phillips <scott@os.amperecomputing.com>
Signed-off-by: Zaid Alali <zaidal@os.amperecomputing.com>
---
drivers/iommu/iova.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/drivers/iommu/iova.c b/drivers/iommu/iova.c
index fe452ce46..d2a6cb573 100644
--- a/drivers/iommu/iova.c
+++ b/drivers/iommu/iova.c
@@ -106,7 +106,7 @@ __cached_rbnode_delete_update(struct iova_domain *iovad, struct iova *free)
iovad->max32_alloc_size = iovad->dma_32bit_pfn;
cached_iova = to_iova(iovad->cached_node);
- if (free->pfn_lo >= cached_iova->pfn_lo)
+ if (free == cached_iova)
iovad->cached_node = rb_next(&free->node);
}
--
2.34.1
next reply other threads:[~2023-05-04 12:56 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2023-05-04 12:56 Zaid Alali [this message]
2023-05-05 18:55 ` [PATCH] iommu/iova: Don't reset cached_node in dac deallocation Robin Murphy
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=ZFOri/cwNVeEIPAf@zaid-VirtualBox \
--to=zaidal@os.amperecomputing.com \
--cc=iommu@lists.linux.dev \
--cc=joro@8bytes.org \
--cc=robin.murphy@arm.com \
--cc=scott@os.amperecomputing.com \
--cc=will@kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox