]> git.proxmox.com Git - mirror_ubuntu-zesty-kernel.git/commit
powerpc/mm/iommu, vfio/spapr: Put pages on VFIO container shutdown
authorAlexey Kardashevskiy <aik@ozlabs.ru>
Wed, 30 Nov 2016 06:52:05 +0000 (17:52 +1100)
committerMichael Ellerman <mpe@ellerman.id.au>
Fri, 2 Dec 2016 03:38:34 +0000 (14:38 +1100)
commit4b6fad7097f883335b6d9627c883cb7f276d94c9
tree75ad35b05d8d5a9c5fe6d0dca836948bcddbd0eb
parentbc82d122ae4a0e9f971f13403995898fcfa0c09e
powerpc/mm/iommu, vfio/spapr: Put pages on VFIO container shutdown

At the moment the userspace tool is expected to request pinning of
the entire guest RAM when VFIO IOMMU SPAPR v2 driver is present.
When the userspace process finishes, all the pinned pages need to
be put; this is done as a part of the userspace memory context (MM)
destruction which happens on the very last mmdrop().

This approach has a problem that a MM of the userspace process
may live longer than the userspace process itself as kernel threads
use userspace process MMs which was runnning on a CPU where
the kernel thread was scheduled to. If this happened, the MM remains
referenced until this exact kernel thread wakes up again
and releases the very last reference to the MM, on an idle system this
can take even hours.

This moves preregistered regions tracking from MM to VFIO; insteads of
using mm_iommu_table_group_mem_t::used, tce_container::prereg_list is
added so each container releases regions which it has pre-registered.

This changes the userspace interface to return EBUSY if a memory
region is already registered in a container. However it should not
have any practical effect as the only userspace tool available now
does register memory region once per container anyway.

As tce_iommu_register_pages/tce_iommu_unregister_pages are called
under container->lock, this does not need additional locking.

Signed-off-by: Alexey Kardashevskiy <aik@ozlabs.ru>
Reviewed-by: Nicholas Piggin <npiggin@gmail.com>
Acked-by: Alex Williamson <alex.williamson@redhat.com>
Reviewed-by: David Gibson <david@gibson.dropbear.id.au>
Signed-off-by: Michael Ellerman <mpe@ellerman.id.au>
arch/powerpc/mm/mmu_context_book3s64.c
arch/powerpc/mm/mmu_context_iommu.c
drivers/vfio/vfio_iommu_spapr_tce.c