From: Alex Williamson <alex.williamson-H+wXaHxf7aLQT0dZR+AlfA@public.gmane.org>
To: iommu-cunTk1MwBs9QetFLy7KEm3xJsTq8ys+cHZ5vskTnxNA@public.gmane.org,
kvm-u79uwXL29TY76Z2rM5mHXA@public.gmane.org
Subject: [PATCH 0/3] vfio/type1: map/unmap chunking + conditional rescheduling
Date: Thu, 15 Jan 2015 10:35:08 -0700 [thread overview]
Message-ID: <20150115171023.29162.90105.stgit@gimli.home> (raw)
This series is inspired by the IOMMU tracing code added by Shuah Khan
and a request to report some of those traces for vfio-based device
assignment. What I saw in the trace was an absurd number of calls to
iommu_unmap(). In fact, I had to up the trace log buffer size several
times before I was actually able to capture a full guest startup and
shutdown. The problem was that I was testing on a VT-d system without
IOMMU superpage support, which the current code relies on to produce
any sort or optimization in the unmap path. Without it, we explicitly
unmap every single page. We can do better. In fact, doing better on
Intel simply requires asking the IOMMU for the next translations to
determine the extent of a physically contiguous range to unmap. With
hugetlbfs, this can boost a synthetic VM test case by upwards of 40%,
30% even without hugetlbfs. An IOMMU with 2M superpage support does
pretty well with hugetlbfs, so we break even there, but when using
non-hugepages we can still see about a 30% improvement.
The trouble comes with AMD-Vi, which has crazy awesome fine-grained
superpage support. The above change hurts the existing hugetlbfs case
by about 25% and maybe marginally helps the non-hugepage case.
The solution I've come up with is to attempt to detect fine-grained
superpage support and only enable the vfio-based unmap chunking when
not detected. This maintains AMD-Vi performance while still helping
Intel VT-d. I'm curious to see what this will do on other IOMMUs.
Please test and report.
The trace also showed that we do single page mappings for invalid and
reserved memory regions, like mappings of MMIO BARs, for no good
reason. We only need to skip the accounting here, not the chunking.
Finally, the trace showed that we can run far, far too long with
needs-resched set, so I've sprinked in some cond_resched()s after
potentially time consuming IOMMU operations.
All said, on the troublesome Intel case, these changes result in
about 2% of the iommu_unmap() calls we had originally and only
sporadic needs-resced sightings. Thanks,
Alex
---
Alex Williamson (3):
vfio/type1: Add conditional rescheduling
vfio/type1: Chunk contiguous reserved/invalid page mappings
vfio/type1: DMA unmap chunking
drivers/vfio/vfio_iommu_type1.c | 80 ++++++++++++++++++++++++++++++++++-----
1 file changed, 69 insertions(+), 11 deletions(-)
next reply other threads:[~2015-01-15 17:35 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2015-01-15 17:35 Alex Williamson [this message]
[not found] ` <20150115171023.29162.90105.stgit-GCcqpEzw8uZBDLzU/O5InQ@public.gmane.org>
2015-01-15 17:35 ` [PATCH 1/3] vfio/type1: DMA unmap chunking Alex Williamson
2015-01-15 17:35 ` [PATCH 2/3] vfio/type1: Chunk contiguous reserved/invalid page mappings Alex Williamson
2015-01-15 17:35 ` [PATCH 3/3] vfio/type1: Add conditional rescheduling Alex Williamson
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=20150115171023.29162.90105.stgit@gimli.home \
--to=alex.williamson-h+wxahxf7alqt0dzr+alfa@public.gmane.org \
--cc=iommu-cunTk1MwBs9QetFLy7KEm3xJsTq8ys+cHZ5vskTnxNA@public.gmane.org \
--cc=kvm-u79uwXL29TY76Z2rM5mHXA@public.gmane.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