From: Alex Williamson <alex.williamson-H+wXaHxf7aLQT0dZR+AlfA@public.gmane.org>
To: Suravee Suthikulpanit
<Suravee.Suthikulpanit-5C7GfCeVMHo@public.gmane.org>
Cc: iommu-cunTk1MwBs9QetFLy7KEm3xJsTq8ys+cHZ5vskTnxNA@public.gmane.org,
jroedel-l3A5Bk7waGM@public.gmane.org,
linux-kernel-u79uwXL29TY76Z2rM5mHXA@public.gmane.org
Subject: Re: [PATCH 1/2] vfio/type1: Adopt fast IOTLB flush interface when unmap IOVAs
Date: Fri, 17 Nov 2017 14:51:52 -0700 [thread overview]
Message-ID: <20171117145152.41fae930@t450s.home> (raw)
In-Reply-To: <1510953080-5619-2-git-send-email-Suravee.Suthikulpanit-5C7GfCeVMHo@public.gmane.org>
On Fri, 17 Nov 2017 15:11:19 -0600
Suravee Suthikulpanit <Suravee.Suthikulpanit-5C7GfCeVMHo@public.gmane.org> wrote:
> From: Suravee Suthikulpanit <suravee.suthikulpanit-5C7GfCeVMHo@public.gmane.org>
>
> VFIO IOMMU type1 currently upmaps IOVA pages synchronously, which requires
> IOTLB flushing for every unmapping. This results in large IOTLB flushing
> overhead when handling pass-through devices with a large number of mapped
> IOVAs (e.g. GPUs).
Of course the type of device is really irrelevant, QEMU maps the entire
VM address space for any assigned device.
> This can be avoided by using the new IOTLB flushing interface.
>
> Cc: Alex Williamson <alex.williamson-H+wXaHxf7aLQT0dZR+AlfA@public.gmane.org>
> Cc: Joerg Roedel <jroedel-l3A5Bk7waGM@public.gmane.org>
> Signed-off-by: Suravee Suthikulpanit <suravee.suthikulpanit-5C7GfCeVMHo@public.gmane.org>
> ---
> drivers/vfio/vfio_iommu_type1.c | 12 +++++++++---
> 1 file changed, 9 insertions(+), 3 deletions(-)
>
> diff --git a/drivers/vfio/vfio_iommu_type1.c b/drivers/vfio/vfio_iommu_type1.c
> index 92155cc..28a7ab6 100644
> --- a/drivers/vfio/vfio_iommu_type1.c
> +++ b/drivers/vfio/vfio_iommu_type1.c
> @@ -698,10 +698,12 @@ static long vfio_unmap_unpin(struct vfio_iommu *iommu, struct vfio_dma *dma,
> break;
> }
>
> - unmapped = iommu_unmap(domain->domain, iova, len);
> + unmapped = iommu_unmap_fast(domain->domain, iova, len);
> if (WARN_ON(!unmapped))
> break;
>
> + iommu_tlb_range_add(domain->domain, iova, len);
> +
We should only add @unmapped, not @len, right?
> unlocked += vfio_unpin_pages_remote(dma, iova,
> phys >> PAGE_SHIFT,
> unmapped >> PAGE_SHIFT,
> @@ -710,6 +712,7 @@ static long vfio_unmap_unpin(struct vfio_iommu *iommu, struct vfio_dma *dma,
>
> cond_resched();
> }
> + iommu_tlb_sync(domain->domain);
>
> dma->iommu_mapped = false;
> if (do_accounting) {
> @@ -884,8 +887,11 @@ static int map_try_harder(struct vfio_domain *domain, dma_addr_t iova,
> break;
> }
>
> - for (; i < npage && i > 0; i--, iova -= PAGE_SIZE)
> - iommu_unmap(domain->domain, iova, PAGE_SIZE);
> + for (; i < npage && i > 0; i--, iova -= PAGE_SIZE) {
> + iommu_unmap_fast(domain->domain, iova, PAGE_SIZE);
> + iommu_tlb_range_add(domain->domain, iova, PAGE_SIZE);
> + }
> + iommu_tlb_sync(domain->domain);
>
> return ret;
> }
next prev parent reply other threads:[~2017-11-17 21:51 UTC|newest]
Thread overview: 8+ messages / expand[flat|nested] mbox.gz Atom feed top
2017-11-17 21:11 [PATCH 0/2] Reduce IOTLB flush when pass-through dGPU devices Suravee Suthikulpanit
[not found] ` <1510953080-5619-1-git-send-email-Suravee.Suthikulpanit-5C7GfCeVMHo@public.gmane.org>
2017-11-17 21:11 ` [PATCH 1/2] vfio/type1: Adopt fast IOTLB flush interface when unmap IOVAs Suravee Suthikulpanit
[not found] ` <1510953080-5619-2-git-send-email-Suravee.Suthikulpanit-5C7GfCeVMHo@public.gmane.org>
2017-11-17 21:51 ` Alex Williamson [this message]
[not found] ` <20171117145152.41fae930-1yVPhWWZRC1BDLzU/O5InQ@public.gmane.org>
2017-11-18 4:20 ` Alex Williamson
[not found] ` <20171117212040.7f0921a0-1yVPhWWZRC1BDLzU/O5InQ@public.gmane.org>
2017-11-27 8:14 ` Suravee Suthikulpanit
2017-11-27 8:12 ` Suravee Suthikulpanit
2017-11-17 21:11 ` [PATCH 2/2] iommu/amd: Add support for fast IOTLB flushing Suravee Suthikulpanit
[not found] ` <1510953080-5619-3-git-send-email-Suravee.Suthikulpanit-5C7GfCeVMHo@public.gmane.org>
2017-11-17 22:25 ` Tom Lendacky
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=20171117145152.41fae930@t450s.home \
--to=alex.williamson-h+wxahxf7alqt0dzr+alfa@public.gmane.org \
--cc=Suravee.Suthikulpanit-5C7GfCeVMHo@public.gmane.org \
--cc=iommu-cunTk1MwBs9QetFLy7KEm3xJsTq8ys+cHZ5vskTnxNA@public.gmane.org \
--cc=jroedel-l3A5Bk7waGM@public.gmane.org \
--cc=linux-kernel-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;
as well as URLs for NNTP newsgroup(s).