mm/hmm: Hold on to the mmget for the lifetime of the range
authorJason Gunthorpe <jgg@mellanox.com>
Thu, 23 May 2019 14:08:28 +0000 (11:08 -0300)
committerJason Gunthorpe <jgg@mellanox.com>
Tue, 18 Jun 2019 15:11:16 +0000 (12:11 -0300)
commit47f245985a4f3e270b1e4f28aa49f4c939527981
treeba0dcb5d040a33a32c50a9dbad6f467cc65f248d
parent157816f3775f5c4df2c68ef0e3a100ada974aa2e
mm/hmm: Hold on to the mmget for the lifetime of the range

Range functions like hmm_range_snapshot() and hmm_range_fault() call
find_vma, which requires hodling the mmget() and the mmap_sem for the mm.

Make this simpler for the callers by holding the mmget() inside the range
for the lifetime of the range. Other functions that accept a range should
only be called if the range is registered.

This has the side effect of directly preventing hmm_release() from
happening while a range is registered. That means range->dead cannot be
false during the lifetime of the range, so remove dead and
hmm_mirror_mm_is_alive() entirely.

Signed-off-by: Jason Gunthorpe <jgg@mellanox.com>
Reviewed-by: John Hubbard <jhubbard@nvidia.com>
Reviewed-by: Ralph Campbell <rcampbell@nvidia.com>
Reviewed-by: Christoph Hellwig <hch@lst.de>
Tested-by: Philip Yang <Philip.Yang@amd.com>
include/linux/hmm.h
mm/hmm.c