hmm: use mmu_notifier_get/put for 'struct hmm'
authorJason Gunthorpe <jgg@mellanox.com>
Tue, 6 Aug 2019 23:15:42 +0000 (20:15 -0300)
committerJason Gunthorpe <jgg@mellanox.com>
Tue, 20 Aug 2019 12:35:02 +0000 (09:35 -0300)
commitc7d8b7824ff9de866a356e1892dbe9f191aa5d06
treea0e5a54cc6d3647bbcfcefb7aa72522a130e68d8
parente4c057d02c9ef0b39bb88544b0c3c0a0a4d55ed6
hmm: use mmu_notifier_get/put for 'struct hmm'

This is a significant simplification, it eliminates all the remaining
'hmm' stuff in mm_struct, eliminates krefing along the critical notifier
paths, and takes away all the ugly locking and abuse of page_table_lock.

mmu_notifier_get() provides the single struct hmm per struct mm which
eliminates mm->hmm.

It also directly guarantees that no mmu_notifier op callback is callable
while concurrent free is possible, this eliminates all the krefs inside
the mmu_notifier callbacks.

The remaining krefs in the range code were overly cautious, drivers are
already not permitted to free the mirror while a range exists.

Link: https://lore.kernel.org/r/20190806231548.25242-6-jgg@ziepe.ca
Reviewed-by: Christoph Hellwig <hch@lst.de>
Reviewed-by: Ralph Campbell <rcampbell@nvidia.com>
Tested-by: Ralph Campbell <rcampbell@nvidia.com>
Signed-off-by: Jason Gunthorpe <jgg@mellanox.com>
drivers/gpu/drm/amd/amdgpu/amdgpu_drv.c
drivers/gpu/drm/nouveau/nouveau_drm.c
include/linux/hmm.h
include/linux/mm_types.h
kernel/fork.c
mm/hmm.c