From: David Gibson <david@gibson.dropbear.id.au>
To: Alexey Kardashevskiy <aik@ozlabs.ru>
Cc: linuxppc-dev@lists.ozlabs.org,
Alex Williamson <alex.williamson@redhat.com>,
Paul Mackerras <paulus@samba.org>,
kvm@vger.kernel.org
Subject: Re: [PATCH kernel v5 3/6] vfio/spapr: Postpone allocation of userspace version of TCE table
Date: Tue, 22 Nov 2016 10:27:57 +1100 [thread overview]
Message-ID: <20161121232757.GG8681@umbus.fritz.box> (raw)
In-Reply-To: <1478867537-27893-4-git-send-email-aik@ozlabs.ru>
[-- Attachment #1: Type: text/plain, Size: 2265 bytes --]
On Fri, Nov 11, 2016 at 11:32:14PM +1100, Alexey Kardashevskiy wrote:
> The iommu_table struct manages a hardware TCE table and a vmalloc'd
> table with corresponding userspace addresses. Both are allocated when
> the default DMA window is created and this happens when the very first
> group is attached to a container.
>
> As we are going to allow the userspace to configure container in one
> memory context and pas container fd to another, we have to postpones
> such allocations till a container fd is passed to the destination
> user process so we would account locked memory limit against the actual
> container user constrainsts.
>
> This postpones the it_userspace array allocation till it is used first
> time for mapping. The unmapping patch already checks if the array is
> allocated.
>
> Signed-off-by: Alexey Kardashevskiy <aik@ozlabs.ru>
Reviewed-by: David Gibson <david@gibson.dropbear.id.au>
> ---
> drivers/vfio/vfio_iommu_spapr_tce.c | 11 +++++++----
> 1 file changed, 7 insertions(+), 4 deletions(-)
>
> diff --git a/drivers/vfio/vfio_iommu_spapr_tce.c b/drivers/vfio/vfio_iommu_spapr_tce.c
> index d0c38b2..442baac 100644
> --- a/drivers/vfio/vfio_iommu_spapr_tce.c
> +++ b/drivers/vfio/vfio_iommu_spapr_tce.c
> @@ -515,6 +515,12 @@ static long tce_iommu_build_v2(struct tce_container *container,
> unsigned long hpa;
> enum dma_data_direction dirtmp;
>
> + if (!tbl->it_userspace) {
> + ret = tce_iommu_userspace_view_alloc(tbl);
> + if (ret)
> + return ret;
> + }
> +
> for (i = 0; i < pages; ++i) {
> struct mm_iommu_table_group_mem_t *mem = NULL;
> unsigned long *pua = IOMMU_TABLE_USERSPACE_ENTRY(tbl,
> @@ -1068,10 +1074,7 @@ static int tce_iommu_take_ownership(struct tce_container *container,
> if (!tbl || !tbl->it_map)
> continue;
>
> - rc = tce_iommu_userspace_view_alloc(tbl);
> - if (!rc)
> - rc = iommu_take_ownership(tbl);
> -
> + rc = iommu_take_ownership(tbl);
> if (rc) {
> for (j = 0; j < i; ++j)
> iommu_release_ownership(
--
David Gibson | I'll have my music baroque, and my code
david AT gibson.dropbear.id.au | minimalist, thank you. NOT _the_ _other_
| _way_ _around_!
http://www.ozlabs.org/~dgibson
[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 819 bytes --]
next prev parent reply other threads:[~2016-11-22 0:03 UTC|newest]
Thread overview: 19+ messages / expand[flat|nested] mbox.gz Atom feed top
2016-11-11 12:32 [PATCH kernel v5 0/6] powerpc/spapr/vfio: Put pages on VFIO container shutdown Alexey Kardashevskiy
2016-11-11 12:32 ` [PATCH kernel v5 1/6] powerpc/iommu: Pass mm_struct to init/cleanup helpers Alexey Kardashevskiy
2016-11-11 12:32 ` [PATCH kernel v5 2/6] powerpc/iommu: Stop using @current in mm_iommu_xxx Alexey Kardashevskiy
2016-11-11 12:32 ` [PATCH kernel v5 3/6] vfio/spapr: Postpone allocation of userspace version of TCE table Alexey Kardashevskiy
2016-11-21 23:27 ` David Gibson [this message]
2016-11-11 12:32 ` [PATCH kernel v5 4/6] vfio/spapr: Postpone default window creation Alexey Kardashevskiy
2016-11-22 2:50 ` David Gibson
2016-11-22 7:29 ` Alexey Kardashevskiy
2016-11-23 1:35 ` David Gibson
2016-11-23 5:06 ` Alexey Kardashevskiy
2016-11-24 4:08 ` David Gibson
2016-11-11 12:32 ` [PATCH kernel v5 5/6] vfio/spapr: Reference mm in tce_container Alexey Kardashevskiy
2016-11-17 7:39 ` Alexey Kardashevskiy
2016-11-17 21:56 ` Alex Williamson
2016-11-22 2:38 ` David Gibson
2016-11-22 3:49 ` Alexey Kardashevskiy
2016-11-22 7:34 ` Alexey Kardashevskiy
2016-11-23 1:36 ` David Gibson
2016-11-11 12:32 ` [PATCH kernel v5 6/6] powerpc/mm/iommu, vfio/spapr: Put pages on VFIO container shutdown Alexey Kardashevskiy
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=20161121232757.GG8681@umbus.fritz.box \
--to=david@gibson.dropbear.id.au \
--cc=aik@ozlabs.ru \
--cc=alex.williamson@redhat.com \
--cc=kvm@vger.kernel.org \
--cc=linuxppc-dev@lists.ozlabs.org \
--cc=paulus@samba.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).